fix(client): address PR #4 round 2 review feedback
- decode_snapshot() reports dropped entities via push_error and returns decode_errors count so callers can detect partial data (D-010 information boundary compliance) - receive_bytes() warns when overwriting unconsumed snapshot, documents latest-wins semantics - Rename misleading test to test_encode_produces_nonempty_bytes - Fix tick rate comment: 10 ticks/game-minute per D-031 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -26,17 +26,25 @@ static func decode_snapshot(bytes: PackedByteArray) -> Variant:
|
||||
return null
|
||||
|
||||
var entities: Array[Dictionary] = []
|
||||
for raw_entity in raw["entities"]:
|
||||
var raw_entities: Array = raw["entities"]
|
||||
var dropped := 0
|
||||
for raw_entity in raw_entities:
|
||||
var entity = _decode_entity(raw_entity)
|
||||
if entity != null:
|
||||
entities.append(entity)
|
||||
else:
|
||||
dropped += 1
|
||||
|
||||
if dropped > 0:
|
||||
push_error("Protocol: %d/%d entities failed to decode (D-010 information boundary violation)" % [dropped, raw_entities.size()])
|
||||
|
||||
# GDScript int is signed 64-bit. Rust tick is u64 but will not exceed 2^63
|
||||
# in any realistic scenario (would require ~29 billion years at 10 ticks/min).
|
||||
# in any realistic scenario (would require ~29 billion years at 10 ticks/game-minute per D-031).
|
||||
var tick: int = raw["tick"]
|
||||
return {
|
||||
"tick": tick,
|
||||
"entities": entities,
|
||||
"decode_errors": dropped,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user