Skip to content

Why the game import table grew, and what moved

Count only callable fields of struct game_import and struct game_export, not buffers, entity metadata, local inline helpers or nested callback arguments. The May 29 main snapshot (22b2ab78) had 24 / 8. The November 29 pre-refactor snapshot (85248cc4) had 55 / 31. The first lifecycle change got to 51 imports; the import cleanup got to 30, and the checkpoint pass got to 30 imports / 28 exports. Stock Quake II has 44 / 15, counting the same way in its native API. Its table includes separate message encoders, command arguments and BSP/Pmove services. These are local boundary budgets, not Quake compatibility numbers.

Why the old choices made sense at the time

The lineage below was traced with first-parent blame on the old table and router, then checked against the defining patches. September's type/formatting renames show up in blame but did not introduce the operations.

Change Problem it solved Where that responsibility belongs now
WoW UI merge introduced the game import for menu actions; August router grouped local menu, map and quit requests; campaign deferral postponed teardown until JASS returned. Initially one in-process path was convenient. Later deferral fixed a real lifetime bug. Keep deferral; don't use the menu renderer or a client string parser as the session controller. The server normalizes and executes authoritative requests, and the local host may interpose presentation.
Pre-rendered movies, model cinematics, early loading screens. Decode media on the client, preserve movie-before-transition ordering, and keep the window responsive during a synchronous load. Use a bounded local presentation handoff and a yield valid only during the load. Dedicated skips the client pump. The wire loading messages remain independent.
Save/load commands, sandboxed script saves, campaign scope bindings, read-only cache paths, control-group sidecar. Keep untrusted script storage separate, avoid creating a scope on a read, restore campaign state and remember client conveniences. The host still owns the roots and policies. One authoritative named-save operation runs before/after hooks and binds its scope. Only a committed save hands off a local sidecar write, completed at the serial host boundary before the next command or map transition. Typed path, edit, and catalog operations keep scopes explicit; they don't accept OS paths from scripts.
Response audio policy, asset probes, priority map reads, external controller. Add sound recipient/range policy, avoid full I/O for probes, honor map overrides, and give the automation adapter acknowledged lifecycle changes. Expose one media registration service, one sound emission service, one asset lookup capability with explicit modes, and a typed external transition request. Preserve the differences in semantics, not one exported entry for each variation.

New boundary

Quake II's server map transition owns map replacement and emits changing/reconnect messages. Its client reacts with a loading plaque and connection state changes. Quake III similarly puts the map command and spawn call on the server. Open Realm keeps its separate title menu libraries: they own routes, authored controls and glue rendering. The local client owns visual presentation, focus and media playback. It does not resolve maps or decide which save namespace to use. The server owns those choices and executes the same authoritative operation after the listen host's presentation gate or on the dedicated scheduler.

The 30 remaining calls are: - Memory and diagnostics (4): allocation/free, fatal error, monotonic diagnostics. - Media and sound/UI effects (3): registration, sound emission, minimap ping. - World entity index (4): link, unlink, box query and clear. - Lifecycle, configuration and time (8): session/external requests, map resolve, lobby application, cvar lookup, simulation clock read/write and pause. - Network publication (5): multicast, unicast, typed write and configstring read/write. - VFS and save storage (6): asset access, priority archive, storage path/edit, catalog visit and script-scope identity.

Checkpoints and preventing renewed growth

The four save-event exports came from two real compatibility requirements, not from map deferral. Named save/load events supplied the Warcraft III script with a transient filename; the scripted zone restore needed a different campaign trigger, so a zone restore would not replace live zone storage with a named slot's backup. These are now four phases of one optional Checkpoint export. Only the pre-save phase can veto a write. A committed save or completed restore is a notification, and the server never passes an absolute path to the hook. Snapshot I/O and map identity remain separate from the notifications. No phase is added for menus, videos or loading screens.

Before changing either table, identify who owns the operation. If it is a menu action or rendering effect, keep it out of the server/game ABI. If it arises purely from server lifecycle, handle it in the host after the current game callback returns. Combine slots only when they are phases or variants of the same service; a general-purpose string router or nested table would only hide the size. If a genuinely new cross-boundary capability is needed, document its owner, lifetime, and which clients or modules use it before raising the budget.

make test-game-abi-boundary checks both flat tables (at most 30 imports and 28 exports) and rejects the removed presentation imports. It allows only the existing entity data fields in the export table. This is a tripwire, not a replacement for reviewing the contract. Shared compile definitions and runtime module loading remain separate issues #726 and #727.