The roster sent to clients now contains living characters only. Retirement stays server-side bookkeeping for archival; from the player's side a dead character is simply gone, and listing it offers a choice that cannot be taken. The XP bar only moved on a level-up or a character swap because it read the character roster, which is re-sent only when the SET of characters changes. Experience now rides the snapshot -- four bytes on a message already going out at 20Hz -- and the server mirrors each grant into the world immediately rather than only when a level is crossed. The create field starts with a suggested name instead of blank, and offers another after each creation. Two bugs found while testing, both mine: The first was a bad patch of my own: a change meant for the snapshot decoder also matched inside decode_characters, which then read a four-byte field its encoder never wrote and ran off the end of every packet. This is precisely the "encodes but decodes wrong" failure the codec tests exist to catch, and it was caught within a minute of the test being written. Chasing that exposed a real robustness gap: StreamPeerBuffer.get_utf8_string() pushes an engine error and returns garbage when the buffer is short, so a truncated or hostile character/roster packet produced error spam instead of degrading. Both decoders now bounds-check every field, with tests that slice each packet at many lengths and assert it degrades rather than inventing entries -- the same guarantee the input decoder already had. 206 tests. check.sh, test.sh, smoke.sh and both diagnostics pass.
This commit is contained in:
@@ -82,6 +82,10 @@ func _physics_process(_delta: float) -> void:
|
||||
_srv._dispatch_events(inst)
|
||||
var after: int = _srv.store.get_character(_account, _character.id).total_xp
|
||||
_check(after > before, "killing an enemy awards experience (%d -> %d)" % [before, after])
|
||||
# Mirrored into the world immediately, which is what lets the bar move
|
||||
# per kill instead of waiting for the next roster message.
|
||||
var mine: SimPlayer = inst.world.players[Net.LOCAL_PEER]
|
||||
_check(mine.total_xp == after, "the experience reaches the world at once")
|
||||
|
||||
elif _step == 80:
|
||||
# Enough experience to cross a level boundary, and check health follows.
|
||||
@@ -132,6 +136,17 @@ func _physics_process(_delta: float) -> void:
|
||||
_check(_srv.store.active_characters(_account).is_empty(),
|
||||
"no living characters remain")
|
||||
|
||||
elif _step == 110:
|
||||
# The roster the client actually holds must contain no dead character:
|
||||
# retirement is server-side bookkeeping, and from the player's side a
|
||||
# dead character is simply gone.
|
||||
var shown := 0
|
||||
for c in Net.client.characters:
|
||||
shown += 1
|
||||
_check(shown == 0, "the dead character is not offered to the client")
|
||||
_check(_srv.store.characters_for(_account).size() == 1,
|
||||
"but the server still holds the record")
|
||||
|
||||
elif _step == 120:
|
||||
# With nothing alive, the player must be left with no character rather
|
||||
# than silently resurrected into the dead one.
|
||||
|
||||
Reference in New Issue
Block a user