mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-12 08:21:02 +02:00
fix(mods): keep title resume independent
This commit is contained in:
@@ -433,12 +433,6 @@ local function isTitleSession(game)
|
||||
return false
|
||||
end
|
||||
|
||||
local function emitRestored(game, checkpoint)
|
||||
if ModRuntime.wants("checkpoint.restored") then
|
||||
ModRuntime.emit("checkpoint.restored", { game = game, kind = checkpoint.kind })
|
||||
end
|
||||
end
|
||||
|
||||
local function rebuildTitle(game, savedTitle, rng)
|
||||
local save, err = dataCopy(savedTitle)
|
||||
if not save then error("title rollback decode failed: " .. tostring(err), 0) end
|
||||
@@ -485,7 +479,6 @@ function Checkpoint.resume(game, checkpoint)
|
||||
local restored, verifyCode = Checkpoint.capture(game)
|
||||
if restored and validated.rng == nil then restored.rng = nil end
|
||||
if restored and equalData(restored, validated) then
|
||||
emitRestored(game, validated)
|
||||
return true
|
||||
end
|
||||
err = restored and ("resumed state differed at "
|
||||
|
||||
@@ -60,10 +60,6 @@ local files = {
|
||||
return function(mod)
|
||||
_G.MOD_TITLE_STORAGE = mod.storage
|
||||
_G.MOD_TITLE_CHECKPOINTS = mod.checkpoints
|
||||
_G.MOD_TITLE_RESTORE_COUNT = 0
|
||||
mod.events:on("checkpoint.restored", function()
|
||||
_G.MOD_TITLE_RESTORE_COUNT = _G.MOD_TITLE_RESTORE_COUNT + 1
|
||||
end)
|
||||
end
|
||||
]],
|
||||
}
|
||||
@@ -198,13 +194,10 @@ if type(storage) == "table" then
|
||||
"title bootstrap never creates a normal Pokémon save as a side effect")
|
||||
T.same(checkpoints:capture(titleRuntime), checkpoint,
|
||||
"bootstrapped overworld differentially recaptures the selected checkpoint")
|
||||
T.eq(_G.MOD_TITLE_RESTORE_COUNT, 1,
|
||||
"a successful title bootstrap emits checkpoint.restored exactly once")
|
||||
|
||||
-- Force a failure after restoreCheckpointSave has already installed the
|
||||
-- checkpoint's canonical save and overworld. Title has no live checkpoint
|
||||
-- rollback, so it must rebuild a clean title session and must not publish
|
||||
-- the success-only lifecycle event.
|
||||
-- rollback, so it must rebuild a clean title session.
|
||||
SaveData.resetSlotState()
|
||||
local failingTitle = makeRuntime(SaveData.newGame({ version = "red" }), true)
|
||||
failingTitle.save.options = { volume = 7, bindings = {} }
|
||||
@@ -222,8 +215,6 @@ if type(storage) == "table" then
|
||||
"failed title reconstruction restores the unbound title skeleton")
|
||||
T.eq(failingTitle.save.options.volume, 7,
|
||||
"failed title reconstruction retains current title options")
|
||||
T.eq(_G.MOD_TITLE_RESTORE_COUNT, 1,
|
||||
"failed title reconstruction never emits checkpoint.restored")
|
||||
T.check(files["save.lua"] == nil,
|
||||
"failed title reconstruction never writes a normal Pokémon save")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user