Jump to content

Source code

From Galactic Empire wiki

Mike Murdock released the classic Galactic Empire source under the GNU General Public License version 2 in 2002. A historical copy is available on SourceForge and was later mirrored to GitHub. Elwynor Technologies subsequently acquired the rights to Galactic Empire from Murdock and maintains the official port. Its source and later descendants, including ge-next and ge-arena, are distributed under the GNU Affero General Public License version 3 (AGPLv3). The original GPLv2 release remains part of the game's licensing history; consult the license supplied with the particular source tree rather than assuming that every independent copy of the original source was automatically relicensed. ge-next's modifications are credited separately to Anthony Schmidt, not claimed as a transfer of the underlying Galactic Empire copyright.

For the wider development reference, see Development and source code.

Principal source files

File Primary responsibility
GEMAIN.C Module lifecycle, user entry, recurring updates
GECMDS.C Player and sysop commands
GEFUNCS.C Shared game mechanics and ship movement
GESCAN.C Scans, reports, and related display logic; a separate source file in ge-next, not classic GE
GEPLANET.C Planet creation and periodic updates
GECYBS.C Cybertron behavior
GEDROIDS.C Droid behavior
GELIB.C Geometry, bearings, and utility routines
GEARENA.C Arena lobby, matches, scoring, and other arena-specific logic; a ge-next file compiled only into ge-arena builds
GEGLOBAL.H Shared globals and structures
GEPROTO.H Function declarations

The table describes the ge-next family. Classic GE organizes some of these responsibilities differently and has neither GESCAN.C nor GEARENA.C.

Configuration sources

Classic GE and ge-next before 0.3 use MBMGEMSG.MSG for messages and configuration options, MBMGEHLP.MSG for help text, and MBMGESHP.MSG for ship classes. In current standard ge-next, those roles belong to MPOGEMSG.MSG, MPOGEHLP.MSG, and MPOGESHP.MSG respectively. ge-arena uses the corresponding MPOGA files. Generated message headers are build artifacts, not the authoritative text to edit.

Reading the source

  • To trace a command, start at the command table and handler in GECMDS.C, then follow helpers into GEFUNCS.C or the relevant subsystem.
  • For periodic behavior, start with callback registration and state routines in GEMAIN.C.
  • For a stored value, inspect its structure and type, then follow each database mutation.
  • For NPC behavior, trace slot allocation in GEMAIN.C, class hooks, then GECYBS.C or GEDROIDS.C.
  • For coordinates, read the call site alongside GELIB.C; do not infer GE's heading convention from ordinary Cartesian geometry.

Compare suspected inherited behavior against the published classic source, not only the current ge-next implementation. See Classic bug database and Porting Galactic Empire.

Notable C routines

This alphabetical index covers major entry points, command handlers, and gameplay routines. The lineage column describes where a routine is defined, not whether a command is available to players in a particular mode. Unless a row says otherwise, every routine listed for ge-next is also compiled into ge-arena. Some standard-game routines are replaced by inert arena stubs; these are marked explicitly. For 16-bit MajorBBS 5.x/6.x callbacks, the table uses the 5.x entry-point name (for example, plarti()). The 6.x entry point is pplarti(); both forward to the 16-bit implementation plartia(). In the 32-bit port, plarti() is the implementation itself. autorti()/autortia() and warrti()/warrtia() follow the same 16-bit pattern.

The clearest rename is classic gravity() to ge-next proximity(): both examine a moving ship's nearby planets and wormholes. Classic's cmd_freq() functionality moved into cmd_set(); its name did not survive as a separate command handler. Classic's useenergy() did not receive a simple one-to-one rename: ge-next's fluxstat() and other energy-use paths handle its former work.

Routine File Lineage / build Purpose
accel() GEFUNCS.C Classic + ge-next Advances ship speed toward its ordered speed; see Impulse travel and Warp travel.
add_cargo_weight() GEFUNCS.C ge-next only Applies an item's weight to ship cargo accounting; see cargo capacity.
arena_apply_loadout() GEARENA.C ge-arena only Installs a selected arena class's starting systems and items.
arena_credit_last_attacker() GEARENA.C ge-arena only Credits an arena kill to the last valid attacker.
arena_data_players() GEARENA.C ge-arena only Writes arena player data for the DATA interface.
arena_data_status() GEARENA.C ge-arena only Writes arena status data for the DATA interface.
arena_drop_zygor() GEARENA.C ge-arena only Generates an announced supply drop at Zygor.
arena_end_match() GEARENA.C ge-arena only Finalizes results, returns players to the lobby, and resets match state.
arena_enter_lobby() GEARENA.C ge-arena only Loads a player into the arena lobby.
arena_find_leaders() GEARENA.C ge-arena only Finds the highest-scoring active players and detects ties.
arena_initialize_world() GEARENA.C ge-arena only Wipes and prepares the disposable galaxy at match setup.
arena_king_move_sector() GEARENA.C ge-arena only Chooses and announces the next King sector.
arena_king_score_tick() GEARENA.C ge-arena only Accrues time in the active King sector.
arena_leave() GEARENA.C ge-arena only Handles arena departure, including kill credit and host succession.
arena_lobby_chat() GEARENA.C ge-arena only Broadcasts a lobby chat message.
arena_parse_ship_choice() GEARENA.C ge-arena only Validates a ship-selection number.
arena_record_win() GEARENA.C ge-arena only Adds a mode-specific win to a user's persistent record.
arena_refresh_win_scores() GEARENA.C ge-arena only Synchronizes persistent arena wins with roster sort fields.
arena_respawn_tick() GEARENA.C ge-arena only Advances the respawn delay and spawns eligible players.
arena_score_compare() GEARENA.C ge-arena only Compares players using the current mode's scoring field.
arena_score_cyb_kill() GEARENA.C ge-arena only Credits a player for a scored Cybertron kill.
arena_score_uncredited_death() GEARENA.C ge-arena only Applies mode-specific consequences for an uncredited death.
arena_score_user_kill() GEARENA.C ge-arena only Applies Scored mode's class-based award and death deduction.
arena_select_ship() GEARENA.C ge-arena only Applies a player's arena ship selection.
arena_set_mode() GEARENA.C ge-arena only Changes the selected arena game mode.
arena_set_observe() GEARENA.C ge-arena only Marks a player to observe the next match.
arena_set_ready() GEARENA.C ge-arena only Marks a player ready for the next match.
arena_ship_destroyed() GEARENA.C ge-arena only Handles arena ship destruction and respawn state.
arena_show_results() GEARENA.C ge-arena only Announces a winner or initiates a tiebreaker.
arena_show_ship_choices() GEARENA.C ge-arena only Prints the mode's ship-selection screen.
arena_show_status() GEARENA.C ge-arena only Displays the mode-specific status table.
arena_spawn_player() GEARENA.C ge-arena only Creates or respawns a player ship in the match.
arena_start_combat() GEARENA.C ge-arena only Ends staging and enables combat.
arena_start_countdown() GEARENA.C ge-arena only Lets the host start staging immediately when enough players are ready.
arena_start_match() GEARENA.C ge-arena only Sets up a new match and staging period.
arena_start_tiebreak() GEARENA.C ge-arena only Moves tied finalists into the confined sudden-death round.
arena_tick() GEARENA.C ge-arena only Runs arena timers, match phases, and periodic mode events.
arena_total_wins() GEARENA.C ge-arena only Sums a user's wins across arena modes.
arena_wipe_galaxy() GEARENA.C ge-arena only Deletes disposable sector and planet records between matches.
assign_cybs() GECYBS.C ge-next only Assigns Cybertrons to nearby player targets; see Cybertrons.
autorti() GEMAIN.C Classic + ge-next Runs scheduled automatic game maintenance work; see Game timing.
calc_networth() GEMAIN.C Classic + standard ge-next only Calculates a user's roster-related net worth; see Scoring and rosters.
calcweight() GEFUNCS.C Classic + ge-next Recomputes a ship's carried cargo weight; see cargo capacity.
cbearing() GELIB.C Classic + ge-next Returns a relative bearing between coordinates; see Bearing.
cdistance() GELIB.C Classic + ge-next Calculates distance between coordinates; see Distance unit.
check_spy() GEPLANET.C Classic + standard ge-next only Processes spies during a planet production update; see Spies.
checkdam() GEFUNCS.C Classic + ge-next Checks hull destruction and repair; see Hull damage and Maintenance.
checkdist() GEFUNCS.C Classic + ge-next Clears hostility after a ship moves away from a planet; see Attacking planets.
checkmines() GEFUNCS.C Classic + ge-next Updates mines and checks for detonations; see Mines.
checktm() GEFUNCS.C Classic + ge-next Updates torpedoes and missiles in flight; see Torpedoes.
chkitm() GEFUNCS.C ge-next only Checks whether a ship can carry another item; see cargo capacity.
clearitm() GEFUNCS.C ge-next only Clears incoming projectile locks on a departing ship; see Wormholes.
cleartm() GEFUNCS.C Classic + ge-next Clears or detaches projectile ownership for a departing ship; see Torpedoes.
cmd_abandon() GECMDS.C Classic + ge-next; arena stub Handles abandonment of a player's planet; see Abandon command.
cmd_abort() GECMDS.C Classic + ge-next; arena stub Cancels an active self-destruct countdown; see Destruct command.
cmd_admin() GECMDS.C Classic + ge-next Opens planetary administration; see Admin command.
cmd_attack() GECMDS.C Classic + ge-next; arena stub Handles attacks against planets; see Attack command.
cmd_buy() GECMDS.C Classic + ge-next; arena stub Buys items from a planet; see Buy command.
cmd_clear() GECMDS.C Classic + ge-next Clears the user's terminal screen; see CLS command.
cmd_cloak() GECMDS.C Classic + ge-next; arena stub Controls a ship's cloaking device; see Cloak command.
cmd_data() GESCAN.C Classic + ge-next Emits machine-readable game state for frontends; see Data command.
cmd_decoy() GECMDS.C Classic + ge-next Deploys decoys; see Decoy command.
cmd_destruct() GECMDS.C Classic + ge-next; arena stub Starts the self-destruct countdown; see Destruct command.
cmd_displ() GECMDS.C Classic only Displays registration status; its RG# command entry is commented out in classic; see Classic registration and security system.
cmd_flux() GECMDS.C Classic + ge-next Manually loads a new flux pod; see Flux command.
cmd_freq() GECMDS.C Classic only Sets a classic radio encoding channel; its behavior moved into SET in ge-next; see Set command.
cmd_gehelp() GECMDS.C Classic + ge-next Displays command and topic help; see Help command.
cmd_geroster() GECMDS.C Classic + ge-next Displays the player roster; see Roster command.
cmd_impulse() GECMDS.C Classic + ge-next Sets an impulse-speed order; see Impulse command.
cmd_jammer() GECMDS.C Classic + ge-next Deploys a jammer; see Jammer command.
cmd_jettison() GECMDS.C Classic + ge-next Discards carried cargo; see Jettison command.
cmd_lock() GECMDS.C Classic + ge-next Acquires or clears a scanner lock; see Lock command.
cmd_maint() GECMDS.C Classic + ge-next Starts maintenance at an eligible planet; see Maintenance command.
cmd_mine() GECMDS.C Classic + ge-next Lays a mine; see Mine command.
cmd_missl() GECMDS.C Classic + ge-next Launches a missile; see Missile command.
cmd_navigate() GECMDS.C Classic + ge-next Reports bearing and distance to a target sector; see Navigate command.
cmd_new() GECMDS.C Classic + ge-next; arena stub Purchases ship systems or upgrades; see New command.
cmd_orbit() GECMDS.C Classic + ge-next Enters or leaves planetary orbit; see Orbit command.
cmd_phas() GECMDS.C Classic + ge-next Fires standard or hyper-phasers; see Phaser command.
cmd_planet() GECMDS.C Classic + ge-next; arena stub Lists planets owned by a player; see Planet command.
cmd_price() GECMDS.C Classic + ge-next; arena stub Displays planetary item prices; see Price command.
cmd_rename() GECMDS.C Classic + ge-next Renames a planet; see Rename command.
cmd_report() GECMDS.C Classic + ge-next Displays ship and system reports; see Report command.
cmd_rotate() GECMDS.C Classic + ge-next Sets a rotation order; see Rotate command.
cmd_scan() GESCAN.C Classic + ge-next Scans sectors, ships, planets, or range maps; see Scan command.
cmd_sell() GECMDS.C Classic + ge-next; arena stub Sells items to a planet; see Sell command.
cmd_send() GECMDS.C Classic + ge-next Sends hails, team messages, or encoded messages; see Send command.
cmd_set() GECMDS.C Classic + ge-next Changes user preferences, message filters, and encoding channels; see Set command.
cmd_shields() GECMDS.C Classic + ge-next Raises or lowers shields; see Shield command.
cmd_spy() GECMDS.C Classic + ge-next; arena stub Deploys or retrieves planetary spies; see Spy command.
cmd_stop() GECMDS.C ge-next only Orders a ship to stop; see Stop command.
cmd_sysop() GECMDS.C Classic + ge-next Dispatches privileged SYS subcommands; see Sys command.
cmd_team() GECMDS.C Classic + ge-next; arena stub Creates and manages player teams; see Team command.
cmd_torp() GECMDS.C Classic + ge-next Launches a torpedo; see Torpedo command.
cmd_transfer() GECMDS.C Classic + ge-next Transfers items between ship and planet; see Transfer command.
cmd_warp() GECMDS.C Classic + ge-next Sets a warp-speed order; see Warp command.
cmd_who() GECMDS.C Classic + ge-next Lists players online or in the game; see Who command.
cmd_zipper() GECMDS.C Classic + ge-next Deploys a zipper; see Zip command.
collect_spoils() GEFUNCS.C ge-next only Transfers surviving cargo from a destroyed ship; see Combat.
coord1() GELIB.C Classic + ge-next Converts a coordinate to its sector number; see Coordinate system.
coord2() GELIB.C Classic + ge-next Gets the within-sector portion of a coordinate; see Coordinate system.
cyb_attack() GECYBS.C Classic + ge-next Runs Cybertron attack decisions; see Cybertrons.
cyb_check_damage() GECYBS.C Classic + ge-next Reacts to damage sustained by a Cybertron; see Cybertrons.
cyb_check_lockon() GECYBS.C Classic + ge-next Updates Cybertron pursuit of a locked target; see Cybertrons.
cyb_died() GECYBS.C Classic + ge-next Handles destruction of a Cybertron; see Cybertrons.
cyb_init() GECYBS.C Classic + ge-next Initializes a newly created Cybertron ship; see Cybertrons.
cyb_lives() GECYBS.C Classic + ge-next Runs the main Cybertron decision pass; see Cybertrons.
cyb_pick_fight() GECYBS.C ge-next only Chooses a Cybertron target; see Cybertrons.
cyb_place_arena_base() GECYBS.C ge-arena only Places a Cyber-Base for arena Base mode.
cyb_won() GECYBS.C Classic + ge-next Handles a Cybertron victory over another ship; see Cybertrons.
droid_check_state() GEDROIDS.C ge-next only Updates a droid's tactical state; see Droids.
droid_died() GEDROIDS.C Classic + ge-next Handles destruction of a droid ship; see Droids.
droid_init() GEDROIDS.C Classic + ge-next Initializes a newly created droid ship; see Droids.
droid_lives() GEDROIDS.C Classic + ge-next Runs the main droid decision pass; see Droids.
droid_won() GEDROIDS.C Classic + ge-next Handles a droid victory over another ship; see Droids.
firehp() GEFUNCS.C Classic + ge-next Fires hyper-phasers; see Hyper-phasers.
fireion() GEFUNCS.C Classic + ge-next Processes ion-cannon fire; see Ion cannons.
firep() GEFUNCS.C Classic + ge-next Fires standard phasers; see Phasers.
fixplanetteam() GEMAIN.C ge-next only Repairs stale team ownership on a planet; see Teams.
fluxstat() GEFUNCS.C Classic + ge-next Checks and draws flux for a system action, reloading pods when needed; see Flux.
fullrepair() GEFUNCS.C ge-next only Restores a ship's repairable systems; see Maintenance.
galemp() GEMAIN.C Classic + ge-next Dispatches the game's main user interface; see Game execution flow.
gedelete() GEMAIN.C Classic + ge-next Deletes a Galactic Empire user record.
gelogon() GEMAIN.C Classic + ge-next Handles user entry into the game; see Game execution flow.
gemidnight() GEMAIN.C Classic + ge-next Runs the nightly maintenance cycle; see Game execution flow.
gepdb() GEMAIN.C Classic + standard ge-next only Reads or writes persistent ship records.
gernd() GELIB.C Classic + ge-next Returns a game pseudorandom number; see Integer and storage assumptions.
gesdb() GEMAIN.C Classic + ge-next Reads or writes sector and planet records.
gesearch() GECMDS.C Classic + ge-next Finds a player command in the command table.
getplanet() GEPLANET.C Classic + ge-next Loads a numbered planetary body in a sector; see Planets.
getsector() GEPLANET.C Classic + ge-next Loads or creates a sector and any wormhole destinations; see Sector.
geudb() GEMAIN.C Classic + ge-next Reads or writes persistent user records.
gravity() GEFUNCS.C Classic only Checks nearby planets and wormholes; renamed to proximity() in ge-next; see Orbit.
gwar() GECMDS.C Classic + ge-next Parses and dispatches a player's game command; see Commands.
hyperspace() GEFUNCS.C Classic + ge-next Handles entry into or exit from hyperspace; see Warp travel.
ingegame() GEMAIN.C Classic + ge-next Tests whether a ship slot is currently active in the game.
initshp() GEFUNCS.C Classic + ge-next Initializes a ship record; see Data structures.
initusr() GEFUNCS.C Classic + ge-next Initializes a user record; see Data structures.
iniwar() GEMAIN.C Classic + ge-next Initializes the Galactic Empire module; see Game execution flow.
innebula() GEPLANET.C ge-next only Tests whether sector coordinates lie in a nebula; see Nebulas.
jam() GECMDS.C Classic + ge-next Applies jammer effects to nearby ships; see Jamming.
jam_scramble() GESCAN.C ge-next only Obscures scanner text according to jamming severity; see Jamming.
killem() GEFUNCS.C Classic + ge-next Processes a ship's destruction and kill consequences; see Kill credit.
laymine() GECMDS.C Classic + ge-next Creates a mine and assigns its owner; see Mines.
load_team_tab() GEMAIN.C Classic + ge-next Loads the team's in-memory lookup table; see Teams.
lockon() GEFUNCS.C Classic + ge-next Tracks or clears a ship's target lock; see Locks.
mailit() GEFUNCS.C Classic + ge-next; arena stub Creates a stored in-game mail message.
mailread() GEFUNCS.C Classic + standard ge-next only Reads in-game mail.
maint_steps() GEFUNCS.C ge-next only Determines maintenance work required for a ship; see Maintenance.
misl() GEFUNCS.C ge-next only Creates and launches a missile projectile; see Missiles.
movecoord() GEFUNCS.C Classic + ge-next Copies one coordinate structure to another.
moveship() GEFUNCS.C Classic + ge-next Advances ship position, including galaxy-edge handling; see movement calculations and Galactic perimeter.
multiply() GEPLANET.C Classic + standard ge-next only Runs one production pass for a planet; see Planetary production.
neutral() GEPLANET.C Classic + ge-next Tests whether coordinates are in the neutral zone; see Neutral zone.
npc_cruise() GEFUNCS.C ge-next only Chooses a roaming course for a non-player ship; see Droids.
outprfge() GEMAIN.C Classic + ge-next Sends formatted output to one player with message-filter handling; see Set command.
outrange() GEMAIN.C Classic + ge-next Broadcasts output to ships within scanner range.
outsect() GEMAIN.C Classic + ge-next Broadcasts output to ships in a sector.
outwar() GEMAIN.C Classic + ge-next Broadcasts output to players in the game.
pdamage() GEFUNCS.C Classic + ge-next Calculates standard or hyper-phaser damage before target resistance; see Phasers.
plarti() GEMAIN.C Classic + standard ge-next only Schedules and performs planetary production updates; see Planetary production.
proximity() GEFUNCS.C ge-next only Checks nearby planets and wormholes; called gravity() in classic; see Orbit.
randamage() GEFUNCS.C Classic + ge-next Distributes secondary system damage and, in ge-next, cargo loss; see System damage.
recharge() GEFUNCS.C Classic + ge-next Recharges a ship's energy pool; see Flux.
refresh() GEFUNCS.C Classic + ge-next Refreshes a ship's nearby planet and wormhole cache; see Sector.
repairship() GEFUNCS.C Classic + ge-next Advances timed ship-system repairs; see Maintenance.
rospos() GEFUNCS.C ge-next only Computes a player's roster position; see Scoring and rosters.
rotateship() GEFUNCS.C Classic + ge-next Advances ship rotation; see Rotation and headings.
scan_pl() GESCAN.C Classic + ge-next Scans a planet or wormhole; see planet scanning.
scan_ra() GESCAN.C Classic + ge-next Draws a range scan; see range scan.
scan_se() GESCAN.C Classic + ge-next Scans a sector; see sector scan.
scan_sh() GESCAN.C Classic + ge-next Scans a ship; see ship scanning.
selectship() GEFUNCS.C Classic + standard ge-next only Selects an available ship slot for a new ship; see Ship slot.
sendit() GEFUNCS.C Classic + ge-next; arena stub Delivers a stored in-game mail message; see Classic bug: Rejected mail leaks into output.
set_dislike() GEFUNCS.C ge-next only Updates a faction's hostility toward a ship; see faction dislike.
shieldchg() GEFUNCS.C Classic + ge-next Advances shield charging; see Shields.
shieldhit() GEFUNCS.C Classic + ge-next Applies a phaser hit to raised shields; see Shields.
shieldup() GEFUNCS.C Classic + ge-next Raises a ship's shields; see Shields.
ship_scanrange() GEFUNCS.C ge-next only Returns the effective scanner range of a ship; see scanner range.
suddenappear() GEFUNCS.C ge-next only Announces a ship emerging from concealment or transit; see Cloaking.
telezip() GEFUNCS.C Classic + ge-next Applies the galactic-perimeter bounce; see Galactic perimeter.
ton_fact() GEFUNCS.C Classic + ge-next Calculates a target's damage-resistance factor; see DAMF.
torp() GEFUNCS.C Classic + ge-next Creates and launches a torpedo projectile; see Torpedoes.
update_scantab() GEFUNCS.C Classic + ge-next Builds the scanner's ship-contact table; see Scantab.
update_team_tab() GEMAIN.C Classic + ge-next Updates the in-memory team lookup table; see Teams.
useenergy() GEFUNCS.C Classic only Checks and deducts a requested amount from the active energy pool in classic; see Flux.
warhup() GEMAIN.C Classic + ge-next Cleans up a user who hangs up; see MajorBBS integration.
warrti() GEMAIN.C Classic + ge-next Runs the six-second ship-system and ordnance pass; see Game timing.
warrti2() GEMAIN.C Classic + ge-next Runs the one-second movement pass for one third of ship slots; see Game timing.
warrti3() GEMAIN.C Classic + standard ge-next only Broadcasts the periodic neutral-zone warning; see Game timing.
xgetsector() GEPLANET.C Classic + ge-next Loads or creates a single sector, optionally suppressing new wormholes; see Sector.
zip() GECMDS.C Classic + ge-next Applies a zipper's short-range displacement; see Zippers.

See Game execution flow, Data structures, and the Classic bug database for implementation-specific notes.

See also