mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-17 19:24:01 +02:00
fix(mods): emit restore lifecycle after title resume
This commit is contained in:
+13
-6
@@ -386,6 +386,8 @@ local function firstDifference(a, b, path)
|
||||
return nil
|
||||
end
|
||||
|
||||
local emitRestored
|
||||
|
||||
function Checkpoint.restore(game, checkpoint)
|
||||
local capability = Checkpoint.inspect(game)
|
||||
if not capability.canRestore then
|
||||
@@ -403,12 +405,7 @@ function Checkpoint.restore(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
|
||||
if ModRuntime.wants("checkpoint.restored") then
|
||||
ModRuntime.emit("checkpoint.restored", {
|
||||
game = game,
|
||||
kind = validated.kind,
|
||||
})
|
||||
end
|
||||
emitRestored(game, validated)
|
||||
return true
|
||||
end
|
||||
err = restored and ("restored state differed at "
|
||||
@@ -424,6 +421,15 @@ function Checkpoint.restore(game, checkpoint)
|
||||
return false, "restore_failed", "Checkpoint restoration failed: " .. tostring(err)
|
||||
end
|
||||
|
||||
emitRestored = function(game, checkpoint)
|
||||
if ModRuntime.wants("checkpoint.restored") then
|
||||
ModRuntime.emit("checkpoint.restored", {
|
||||
game = game,
|
||||
kind = checkpoint.kind,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
local function isTitleSession(game)
|
||||
local states = game and game.stack and game.stack.states
|
||||
if type(states) ~= "table" then return false end
|
||||
@@ -479,6 +485,7 @@ 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 "
|
||||
|
||||
Reference in New Issue
Block a user