Repository navigation
188 mod tool 10 the netplay test game
Question: S7.1 to S7.7 built the mod tool (documents 181 to 187). S7.8 (document 180) makes the game that proves the tool and becomes netplay's test bed. What is that game? What does it contain, which platforms does it run on, how do players find each other, and how does it fit the netplay design on the deterministic Q16.16 sim (document 155)?
This is a design document, agreed with the user on 2026-12-01. Nothing is built yet, and the game's repo does not exist yet. Every answer below is the user's. Where something is a recommendation still to be checked (free server hosts, rollback cost on the web), the document says so. Tracking: #143 (S7) and #43 (netplay, Phase 5).
| Term | Meaning |
|---|---|
| openfire-nettest | The test game: a public repo alexdia25/openfire-nettest with the engine as a submodule and its own standalone pack. All its art, sound and maps are made by the user with the mod tool. The repo name is also the working title; the real title is chosen later (a manifest field). |
| side | One party of a match: its home, its flag, its targets, its colour. Today the engine has exactly two. This game needs up to four. |
| peer | One machine in a networked match. It has one or two local players. |
| input word | One player's controls for one tick (InputWord, document 138). Netplay sends these and nothing else. |
| lockstep | Every peer waits until it has every player's input word for a tick, then runs that tick. |
| rollback | A peer runs ahead on predicted inputs. When the real input arrives and differs, it restores a saved state and re-runs the ticks since then. |
| input delay | A player's input word is applied d ticks after it is pressed, so it has d ticks to reach the other peers before it is needed. |
| rollback window | How many ticks a peer may run ahead on predictions before it must wait. A window of 0 is plain lockstep. |
| signalling | Exchanging the small connection offers WebRTC needs before two browsers can talk to each other directly. |
| STUN / TURN | STUN tells a peer its public address, so a direct link can punch through a home router (NAT). TURN relays the traffic when no direct link is possible. |
- A small 2-to-4-player vehicle battle. It has two contrasting vehicles, two maps (one small, one 128 x 128, each with four homes), and every kind of world object the engine has: buildings and targets, gun turrets, soldiers, drones and mines. The user makes every picture, sound and map.
- Three win rules, any combination, on any map: the flag (the engine's existing rule), a score limit and a time limit. The host picks them per match. The engine gains the score and time rules as pack data, for every game, not only this one.
- A side-pick screen before each match. Each player is a row and each side is a column, and a player moves into a column to join that side. Players in the same column are a team, so free-for-all and teams (2v2, 3v1) come from the same screen. Up to two players can share one machine (split screen) and still play online. The host can also put computer players in any column, online as well as locally (user, 2026-12-01).
-
Web first, desktop later. S7.8 exports to the web, so a tester only opens a link. The transport is built behind the interface of
PORTING_PLAN.md2.5.4, so Windows and Linux builds can join later without a redesign. - Three ways to connect: a room code through a small signalling server; a link code copied and pasted between players, with no server at all; and direct IP in the later desktop builds. The server is swappable, and a free host is preferred.
-
Rollback from the start, with lockstep as a setting of it. The host sets the input delay and the rollback window per match, so the same build can test plain lockstep, pure rollback, and everything between. This reverses
PORTING_PLAN.mdPhase 5's "lockstep first, rollback only if needed". The reason, and the costs, are in Lockstep and rollback. - On a disconnect, the host decides (a match setting): a computer player takes over the side, the vehicle is removed, or the match ends.
- The work splits in two. S7.8 builds the game, its web export, the no-original-asset check and its CI recording, plus the engine features the game itself needs (four sides, the score and time rules, the side-pick screen). Phase 5 builds netplay on top: the transport, rooms, rollback, the host's settings, disconnects.
-
2 to 4 players per match. The engine's match is two-sided today (
MatchController's side slots,menu_def.gd's"sides", Swap Sides). It becomes up to four sides, each with its own home, flag, targets and team colour. This fulfilsPORTING_PLAN.mdsection 0's 4-player goal: the plan asked for "a netcode design that isn't quietly assuming 2 participants", and this game is where that is proven. - Teams come from the side-pick screen. A side may hold one or more players. Free-for-all is one player per side; 2v2 is two sides of two. A side with no player is not in play, unless the host fills it with a computer player.
- Computer players online too (user, 2026-12-01): on the side-pick screen the host adds computer rows (each with its skill level) to any side, beside the people, in an online match as in a local one. The host's peer runs them and sends their input words like a local player's, so the other peers predict and correct them like a person (document 155: a computer player is a controller that only reads the sim, so it may keep floats and need not run on every peer). The same mechanism serves the disconnect policy's "a computer player takes over".
- Teammates share their side's home (user, 2026-12-01, #146): one pad, and teammates take turns on it. A home's vehicle stock is a host setting: one pool shared by the side, or the level's full counts for each player. A side is out when all its players are out. On a 4-home map, homes no side plays are neutral: their buildings are scenery, their turrets sleep, and their flag never appears.
- Host settings for more than two sides: whether a flag capture wins the match or only knocks the captured side out (play goes on until one side is left), and friendly fire between teammates (off by default). A side's vehicles and home take the side's colour.
- Up to two players per machine. The two players on one peer share its screen in split screen (documents 134-141), and each sends its own input word. A 4-player match can be four machines, two machines with two players each, or a mix.
The user's reference is the controller-assignment screen of a console sports game:
- Each player is a row: a local controller, or a remote player labelled with their machine.
- Each side is a column, with the side's name and colour on top. The map decides how many columns there are (2 to 4).
- A row starts in the middle, not playing. Left and right move it into a column. Only a peer's own rows move on that peer.
- Empty rows invite another local controller (up to the per-machine limit).
- A bottom bar has Back (leave the room), the match settings (host only: map, rules, limits, netplay settings, disconnect policy) and Next, which starts the match once every side in play has a player and every peer is ready.
Like every front-end screen since S7.7 (document 187), it is pack data: its labels, layout and skin are the game's, and the engine draws a plain default. It also replaces the "Register player" step for netplay games. A local game uses the same screen with local rows only, so split screen and online play share one path.
The user builds two vehicles with the Vehicles tab and the assembler (documents 184, 185), each with its own weapon:
- A light one: fast, turns quickly, little armour, a rapid weak weapon. It is the flag carrier.
- A heavy one: slow, armoured, a slow strong weapon.
Which one carries the flag, and their exact numbers, are the user's when they build them. The pair is chosen to cover different sim paths cheaply. A flier or a boat would cover more, and can be added later without changing anything here.
All of the engine's world objects are in, because each one is sim state that netplay must keep in agreement:
- Buildings and targets, which the flag rule needs, and their ruins.
- Gun turrets, per side.
- Soldiers, who come out of buildings (walk cycle, death).
- Drones and mines.
Each is configured with the S7.6 tools (document 186).
The engine has one win rule today: destroy the enemy's targets, then bring their flag home. This game needs three, and the engine gains them for every game:
| Rule | Ends the match when | Score counts |
|---|---|---|
| Flag (exists) | a side brings an enemy flag home. With more than two sides: any enemy flag | flag captures |
| Score limit (new) | a side reaches N points | kills, plus a capture's worth (pack data) |
| Time limit (new) | M minutes have passed; the highest score wins, and a tie is a draw (or sudden death, pack data) | as above |
Any rule, on any map. The host turns each rule on or off and sets the limits in the match settings. A map only gives defaults. The chosen rules go to every peer at match start, and they are part of what the netplay handshake agrees on. The score and timer live in the sim (integers, counted in ticks), so they are hashed and kept in agreement like everything else.
| Map | Size | Players | Purpose |
|---|---|---|---|
| Small | about 64 x 64 (the user's choice) | 2-4 | quick matches; the CI recording's map |
| Large | 128 x 128 | 2-4 | the full-size case, and more state per tick |
Both have four homes, so each has four pads, four flags and four target sets. The user paints them with the map editor (document 183). Its 128 x 128 assumptions were already fixed for smaller maps in S7.3. Placing four homes is new: the map editor and level.json learn sides 2 and 3.
Nothing is generated. This is the list to make with the tool. Sizes follow the engine's presets (document 182).
- Tiles: ground, road, water, coast shapes, at least one building type with its ruin, the home pad, and the turret's tile.
- Vehicles: the faces of each body, their team masks, anything that moves (wheels, tracks, a turret).
- Weapons: each weapon's shot, the explosions (sequences), the mine.
- World: the soldier's walk and death, the drone, the flag, the wreck's pieces.
- Four side colours, and the side names.
- Front end: the title picture, the menu skin, the side-pick screen's look, the HUD panels, and the results screen. A font is optional.
- Sounds: each vehicle's engine, each weapon, explosions, hits, soldiers, turrets, drones, the flag pickup and capture, the countdown, menu clicks. Music is optional.
Mermaid source
flowchart TB
T["Title"] --> P["Play online"]
T --> L["Play here<br/>(split screen, computer players)"]
P --> H["Host a room"]
P --> J["Join: room code,<br/>link code, or IP (desktop)"]
H --> R["The room:<br/>side-pick screen"]
J --> R
L --> R
R -->|"host: map, rules,<br/>netplay, disconnect"| R
R -->|"Next: all ready"| C["Handshake and countdown"]
C --> M["Match"]
M -->|"a rule ends it"| S["Results"]
M -->|"a peer drops"| D{"host's policy"}
D -->|"computer takes over<br/>or vehicle removed"| M
D -->|"end the match"| S
S --> R
- Host or join. The host opens a room. Players join it with a room code, a link code, or an IP address (desktop builds only).
- The room is the side-pick screen. Players pick sides, and the host sets the map, the rules and limits, the netplay settings and the disconnect policy. Everyone sees the settings as they change.
- Next runs the handshake: every peer checks it has the same game build and pack (the pack identity hash, #16), receives the match seed, the sides, the rules and the netplay settings, and confirms. Then a countdown starts the match on the same tick everywhere.
-
The match. Each peer sends its players' input words. The peers swap the per-tick state hash (
SimHash, document 156) every few ticks and stop at the first mismatch with a desync report, which is the test bed's main output. - A rule ends it. A results screen shows the winner and each side's score. Then everyone is back on the side-pick screen in the same room for a rematch, and the host can change the map or rules.
- A peer drops. Everyone pauses and waits a short time for a reconnect. Then the host's policy applies: a computer player takes over the side (the host's peer runs it and sends its input words), the side's vehicle is removed, or the match ends.
- Web first. S7.8 exports openfire-nettest to the web only. Testers open a link, so nobody installs anything. The engine already exports and runs a web build in its determinism CI (document 178).
- Desktop later. Windows and Linux builds come after the web build works. Behind the transport interface they can also offer direct IP over ENet, and they cross-play with the web, because the sim is bit-exact on every platform. macOS is not planned.
-
The export is the one
STARTING_A_GAME.mddescribes (#140). The engine is a submodule ataddons/openfire_engine. AnEditorExportPluginadds the pack's files. The engine'stests/andtools/are left out. The repo's CI builds the web export on every push and publishes it (for example to GitHub Pages) so a tester always has the latest build. -
The web's own limits (
PORTING_PLAN.md2.5.5) apply: a click to start audio, gamepads after a button press, and the keyboard always a complete control scheme. - The no-original-asset check (#141) runs on the web export, the build that is handed out.
Mermaid source
flowchart TB
N["netcode: rollback, input words,<br/>hash swap"] --> I["transport interface<br/>(PORTING_PLAN 2.5.4)"]
I --> W["WebRTC data channels<br/>(web and desktop)"]
I --> E["ENet over UDP<br/>(desktop only, later)"]
W --> RC["room code:<br/>signalling server"]
W --> LC["link code:<br/>copy and paste, no server"]
W -. "strict NAT" .-> TU["TURN relay"]
E --> IP["direct IP<br/>(host forwards a port)"]
All three ways are supported:
- Room code. The host's game asks a signalling server for a room and shows a short code. Joiners type it. The server only passes the WebRTC connection offers between peers; the match's traffic goes directly between peers.
- Link code, no server. The host's game shows its WebRTC offer as a code to copy. The joiner pastes it and copies an answer code back. The two codes are sent by any chat. This needs no server at all, only a public STUN server, so it is the free fallback. It fails when both routers block direct links. It is clumsy for more than two peers, because each pair of peers swaps codes, but it is enough for a test.
- Direct IP (desktop builds, later). The host forwards a port and shares an address, over ENet.
Topology: a star around the host for the room and the handshake. For the match itself, every peer sends its input words to every other peer, a full mesh of at most four peers. That keeps latency lowest, and rollback works with either layout. If a mesh link fails, that peer's words travel through the host.
The server is swappable and should be free. The signalling protocol is small (create a room, join a room, pass offers along), so it is one interface with a reference server in the game's repo. Which host runs it is decided in Phase 5. Candidates to check then (none verified yet):
- Godot's own WebRTC signalling demo (a small Node.js server) on a free tier host;
- a serverless WebSocket host;
- an always-free virtual machine;
- public STUN servers;
- a free TURN tier for the strict-NAT case.
The game never hard-codes a server: its address is a setting, so a tester can point at their own.
Both models rest on the same fact: the sim is deterministic (S0-S6, documents 156 to 178). Peers never send positions or hit points, only each player's input word per tick, and every peer runs the whole match itself. The two models differ in what a peer does when a remote player's input for the next tick has not arrived yet.
A peer runs tick t only when it has every player's input word for t. To avoid waiting every tick, each input has an input delay: what a player presses on tick t is applied on tick t + d, and is sent right away, so it has d ticks to arrive.
- Simple. The sim only ever moves forward. Nothing is saved or restored. Sound, effects and the camera are never wrong, because no tick is ever undone.
- Cheap. One tick of sim per tick, which matters on the web, where everything runs on one thread.
- But the delay is felt. Every control responds d ticks late, even locally. The delay must cover the slowest link's round trip, so one far-away player makes everyone's controls sluggish. If a packet is later than d, everyone stalls.
A peer does not wait. For a remote input it hasn't received, it predicts one, usually "the same as their last one", which is right most ticks because players hold keys for many ticks. It runs ahead, saving the sim state each tick. When the real input arrives and differs from the guess, it restores the state of that tick and re-runs every tick since, with the real input, in a single frame.
- Local controls feel immediate, whatever the latency. Remote players' vehicles may visibly jump when a guess was wrong. A wrong guess is noticed only when input changes, which keeps such jumps small.
-
It needs things lockstep does not:
-
Save and restore of the whole sim state, every tick, and fast. The sim is all integers since S5, so a snapshot is plain data.
SimHashalready walks exactly the sim's state (and knows what to skip), so a snapshot can follow the same walk, copying where it hashes. Nothing does this yet; it is the largest new piece. - Re-simulation within a frame. With a window of w ticks, the worst case is w + 1 ticks of sim in one frame. On the web this is the real limit, and it is measured, not guessed: the first rollback step times a tick of the large map with four players and all objects.
- A presentation that tolerates rewinds. Views, sounds and particles read the sim; they must not fire twice or keep a "ghost" from a tick that was undone. Sound cues and effects are keyed by (tick, source), so a re-run of the same tick does not repeat them. A cue from a rolled-back guess that did not happen is cut short or never started.
- Computer players are unaffected: the host's peer runs each of them and sends its input words, which are predicted and corrected like a person's (document 155).
-
Save and restore of the whole sim state, every tick, and fast. The sim is all integers since S5, so a snapshot is plain data.
The plan said lockstep first and rollback only if latency proved unacceptable. The user chose rollback from the start, for three reasons:
- The game is a test bed. Its purpose is to find out what feels right, so it must be able to try both. Building lockstep first and adding rollback later would mean building the netcode twice.
- Lockstep is a special case of rollback. A rollback window of 0 means a peer may never run ahead, so it waits: that is lockstep. With input delay d and window w as two settings, one implementation covers all of these:
| Input delay d | Window w | What it is |
|---|---|---|
| d > 0 | 0 | plain lockstep |
| 0 | w > 0 | pure rollback: always guess |
| small d (1-2 ticks) | w > 0 | the usual mix: the delay absorbs most of the latency, so rollbacks are rarer and shorter |
-
The deterministic sim already pays for the hard part. Rollback's preconditions are a deterministic sim, inputs as small words, and a state hash to catch desyncs, and S0-S6 built all three. What is left (save and restore) is mechanical. The sim was written for it: every object is a plain
RefCountedholding integers, and no scene node is sim state.
The host sets both numbers per match (with safe defaults in the game's pack), and every peer gets them in the handshake. A test session can then compare the settings on the same link: the desync reports, the measured round trips and the rollback counts are logged on every peer, so the comparison rests on data.
What would change this decision. The re-simulation cost on the web. If a frame cannot re-run enough ticks of the large map, the window is capped for web peers. In the worst case web matches fall back to lockstep (window 0) and only desktop uses rollback. The design needs no change for that, only a smaller default.
S7.8, the game (before netplay; issues #140-#142 and new issues for the engine pieces):
| Piece | Where |
|---|---|
| Up to four sides: homes, flags, targets, colours, the map editor's sides 2 and 3, the HUD and split screen for them; computer players on any side | engine, #146, done: document 189 (absorbs #40; delivers #132) |
| Score limit and time limit as rules, beside the flag; any combination, set per match; score and timer in the sim | engine, #147, done: document 190 |
| The side-pick screen (pack data, plain default), local rows only, the match settings, each side's colour; results then back to it | engine, #148 (absorbs #14), done: document 191 |
| The game's repo, its pack (the user's content), the web export plugin, CI publishing the web build | openfire-nettest (#140), started: document 192 |
| The no-original-asset check on the web export | openfire-nettest + openfire's importer (#141) |
| A recorded 4-player match on the small map, with every rule and object in play, replayed on Linux, Windows and the web | openfire-nettest CI (#142) |
Phase 5, netplay (#43, on this game):
| Piece | Notes |
|---|---|
| Save and restore of the sim state | follows SimHash's walk; a check that restore + re-run gives the same hashes as a straight run |
| The transport interface; WebRTC first, ENet later |
PORTING_PLAN.md 2.5.4 |
| Rooms: signalling server (reference implementation, address a setting), room codes, link codes | |
| Rollback with input delay and window as host settings; prediction; re-simulation; desync reports | lockstep is window 0 |
| Remote rows on the side-pick screen; two local players per peer; computer rows the host adds, run by the host's peer | |
| The handshake: pack identity (#16), seed, sides, rules, netplay settings | |
| Disconnects: pause, reconnect, the host's policy | |
| A rollback check in CI: replay the recording with artificially delayed inputs and mispredictions, same hashes as the straight run | extends #142's workflow |
-
Document 155 /
PORTING_PLAN.mdPhase 5: "lockstep with input delay first, rollback only if latency proves unacceptable" becomes "rollback from the start, with lockstep as window 0". The transport rule (2.5.4) stands. -
Document 180 S7.8: the open choices are made. The game is a small netplay test game,
openfire-nettest, public. It ships web first, not Windows, Linux and the web together. It needs the four-side and rules work above before its maps can be finished. - #140's done-condition becomes a web build, built and published in CI, that reaches the title screen and plays a level. Desktop builds are later.
- Every picture, sound, map and vehicle, and the game's real title.
- The vehicles' numbers, the default rules and limits per map, the side names and colours.
- The choice of server host (Phase 5), from the candidates above or others.
- The try-outs: S7.8's (play the web build from a link, hand it to a tester), and Phase 5's (a match over the internet, comparing the netplay settings).
- Engine
game/match_controller.gd: the sides in play (two today), computer players filling sides. - Engine
game/menu_def.gd,game/level_select_screen.gd: the "Register player" table and the two side names. - Engine
game/sim/sim_hash.gd: the walk over the sim's state that save and restore will follow. - Engine
tests/determinism/: the recording and replay that #142 copies. - Engine
docs/STARTING_A_GAME.md: the game's repo and export.
Next: S7.8's engine pieces are done (four sides #146, document 189; the score and time rules #147, document 190; the side-pick screen #148, document 191). The game's repo is made (document 192); next is the user's content, then #141 and #142.
Return Fire, rebuilt
Elsewhere