Repository navigation
v0.3.1 — characters are saved, and cannot roll back
A play-tester reported that their character kept rolling back to an older save. It was worse
than that: no deployed game server was writing saves at all, so the "older save" was the only
save that had ever existed. Every character on the realm read charver=1 — created, and never
written since.
Three servers, three different ways of not saving. The Mac-image server cleared the engine's
own -nosave flag and never replaced it. The pre-1.14 host answered fpSaveDatabaseCharacter
with a stack-balancing stub. Only the wine-injected 1.14d DLL implemented the slot, and that
one filed saves under the wrong key whenever its 16-slot join ring had recycled the player.
What this release changes:
- The store refuses to go backwards. Rather than asking every path above it to be
careful,realmd:charveris a compare-and-set token: a load hands back the bytes and the
version they were at, and a save is accepted only while the store is still at that
version. Compare, set and increment are a single Lua script, so there is no window
between them. Version zero is accepted whatever the caller expected, because that means
redis lost its state and was refilled from Postgres — where a live session's bytes are
the newest thing in existence. A refused save is never retried; it is obsolete by
definition. - Character names are claimed realm-wide. They were unique only within an account,
while the seat tables, the retry queue, a departing player's seat release and the Mac
engine's own<charname>.d2sall key on the name alone. Two accounts with a "Bob" was
never a rollback — it was a character swap. The claim is a table rather than a unique
index, so it cannot fail at startup on data that already holds duplicates, and characters
that predate it are covered by a check againstcharsitself. - Saving is continuous. 1.14d's interval drops from 8192 game frames (~5.5 minutes) to
512 (~20 seconds) by patching two immediates inUpdateClients. The pre-1.14 engines
locate the same site by its constant rather than its address —0x80001fffis the
signed-modulo-8192 idiom and nothing else in the image holds that number. Exactly one
match is required, so an engine that does not match is refused rather than guessed at.
All ten shippedD2Game.dllfiles have exactly one, in both encodings, with the fixup at
+7. - Three smaller ways to lose a character, closed. Deleting a character that was in a
game, where the server still held it and wrote it back afterwards. Releasing a seat by
matching a name suffix over an unorderedSMEMBERS, which could free a lock belonging to
somebody still playing. And a save-retry queue that carried no fence and had no age
bound. - One seat table instead of three. The join seat table moves to
packages/gs-seatsand
is shared by all three servers, which previously had one table, another table, and none.
Verified on the real engines under wine: the interval patch applies on all six, a client
reaches a world on 1.14d and its charver climbs 1 → 2 → 3, a save replayed at a superseded
version is refused with the character left intact, and all seven engines still reach a world
in CI.
Upgrading
Nothing to run by hand — the charnames table is created on startup and existing characters
keep their names. From this release a second account can no longer take a name that is already
in use on the realm.
charver is the signal that this is working. It should start climbing for anyone playing; if
every character still reads 1, the save path is not running:
redis-cli GET realmd:charver:<account>/<character>