Skip to content

Keep out-of-date saves instead of deleting them - #63

Merged
Critlist merged 1 commit into
masterfrom
fix/keep-outdated-saves
Nov 11, 2026
Merged

Critlist merged 1 commit into
masterfrom
fix/keep-outdated-saves

Conversation

@Critlist

Copy link
Copy Markdown
Owner

Updating the game silently destroyed in-progress saves. At startup the original uptodate() check finds the save older than the new binary, prints "Saved level is out of date." and the save is unlink()ed. Every AUR upgrade or rebuild did this.

This is the safety net while save format v3 (saves that survive updates) is worked on: from now on no save is ever deleted.

What changes

  • An out-of-date save is renamed to save/<uid><name>.outdated (then .outdated.1, .2, … up to 999; an existing file is never clobbered, and any doubt about whether a name exists means the file is left alone). The player is told: "Your saved game is from an older version and can't be restored yet." / "It was kept as save/….outdated."
  • If the rename fails, the save is left untouched and the player is told. The new game then refuses to save over it ("Not saved; it would overwrite …"). If the player moves the file or fixes permissions, the next save retries the move and goes through. A refused save leaves the signal handlers in place.
  • Fixes the original fd leak on this path. The original condition is kept in an /* Original 1984: */ comment, and the new code carries MODERN ADDITION blocks.
  • Browser build unchanged: uptodate() always passes there, so this path never runs (v3 covers the browser).
  • Bones (getbones(), the only other uptodate() caller) unchanged: those are not player saves.

Verified

  • gcc Debug and clang Release: zero warnings; smoke, verify-map and qwertz pass.
  • Normal restore unchanged.
  • Outdated save: renamed, byte-identical (cmp), message shown, and the new game later saves normally.
  • Name collision: .outdated.1 created, earlier .outdated untouched.
  • Rename impossible (chmod a-w save/): no crash, original byte-identical in place, save refused. After fixing permissions mid-game, the next S moves the old save to .outdated.2 and saves.
  • Master, same setup: the save is deleted.

🤖 Generated with Claude Code

At start-up an existing save older than the hack binary was unlink()ed
and a new game started, so every update of the game silently destroyed
the player's saved game.

The save is now renamed to save/<uid><name>.outdated (or .outdated.1,
.2, ... if that name is taken; an existing file is never replaced) and
the player is told where it was kept. If the rename fails the file is
left alone, the player is told, and the new game refuses to save over
it (dosave0() retries the move first, so the game can still be saved
once the problem is fixed).

Such saves are still not restored: that needs the pointer-free save
format. Bones files are unchanged (they are not player saves).
@Critlist
Critlist merged commit 408b636 into master Nov 11, 2026
7 checks passed
neuhaus pushed a commit to neuhaus/restoHack that referenced this pull request Nov 15, 2026
Keep out-of-date saves instead of deleting them
Critlist added a commit that referenced this pull request Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant