mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-20 12:40:21 +02:00
Merge pull request #1495 from mleo2003/fix/fresh-skeleton-playthrough-id
SaveData: a fresh skeleton must not overwrite an existing playthrough binding
This commit is contained in:
+18
-5
@@ -1279,13 +1279,26 @@ function SaveData.ensurePlaythroughId(save, injectedFs)
|
|||||||
local isFresh = save == freshPlaythrough
|
local isFresh = save == freshPlaythrough
|
||||||
if isFresh then freshPlaythrough = nil end
|
if isFresh then freshPlaythrough = nil end
|
||||||
local byVersion = opts.playthroughIds and opts.playthroughIds[version]
|
local byVersion = opts.playthroughIds and opts.playthroughIds[version]
|
||||||
id = not isFresh and byVersion and byVersion[scope] or nil
|
local existing = byVersion and byVersion[scope]
|
||||||
|
id = not isFresh and existing or nil
|
||||||
if type(id) ~= "string" or id == "" then
|
if type(id) ~= "string" or id == "" then
|
||||||
id = SaveData.newPlaythroughId()
|
id = SaveData.newPlaythroughId()
|
||||||
opts.playthroughIds = opts.playthroughIds or {}
|
-- A fresh skeleton still gets its own id (two unsaved New Games sharing a
|
||||||
opts.playthroughIds[version] = opts.playthroughIds[version] or {}
|
-- slot must stay distinct), and it is still persisted when the slot has no
|
||||||
opts.playthroughIds[version][scope] = id
|
-- binding yet -- that is the contract a tool relies on to resolve
|
||||||
SaveData.saveOptions(opts, injectedFs)
|
-- `selected` at the title after a restart, before any normal SAVE.
|
||||||
|
--
|
||||||
|
-- What it must NOT do is OVERWRITE a binding that already exists. newGame()
|
||||||
|
-- marks a skeleton on the boot frame, before any save is loaded, and mods
|
||||||
|
-- initialise inside that window -- so a mod touching storage at init
|
||||||
|
-- replaced the real save's id with a throwaway, stranding that save's mod
|
||||||
|
-- storage and repeating on every launch.
|
||||||
|
if not (isFresh and type(existing) == "string" and existing ~= "") then
|
||||||
|
opts.playthroughIds = opts.playthroughIds or {}
|
||||||
|
opts.playthroughIds[version] = opts.playthroughIds[version] or {}
|
||||||
|
opts.playthroughIds[version][scope] = id
|
||||||
|
SaveData.saveOptions(opts, injectedFs)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
save.meta.playthroughId = id
|
save.meta.playthroughId = id
|
||||||
return id
|
return id
|
||||||
|
|||||||
Reference in New Issue
Block a user