Skip to content

Saves carry across content and format changes - #146

Merged
h0lybyte merged 1 commit into
mainfrom
fix/save-compat
Nov 14, 2026
Merged

h0lybyte merged 1 commit into
mainfrom
fix/save-compat

Conversation

@h0lybyte

Copy link
Copy Markdown
Owner

Old save slots keep loading as content and the save format change. See docs/saves.md.

What changed

  • Core/SaveFormat: a save is read in three steps: parse the JSON, migrate it (one step per version, Version is now 2), then reconcile it with today's content. SavePresenter reads and writes through it.
  • old_ids (old_skins on ShipStats): added to ItemDef, ShipUpgrade, Universe, ShipStats, CharacterClass and CharacterOrigin. A save that holds a renamed id gets the replacement.
  • Removed content:
    • an item is paid back at the value stored with it (pack items now save their value; the oldest saves already carried one);
    • a skin or universe falls back to the default;
    • an upgrade is dropped and levels are clamped;
    • an unknown job kind is dropped.
    • Each change is logged on load as [Save] slot N: ....
  • content/shipped_ids.json: a growing list of every id ever shipped. ln.py gen adds to it, and gen (and gen --check in CI) fails if a listed id no longer resolves. Renaming or removing content without an alias is caught before release.
  • Unreadable slot: its text is kept as ln.save.N.broken before a new run overwrites it.
  • SaveCompatTests check:
    • a 0.4.1 save and an oldest-format save load whole;
    • write then read gives the same save;
    • every shipped id resolves;
    • renames follow old_ids;
    • removed content falls back as above;
    • unreadable saves fail to load and newer-version saves still load.

Tested

  • ln.py tests: 83/83 pass. gen --check is up to date.
  • Renamed carbine in a scratch copy of the content (not committed). Without an alias, gen --check fails and names it. With old_ids it resolves.
  • Web build in headless Chrome:
    • Injected a v1 save holding a removed item (2 × 40 cr), a missing skin, an upgrade at level 9 and a removed upgrade. It loaded with +80 cr, the default skin, the upgrade clamped to level 4 and the removed one gone, and it re-saved as version 2.
    • Injected a corrupt slot. It showed as empty, the new character saved over it, and the original text was kept as .broken.

Saves now read through Core/SaveFormat: parse, migrate (one step per
version), then reconcile every content id with today's content.

- old_ids (old_skins for ships) on items, upgrades, universes, ships,
  classes and origins: a renamed id resolves to its replacement.
- A removed item is paid back at the value saved with it (pack items
  now keep their value); a removed skin or universe falls back to the
  default; upgrade levels clamp to what exists; an unknown job kind is
  dropped.
- content/shipped_ids.json lists every id ever shipped; ln.py gen (and
  gen --check in CI) fails if one stops resolving.
- An unreadable slot is kept as ln.save.N.broken before a new run is
  written over it.
- SaveCompatTests load 0.4.1 and older saves, check renames, removals,
  round trips and unreadable/newer saves.
- docs/saves.md: what to do when changing content or the save format.
@h0lybyte
h0lybyte merged commit 44dcf84 into main Nov 14, 2026
1 check passed
@h0lybyte
h0lybyte deleted the fix/save-compat branch November 14, 2026 01:03
@h0lybyte h0lybyte mentioned this pull request Nov 14, 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