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:
@@ -45,6 +45,9 @@ var health: PackedInt32Array = PackedInt32Array()
|
||||
var solid_ids: PackedInt32Array = PackedInt32Array()
|
||||
## Prop IDs in the order they were destroyed, for views to catch up on.
|
||||
var destroyed: PackedInt32Array = PackedInt32Array()
|
||||
## Props damaged since whoever sends them to clients last cleared this. A set: the
|
||||
## values mean nothing. Not match state.
|
||||
var changed: Dictionary = {}
|
||||
|
||||
var _ground: SimGround
|
||||
## SimGround solid ID -> prop ID, for props whose box is in `_ground`.
|
||||
@@ -105,6 +108,7 @@ func damage(prop: int, amount: int) -> bool:
|
||||
if prop < 0 or prop >= count() or not is_standing(prop) or amount <= 0:
|
||||
return false
|
||||
health[prop] = maxi(health[prop] - amount, 0)
|
||||
changed[prop] = true
|
||||
if health[prop] > 0:
|
||||
return false
|
||||
destroyed.append(prop)
|
||||
|
||||
Reference in New Issue
Block a user