<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://manicpop.org/gewiki/index.php?action=history&amp;feed=atom&amp;title=MajorBBS_integration</id>
	<title>MajorBBS integration - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://manicpop.org/gewiki/index.php?action=history&amp;feed=atom&amp;title=MajorBBS_integration"/>
	<link rel="alternate" type="text/html" href="https://manicpop.org/gewiki/index.php?title=MajorBBS_integration&amp;action=history"/>
	<updated>2026-10-20T15:20:56Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.2</generator>
	<entry>
		<id>https://manicpop.org/gewiki/index.php?title=MajorBBS_integration&amp;diff=2154&amp;oldid=prev</id>
		<title>CodexBot: Link Btrieve explanation at first mention</title>
		<link rel="alternate" type="text/html" href="https://manicpop.org/gewiki/index.php?title=MajorBBS_integration&amp;diff=2154&amp;oldid=prev"/>
		<updated>2026-10-18T17:53:51Z</updated>

		<summary type="html">&lt;p&gt;Link Btrieve explanation at first mention&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Galactic Empire&amp;#039;&amp;#039;&amp;#039; (GE) is a MajorBBS module, not a standalone server. MajorBBS loads the game, routes users&amp;#039; input to it, supplies channel and account information, runs its scheduled callbacks, formats and sends its output, and provides database services. Understanding that boundary is useful when reading GE&amp;#039;s source or porting it to another host.&lt;br /&gt;
&lt;br /&gt;
== Loading and registration ==&lt;br /&gt;
The 16-bit source supports two MajorBBS integration paths:&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;MajorBBS 5.x:&amp;#039;&amp;#039;&amp;#039; GE is linked into the BBS and enters its common startup routine, &amp;lt;code&amp;gt;iniwara()&amp;lt;/code&amp;gt;, through &amp;lt;code&amp;gt;iniwar()&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;MajorBBS 6.x (Phar Lap):&amp;#039;&amp;#039;&amp;#039; The BBS loads GE as a DLL and calls its exported &amp;lt;code&amp;gt;init__galemp()&amp;lt;/code&amp;gt; initializer. That initializer reads the module description from the game&amp;#039;s MDF file, calls &amp;lt;code&amp;gt;iniwara()&amp;lt;/code&amp;gt;, then passes GE&amp;#039;s &amp;lt;code&amp;gt;struct module&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;register_module()&amp;lt;/code&amp;gt;. The returned module state code is stored in &amp;lt;code&amp;gt;gestt&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The MDF supplies the name used by the BBS Menu Tree. GE uses &amp;lt;code&amp;gt;gmdnam()&amp;lt;/code&amp;gt; to copy that name into the module registration block; the developer&amp;#039;s guide warns that a mismatch between the registered description and the MDF name makes the module inaccessible through the menu. Registration by itself does not put the game in a user&amp;#039;s menu: the sysop must also link the module into the Menu Tree. Classic names its module block &amp;lt;code&amp;gt;mbmge&amp;lt;/code&amp;gt;. ge-next uses &amp;lt;code&amp;gt;mpoge&amp;lt;/code&amp;gt;, while ge-arena uses &amp;lt;code&amp;gt;mpoga&amp;lt;/code&amp;gt;; those builds also have separate MDF and resource files so they can run alongside classic and one another.&lt;br /&gt;
&lt;br /&gt;
Common startup in &amp;lt;code&amp;gt;iniwara()&amp;lt;/code&amp;gt; opens the compiled message bank, reads configuration options, opens [[Btrieve]] files, loads ship classes and other game data, allocates in-memory tables, and starts recurring work with &amp;lt;code&amp;gt;rtkick()&amp;lt;/code&amp;gt;. The 5.x and 6.x routes differ in how the host reaches GE, not in the main game initialization they perform.&lt;br /&gt;
&lt;br /&gt;
== The module interface ==&lt;br /&gt;
MajorBBS&amp;#039;s &amp;lt;code&amp;gt;struct module&amp;lt;/code&amp;gt; contains a description and nine callback slots. GE fills them as follows in its 6.x registration block (the 5.x build uses corresponding host entry points):&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Host event !! GE routine !! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| Supplemental logon || &amp;lt;code&amp;gt;gelogon()&amp;lt;/code&amp;gt; || Optional GE message while a user logs on to the BBS.&lt;br /&gt;
|-&lt;br /&gt;
| Module input || &amp;lt;code&amp;gt;galemp()&amp;lt;/code&amp;gt; || Handles menu selections, prompts, and gameplay commands while the user is in GE.&lt;br /&gt;
|-&lt;br /&gt;
| Status input || &amp;lt;code&amp;gt;stshdlr()&amp;lt;/code&amp;gt; || Handles host status input while GE is selected.&lt;br /&gt;
|-&lt;br /&gt;
| Injected-other input || &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt; || GE does not install a special &amp;lt;code&amp;gt;injoth&amp;lt;/code&amp;gt; handler.&lt;br /&gt;
|-&lt;br /&gt;
| Supplemental logoff || &amp;lt;code&amp;gt;pwarlof()&amp;lt;/code&amp;gt; || Receives the BBS logoff event. In ge-next, it also clears the session&amp;#039;s &amp;lt;code&amp;gt;DATA&amp;lt;/code&amp;gt; state.&lt;br /&gt;
|-&lt;br /&gt;
| Carrier loss / hangup || &amp;lt;code&amp;gt;pwarhup()&amp;lt;/code&amp;gt; || Handles an abrupt disconnect, including any needed ship cleanup.&lt;br /&gt;
|-&lt;br /&gt;
| Midnight cleanup || &amp;lt;code&amp;gt;pgemidnight()&amp;lt;/code&amp;gt; || Runs GE&amp;#039;s daily maintenance work.&lt;br /&gt;
|-&lt;br /&gt;
| Account deletion || &amp;lt;code&amp;gt;pgedelete()&amp;lt;/code&amp;gt; || Removes that user&amp;#039;s GE records when the BBS deletes the account.&lt;br /&gt;
|-&lt;br /&gt;
| System shutdown || &amp;lt;code&amp;gt;pclswar()&amp;lt;/code&amp;gt; || Closes GE resources as the BBS shuts down.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The logon, logoff, hangup, midnight, deletion, and shutdown hooks are host lifecycle events, not commands the player types. The main input callback is different: MajorBBS calls it when a user selects GE and after subsequent input lines. Returning zero leaves the module and returns the user to the parent menu.&lt;br /&gt;
&lt;br /&gt;
== Channels and input state ==&lt;br /&gt;
For user-facing callbacks, MajorBBS supplies globals including &amp;lt;code&amp;gt;usrnum&amp;lt;/code&amp;gt; (the current channel), &amp;lt;code&amp;gt;usrptr&amp;lt;/code&amp;gt; (its live user state), and &amp;lt;code&amp;gt;usaptr&amp;lt;/code&amp;gt; (account information). &amp;lt;code&amp;gt;usrptr-&amp;gt;state&amp;lt;/code&amp;gt; identifies the selected module; &amp;lt;code&amp;gt;usrptr-&amp;gt;substt&amp;lt;/code&amp;gt; identifies the current prompt or input substate within that module. GE&amp;#039;s &amp;lt;code&amp;gt;galemp()&amp;lt;/code&amp;gt; uses &amp;lt;code&amp;gt;substt&amp;lt;/code&amp;gt; to dispatch to the appropriate menu or gameplay handler. It also establishes pointers to the current channel&amp;#039;s GE ship and user entries through &amp;lt;code&amp;gt;warshpoff(usrnum)&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;warusroff(usrnum)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A channel number is a live connection slot, not a permanent player identity. Slots can be reused after a user disconnects; persistent GE records are keyed separately. GE also uses globals as working storage for the current callback. That is ordinary in the single-threaded MajorBBS execution model, but a port cannot treat those globals as independent per-user state or assume a pointer remains valid for a different callback.&lt;br /&gt;
&lt;br /&gt;
== Timed and lifecycle work ==&lt;br /&gt;
During startup, GE schedules recurring callbacks with &amp;lt;code&amp;gt;rtkick()&amp;lt;/code&amp;gt;. Those callbacks process ship movement, automatic systems, Cybertrons and other NPC activity, and planetary updates at different intervals. The 5.x and 6.x builds use different callback wrappers where their required function signatures differ. A callback schedules its next run; the host is not executing a separate GE thread. See [[Game timing]] and [[Game execution flow]] for the full sequence.&lt;br /&gt;
&lt;br /&gt;
The BBS calls GE&amp;#039;s registered [[Game execution flow#Midnight routine|midnight routine]] for daily game maintenance. Separately, when the BBS disconnects users for its own cleanup, it calls GE&amp;#039;s hangup routine. Classic GE treats that hangup like an ordinary disconnect, so a ship still engaged in combat can be lost. MajorBBS provides &amp;lt;code&amp;gt;rsmodes&amp;lt;/code&amp;gt; to indicate that a channel is being reset. ge-next checks it on the hangup path and, when the BBS is disconnecting a combat-locked user for cleanup, saves the ship instead of destroying it.&lt;br /&gt;
&lt;br /&gt;
== Output and message resources ==&lt;br /&gt;
GE&amp;#039;s MSG source is compiled into MCV resource files. &amp;lt;code&amp;gt;opnmsg()&amp;lt;/code&amp;gt; opens a bank, &amp;lt;code&amp;gt;setmbk()&amp;lt;/code&amp;gt; selects it, and &amp;lt;code&amp;gt;prfmsg()&amp;lt;/code&amp;gt; formats a named message into the host&amp;#039;s &amp;lt;code&amp;gt;prfbuf&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;outprf()&amp;lt;/code&amp;gt; sends the formatted text to a channel; &amp;lt;code&amp;gt;clrprf()&amp;lt;/code&amp;gt; discards it. The buffer and its write pointer are shared formatting state, &amp;#039;&amp;#039;&amp;#039;not one independent PRF buffer per channel&amp;#039;&amp;#039;&amp;#039;. GE must select the right bank and explicitly send, reuse, or clear the buffer as it delivers messages to different users. A careless clear or send can hide a message or deliver it to the wrong audience. See [[Configuring Galactic Empire]].&lt;br /&gt;
&lt;br /&gt;
== Persistent data ==&lt;br /&gt;
GE stores users, ships, sectors and planets, and other game records through the host&amp;#039;s Btrieve API. Startup opens the files with the expected record sizes; later operations select a file and use its position block, data buffer, key, operation, and key number. The in-memory channel tables are separate from those persistent records. A port or emulator must preserve the relevant Btrieve key and update behavior, not merely the visible data fields. See [[Data structures]] and [[MBBSEmu]].&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Game execution flow]]&lt;br /&gt;
* [[Game timing]]&lt;br /&gt;
* [[Source code]]&lt;br /&gt;
* [[Porting Galactic Empire]]&lt;br /&gt;
&lt;br /&gt;
== Source ==&lt;br /&gt;
* [https://download.mbbsemu.com/docs/MajorBBS_Developers_Guide_Rev_6.2_Jan_1994.pdf &amp;#039;&amp;#039;The Major BBS Developer&amp;#039;s Guide&amp;#039;&amp;#039;, revision 6.2 (January 1994)], particularly the chapters on module initialization, &amp;lt;code&amp;gt;register_module()&amp;lt;/code&amp;gt;, user state, and PRF output.&lt;br /&gt;
&lt;br /&gt;
{{GE navigation}}&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Platforms]]&lt;/div&gt;</summary>
		<author><name>CodexBot</name></author>
	</entry>
</feed>