<?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=Game_execution_flow</id>
	<title>Game execution flow - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://manicpop.org/gewiki/index.php?action=history&amp;feed=atom&amp;title=Game_execution_flow"/>
	<link rel="alternate" type="text/html" href="https://manicpop.org/gewiki/index.php?title=Game_execution_flow&amp;action=history"/>
	<updated>2026-10-20T16:28:37Z</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=Game_execution_flow&amp;diff=2163&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=Game_execution_flow&amp;diff=2163&amp;oldid=prev"/>
		<updated>2026-10-18T17:54:09Z</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; is a MajorBBS module, not a standalone program with one continuously running game loop. MajorBBS calls the module at startup and later dispatches user input, timer callbacks, and lifecycle events independently. The diagram summarizes the module architecture shared by classic GE and ge-next, with ge-arena differences identified where they change the flow. It is a map of responsibilities, not a guarantee that callbacks happen in the order drawn.&lt;br /&gt;
&lt;br /&gt;
[[File:GE module flow shared GE.png|center|alt=MajorBBS module startup branching into player input, recurring callbacks, and lifecycle events that share game state]]&lt;br /&gt;
&lt;br /&gt;
Solid arrows are direct calls; dashed arrows represent later host dispatch; dotted arrows show access to shared game state.&lt;br /&gt;
&lt;br /&gt;
== Startup ==&lt;br /&gt;
In the 16-bit MajorBBS 5.x build, the module&amp;#039;s startup entry point is &amp;lt;code&amp;gt;iniwar()&amp;lt;/code&amp;gt;; in the 6.x PHARLAP build, it is &amp;lt;code&amp;gt;init__galemp()&amp;lt;/code&amp;gt;. Both call &amp;lt;code&amp;gt;iniwara()&amp;lt;/code&amp;gt;. That routine loads options and message resources, opens the relevant [[Btrieve]] files, builds ship-class and other live tables, and registers the first recurring callbacks with &amp;lt;code&amp;gt;rtkick()&amp;lt;/code&amp;gt;. The 6.x entry point then calls &amp;lt;code&amp;gt;register_module()&amp;lt;/code&amp;gt;. The resulting module interface tells MajorBBS which functions to invoke for input and lifecycle events.&lt;br /&gt;
&lt;br /&gt;
== Runtime branches ==&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Player input:&amp;#039;&amp;#039;&amp;#039; MajorBBS can invoke &amp;lt;code&amp;gt;gelogon()&amp;lt;/code&amp;gt; at login and &amp;lt;code&amp;gt;galemp()&amp;lt;/code&amp;gt; when a user selects the module or enters text within it. &amp;lt;code&amp;gt;galemp()&amp;lt;/code&amp;gt; looks up the user&amp;#039;s current &amp;lt;code&amp;gt;substt&amp;lt;/code&amp;gt; in the menu-state table, then calls the matching handler. That handler may present the main menu, interpret a ship command, continue a prompt, or enter the ge-arena lobby.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Recurring callbacks:&amp;#039;&amp;#039;&amp;#039; Each scheduled callback runs its work and schedules its next &amp;lt;code&amp;gt;rtkick()&amp;lt;/code&amp;gt;. The one-second &amp;lt;code&amp;gt;warrti2()&amp;lt;/code&amp;gt; path moves one third of the ship slots; the separate one-second &amp;lt;code&amp;gt;autorti()&amp;lt;/code&amp;gt; path visits automated ships. ge-arena also advances its match timers from &amp;lt;code&amp;gt;warrti2()&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;warrti()&amp;lt;/code&amp;gt; runs the six-second ship-system pass. GE also runs the neutral-zone warning through &amp;lt;code&amp;gt;warrti3()&amp;lt;/code&amp;gt; and variable-interval planet updates through &amp;lt;code&amp;gt;plarti()&amp;lt;/code&amp;gt;. In 16-bit GE, the 5.x and 6.x timer entry points are forwarding wrappers: for example, &amp;lt;code&amp;gt;plarti()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;pplarti()&amp;lt;/code&amp;gt; both call &amp;lt;code&amp;gt;plartia()&amp;lt;/code&amp;gt;. The same pattern applies to &amp;lt;code&amp;gt;autortia()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;warrtia()&amp;lt;/code&amp;gt;. In the 32-bit port, &amp;lt;code&amp;gt;plarti()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;autorti()&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;warrti()&amp;lt;/code&amp;gt; contain the implementations directly. See [[Game timing]] for exact first-run intervals, called routines, and gameplay consequences.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Lifecycle events:&amp;#039;&amp;#039;&amp;#039; MajorBBS invokes the module&amp;#039;s logoff, hangup, account-deletion, midnight-cleanup, and shutdown hooks separately from &amp;lt;code&amp;gt;galemp()&amp;lt;/code&amp;gt;. Their implementation routines release or update the relevant game state. These hooks are dispatched by MajorBBS rather than by the player-input routine or a game timer.&lt;br /&gt;
&lt;br /&gt;
All three runtime branches can read or change shared in-memory user and ship tables and persistent Btrieve records. The diagram&amp;#039;s bottom bar represents those resources, not a fourth periodic callback. A callback may observe a change made by another branch on its next scheduled pass; there is no single master tick that synchronizes them. The calls and timing within the recurring branch are detailed in [[Game timing]].&lt;br /&gt;
&lt;br /&gt;
== Nightly cleanup and shutdown ==&lt;br /&gt;
=== Midnight routine ===&lt;br /&gt;
During the BBS&amp;#039;s scheduled cleanup, MajorBBS invokes GE&amp;#039;s registered midnight callback: &amp;lt;code&amp;gt;gemidnight()&amp;lt;/code&amp;gt; on 5.x or &amp;lt;code&amp;gt;pgemidnight()&amp;lt;/code&amp;gt; on 6.x. Both forward to &amp;lt;code&amp;gt;gemidnighta()&amp;lt;/code&amp;gt;. Despite the name, this runs when the &amp;#039;&amp;#039;BBS&amp;#039;&amp;#039; performs its daily cleanup, not from a GE timer that fires at exactly 12:00 a.m. It is a lifecycle callback, separate from the recurring &amp;lt;code&amp;gt;rtkick()&amp;lt;/code&amp;gt; schedules.&lt;br /&gt;
&lt;br /&gt;
In classic GE and normal ge-next play, the routine performs these jobs in order:&lt;br /&gt;
# It clears each player&amp;#039;s cached planet count, population, planet score, and total score. ge-next also reduces saved faction dislike and prunes stale automated-ship records.&lt;br /&gt;
# It walks the planet database. For every owned planet with a matching player record, it recalculates the planet&amp;#039;s contribution to that player&amp;#039;s score and totals, then creates a planetary status report for the owner. ge-next also checks whether the first scheduled planet-update pass completed; if not, it arranges for the update interval to be recalculated.&lt;br /&gt;
# It deletes old mail and mail addressed to deleted players, according to the configured retention period.&lt;br /&gt;
# It reconciles team membership, clears invalid team assignments, recomputes player totals from planet and kill scores, removes empty teams, and updates team standings. Classic also saves each player&amp;#039;s roster position for the rank-based kill bonus. ge-next instead determines current roster position when needed and can write an optional text roster export.&lt;br /&gt;
&lt;br /&gt;
This pass &amp;#039;&amp;#039;accounts for&amp;#039;&amp;#039; planets; it does not run planetary production. Production is driven by the separate [[Planetary update cycle|planet-update schedule]]. Combat points are applied when kills occur, whereas planet value and the resulting roster total are refreshed here. See [[Scoring and rosters]] and [[Teams]] for the scoring rules and team calculations.&lt;br /&gt;
&lt;br /&gt;
ge-arena uses the same host callback for a much narrower job: it refreshes persistent win totals for its roster and writes the optional roster export. It does not run the normal game&amp;#039;s planet, mail, or team cleanup.&lt;br /&gt;
&lt;br /&gt;
=== Shutdown and disconnections ===&lt;br /&gt;
The midnight callback itself does not disconnect players or close the module. When the BBS disconnects users as part of its own cleanup, GE receives separate hangup callbacks; the [[MajorBBS integration]] page explains the classic combat-loss consequence and ge-next&amp;#039;s &amp;lt;code&amp;gt;rsmodes&amp;lt;/code&amp;gt; safeguard. On module shutdown, MajorBBS calls &amp;lt;code&amp;gt;clswar()&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;pclswar()&amp;lt;/code&amp;gt;, which forward to &amp;lt;code&amp;gt;clswara()&amp;lt;/code&amp;gt; to close message and database files. Ordinary logoff, hangup, and account deletion can also occur at other times. The diagram therefore branches after startup rather than drawing a single path that ends at midnight.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Game timing]]&lt;br /&gt;
* [[Source code]]&lt;br /&gt;
* [[MajorBBS integration]]&lt;br /&gt;
* [[Data structures]]&lt;br /&gt;
&lt;br /&gt;
{{GE navigation}}&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Source code]]&lt;/div&gt;</summary>
		<author><name>CodexBot</name></author>
	</entry>
</feed>