N5: Replicate building, world damage, tide and loot
Built pieces, props' health, opened chests and the tide's schedule now reach clients as WORLD messages on the reliable channel, and each player is told what they carry as OWN messages. - NetWorld: the WORLD and OWN wire formats, and world_hash(), a digest of everything replicated this way. - WorldSender: one message after each tick in which something changed, the same for everyone, and the whole state for someone joining or a new match. StructureSet and PropSet keep the change lists it reads. - ClientWorld: applies them to the client's world, so pieces and broken props are solid for prediction. A piece's health follows from its building and damage, so building costs nothing on the wire. - Placing ahead of the server: a provisional piece goes up with the command and is replaced by the server's, or taken back once a snapshot shows the server had its chance. Snapshots carry the newest WORLD number for that. - Protocol version 3. A test plays a whole scripted match on a real island with a ClientGame attached and compares the two worlds' hashes throughout. Closes #36 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -52,6 +52,17 @@ func test_a_client_joins_over_udp_generates_the_island_and_plays() -> void:
|
||||
if client.playing():
|
||||
played += 1
|
||||
OS.delay_msec(1)
|
||||
# Let the last reliable messages arrive, then compare the two worlds.
|
||||
for _wait: int in 20:
|
||||
game.poll()
|
||||
client.poll()
|
||||
OS.delay_msec(1)
|
||||
client.replica.sync(loop.sim.tick)
|
||||
assert_true(client.replica.applied >= 2, "the whole state on joining, then the match starting: %d WORLD messages" % client.replica.applied)
|
||||
assert_eq(client.replica.seq, game.world.seq)
|
||||
assert_eq(NetWorld.world_hash(client.world), NetWorld.world_hash(loop.sim), "the world arrived on the reliable channel")
|
||||
assert_not_null(client.world.tide)
|
||||
assert_false(client.replica.own.is_empty(), "and what the player carries")
|
||||
link.leave()
|
||||
assert_eq(played, 150, "the client got into the match and played")
|
||||
var flow: Match = loop.match_flow
|
||||
|
||||
Reference in New Issue
Block a user