Hide dead characters, suggest names, make the XP bar live
ci / verify (push) Successful in 46s

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:
2026-09-04 01:12:53 +02:00
parent 7ef972e3b3
commit d8197885ca
12 changed files with 214 additions and 33 deletions
+22
View File
@@ -25,6 +25,28 @@ var created_unix: int = 0
var died_unix: int = 0
## Suggested names, offered when creating a character so the field is never
## blank. Deliberately a pair of short word lists rather than a big table: the
## point is a usable default the player can overwrite, not a naming system.
const NAME_FIRST: PackedStringArray = [
"Ash", "Bram", "Cass", "Dorn", "Elm", "Fen", "Gale", "Hale", "Iva", "Jory",
"Kit", "Lark", "Mox", "Nell", "Orin", "Pike", "Quill", "Ren", "Sable", "Thorn",
"Vesper", "Wren", "Yarrow", "Zel",
]
const NAME_LAST: PackedStringArray = [
"blade", "briar", "creek", "dusk", "ember", "fell", "grim", "hollow",
"iron", "kettle", "moor", "night", "quarry", "rook", "shade", "thistle",
"vale", "wick",
]
static func random_name(rng: RandomNumberGenerator) -> String:
return "%s%s" % [
NAME_FIRST[rng.randi() % NAME_FIRST.size()],
NAME_LAST[rng.randi() % NAME_LAST.size()],
]
static func create(character_name: String, rng: RandomNumberGenerator) -> Character:
var c := Character.new()
# Random-but-readable: full saturation and high value, so two characters are