mirror of
https://github.com/bryanthaboi/gen1recomp
synced 2026-09-30 23:37:23 -04:00
5920402de4
A cart's saves are keyed by cart id, not by version. SaveData resolves every path through activeScopeKey, which answers cart_<id> while one is active, and the launcher lists, creates and selects a cart's slots from the cartSlots registry (RomImporter._refreshSlots / _selectSlot / _newSlot). src/core/gen2/Save.lua asked in the version's name alone. saveNames built saves/<version>/<slot>.lua or save_<suffix>.lua from the version in both branches and never consulted the active cart, so a cart on Gold, Silver or Crystal read and wrote the BASE GAME's playthrough. Gen 1 was unaffected because it saves through SaveData itself, which is already cart-scoped -- so this only showed on a Gen 2 cart. It was worse than sharing one file. Save.save opens by asking activeSlot(version) and, on nil, calling createSlot + setActiveSlot in the version's name, so the first save inside a cart registered a slot in the base game's registry and made it active: the cart's playthrough appeared in the launcher's list for the base version, and the player's own save there was what the cart then overwrote. Both sites now resolve the cart scope the way SaveData does, and the names they build are SaveData's own -- slotDir's saves/cart_<id>/ and legacyNames' save_cart_<id>.lua -- so the in-game save layer and the launcher land on one file again. tests/gen2_save_test.lua covers the cart's flat name, its slot name, the slot going into the cart's registry rather than the base game's, the cart's scope winning over a base slot, and the base game keeping its own once the cart is cleared. Four of them fail on the unpatched module. Reported as "when I select Wild Crystal to launch it loads my save from regular Crystal". Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>