N10: Playable network client

The client program now turns a connection into a match someone can play.

- ClientSession: a ClientGame, the keyboard and mouse as commands
  (ClientInput), and a MatchView of the client's own copy of the world.
- ClientMirror writes what the client is showing into that world every
  frame: other players from the recent past, its own player where it was
  predicted, items, the barge, the clock and the sea. The existing views
  draw it unchanged.
- LocalServer: offline play is the same ServerLoop and NetGame in the same
  process, with packets handed across in memory, so there is one path.
- main.gd: --connect=HOST[:PORT] joins a server, otherwise an offline
  match; --autoplay and --client-seconds=N for scripts and checks.
- The camera aboard the barge follows the player's own place on the deck.

Tests drive a scripted client through a whole match on a real server over
loopback UDP, lobby to results, and through an offline match. `make
client-check` does it with two real processes, and `make client-captures`
renders what the client sees.

Closes #77

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-12 14:50:52 -05:00
co-authored by Claude Opus 5.5
parent 6b21e9d4f1
commit 9a36ae8615
25 changed files with 1089 additions and 13 deletions
+33 -2
View File
@@ -408,8 +408,39 @@ weights from the island's elevation bands, with rock on steep ground.
sea, points of interest, props, built pieces and `EntityView`, which draws players, the
barge, items and chests. All of it reads one `Simulation` and never writes to it, and a
new match gets a new view. The camera sits on a player's shoulder through `CameraRig`.
Until snapshots arrive, the simulation it reads is a local server's or a replay's; the
figures, barge and items are stand-in shapes for the art pass to replace.
The figures, barge and items are stand-in shapes for the art pass to replace.
In play, the simulation it reads is the client's own copy of the world: the
`Simulation` that `ClientGame` generates from the match's seed and never steps.
`ClientWorld` keeps its pieces, props, chests and tide in line with the server, and
`ClientMirror` (`src/net/`) writes the rest of the picture into it every frame: each
entity the server has told this client about, where it is being drawn now (everyone
else from the recent past, the client's own player where it was predicted), the barge,
the clock and the sea level. So the same views draw a networked match, a local
server's simulation in a test, or a replay in a capture, and there is one set of
drawing code. Captures and tests still point a `MatchView` straight at a server's
simulation.
## The client program
`ClientSession` (`src/app/`) is the game while it is in a match: a `ClientGame`, a
`ClientInput` turning the keyboard and mouse into one command a tick, a `ClientMirror`
and a `MatchView`. Its `pump()` does a frame's work and needs no scene tree, so tests
drive it.
The server is either across the network (`--connect=HOST:PORT`, a `NetClient`) or in
the same process (`LocalServer`, `src/server/`): the same `ServerLoop` and `NetGame` a
dedicated server runs, with the packets handed across in memory, reliable ones first,
in the order a socket would deliver them. The client can't tell the difference, so
offline play is the network path with no network, as "Rules that do not bend" asks.
`src/app/main.gd` picks the mode: `--server` runs the dedicated server; otherwise the
game starts an offline match, or joins a server with `--connect`. Without a window
(`tools/godot.sh` is always headless) a mode has to be asked for. `--autoplay` puts a
small script at the controls and `--client-seconds=N` quits after N seconds with one
JSON line saying how far the client got, which is what `make client-check` reads.
There are no menus yet (N6, A10) and no HUD (A9): one line of text says when the
client is connecting, in the lobby or watching.
## Performance budgets