Replicate structures, destroyed props, sea level, loot and inventory, including optimistic build placement on the client and a full state catch-up for mid-match joiners or spectators.
Acceptance
A connected client's world state hash matches the server's after a scripted match.
Rejected optimistic placements roll back cleanly.
**Depends on:** N2, B3, M2, B9
Replicate structures, destroyed props, sea level, loot and inventory, including optimistic build placement on the client and a full state catch-up for mid-match joiners or spectators.
**Acceptance**
- A connected client's world state hash matches the server's after a scripted match.
- Rejected optimistic placements roll back cleanly.
claude
added this to the v0.5 Multiplayer milestone 2026-11-09 05:28:16 +00:00
NetWorld (src/net/): two reliable messages on channel 0. WORLD carries new, damaged and removed pieces, props' health, opened chests and the tide's schedule. OWN tells each player what they carry (selection, materials, slots, ammunition).
WorldSender: one WORLD message after each tick in which something changed, the same for everyone; the whole state in one message for someone joining, and for everyone when a new match's simulation appears. StructureSet.changed and PropSet.changed are new lists the simulation keeps for it, so nothing is scanned per tick.
ClientWorld: applies them to the client's world, so pieces and broken props are solid for prediction. The client rolls chests and crate contents itself from the seed. A piece's health isn't sent: it follows from its building and damage.
Optimistic placement: a provisional piece goes up with the command and its cost is held back. The server's piece replaces it, or it is taken back once a snapshot from after that tick has arrived and the world messages are caught up. Snapshots carry the newest WORLD number for this (header is 4 bytes longer). Protocol version 3.
Acceptance
A connected client's world state hash matches the server's after a scripted match: test/server/test_world_replication.gd plays seed 2 to results (12,198 ticks, 2 people and 22 bots) with a ClientGame attached, and compares NetWorld.world_hash() on both ends every 150 ticks and at the end. The match had 4 pieces built and removed, 2 props destroyed, 9 chests opened, 121 WORLD messages, 2.3 KB in all.
Rejected optimistic placements roll back cleanly: in that match the client places two walls ahead of the server (kept) and a floor the server can't afford (taken back). test/net/test_world_sync.gd covers a refusal, a command that never arrives, and losing a race for a slot, checking the solids and the hash afterwards.
The UDP test in test_client_game.gd now also checks the world arrives over ENet's reliable channel.
Tested: make check passes, 443 tests, self-check and smoke. make match still replays to the same hash. All headless; nothing here has been seen or felt by a person.
Not done, and where it goes
The client doesn't run the flood, so it only knows the water in the nine cells around its player (N3's own block). Drawing flooded basins further off needs it: for N10 (#77).
The whole-match hash test carries packets by hand with no delay. Delay and loss on the reliable channel are ENet's to handle and are only exercised by the short UDP test; the 24-client soak is N8 (#39).
The client's guess at the build cooldown is its own last placement only. A swap or a swing just before building is refused by the server and rolled back.
A lift onto a low piece isn't replayed if the server corrects an earlier tick, so that case shows as a small correction.
Bots don't build (M6 deferred), so WORLD traffic in a match of people building hasn't been measured.
— tidewall-build
Done in 6b21e9d.
**What changed**
- `NetWorld` (`src/net/`): two reliable messages on channel 0. WORLD carries new, damaged and removed pieces, props' health, opened chests and the tide's schedule. OWN tells each player what they carry (selection, materials, slots, ammunition).
- `WorldSender`: one WORLD message after each tick in which something changed, the same for everyone; the whole state in one message for someone joining, and for everyone when a new match's simulation appears. `StructureSet.changed` and `PropSet.changed` are new lists the simulation keeps for it, so nothing is scanned per tick.
- `ClientWorld`: applies them to the client's world, so pieces and broken props are solid for prediction. The client rolls chests and crate contents itself from the seed. A piece's health isn't sent: it follows from its building and damage.
- Optimistic placement: a provisional piece goes up with the command and its cost is held back. The server's piece replaces it, or it is taken back once a snapshot from after that tick has arrived and the world messages are caught up. Snapshots carry the newest WORLD number for this (header is 4 bytes longer). Protocol version 3.
**Acceptance**
- *A connected client's world state hash matches the server's after a scripted match*: `test/server/test_world_replication.gd` plays seed 2 to results (12,198 ticks, 2 people and 22 bots) with a `ClientGame` attached, and compares `NetWorld.world_hash()` on both ends every 150 ticks and at the end. The match had 4 pieces built and removed, 2 props destroyed, 9 chests opened, 121 WORLD messages, 2.3 KB in all.
- *Rejected optimistic placements roll back cleanly*: in that match the client places two walls ahead of the server (kept) and a floor the server can't afford (taken back). `test/net/test_world_sync.gd` covers a refusal, a command that never arrives, and losing a race for a slot, checking the solids and the hash afterwards.
- The UDP test in `test_client_game.gd` now also checks the world arrives over ENet's reliable channel.
**Tested**: `make check` passes, 443 tests, self-check and smoke. `make match` still replays to the same hash. All headless; nothing here has been seen or felt by a person.
**Not done, and where it goes**
- The client doesn't run the flood, so it only knows the water in the nine cells around its player (N3's own block). Drawing flooded basins further off needs it: for N10 (#77).
- The whole-match hash test carries packets by hand with no delay. Delay and loss on the reliable channel are ENet's to handle and are only exercised by the short UDP test; the 24-client soak is N8 (#39).
- The client's guess at the build cooldown is its own last placement only. A swap or a swing just before building is refused by the server and rolled back.
- A lift onto a low piece isn't replayed if the server corrects an earlier tick, so that case shows as a small correction.
- Bots don't build (M6 deferred), so WORLD traffic in a match of people building hasn't been measured.
— tidewall-build
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Depends on: N2, B3, M2, B9
Replicate structures, destroyed props, sea level, loot and inventory, including optimistic build placement on the client and a full state catch-up for mid-match joiners or spectators.
Acceptance
Done in
6b21e9d.What changed
NetWorld(src/net/): two reliable messages on channel 0. WORLD carries new, damaged and removed pieces, props' health, opened chests and the tide's schedule. OWN tells each player what they carry (selection, materials, slots, ammunition).WorldSender: one WORLD message after each tick in which something changed, the same for everyone; the whole state in one message for someone joining, and for everyone when a new match's simulation appears.StructureSet.changedandPropSet.changedare new lists the simulation keeps for it, so nothing is scanned per tick.ClientWorld: applies them to the client's world, so pieces and broken props are solid for prediction. The client rolls chests and crate contents itself from the seed. A piece's health isn't sent: it follows from its building and damage.Acceptance
test/server/test_world_replication.gdplays seed 2 to results (12,198 ticks, 2 people and 22 bots) with aClientGameattached, and comparesNetWorld.world_hash()on both ends every 150 ticks and at the end. The match had 4 pieces built and removed, 2 props destroyed, 9 chests opened, 121 WORLD messages, 2.3 KB in all.test/net/test_world_sync.gdcovers a refusal, a command that never arrives, and losing a race for a slot, checking the solids and the hash afterwards.test_client_game.gdnow also checks the world arrives over ENet's reliable channel.Tested:
make checkpasses, 443 tests, self-check and smoke.make matchstill replays to the same hash. All headless; nothing here has been seen or felt by a person.Not done, and where it goes
— tidewall-build