Merge pull request #993 from MaxTomahawk/feat/checkpoint-restore-event

feat(mods): signal verified checkpoint restores
This commit is contained in:
bryanthaboi
2026-08-10 14:31:45 -04:00
committed by GitHub
5 changed files with 402 additions and 10 deletions
+10 -1
View File
@@ -6,6 +6,7 @@ local SaveData = require("src.core.SaveData")
local Version = require("src.core.Version")
local BattleState = require("src.battle.BattleState")
local BattleCheckpoint = require("src.core.BattleCheckpoint")
local ModRuntime = require("src.mods.Runtime")
local Checkpoint = {}
@@ -398,7 +399,15 @@ function Checkpoint.restore(game, checkpoint)
if ok then
local restored, verifyCode = Checkpoint.capture(game)
if restored and validated.rng == nil then restored.rng = nil end
if restored and equalData(restored, validated) then return true end
if restored and equalData(restored, validated) then
if ModRuntime.wants("checkpoint.restored") then
ModRuntime.emit("checkpoint.restored", {
game = game,
kind = validated.kind,
})
end
return true
end
err = restored and ("restored state differed at "
.. tostring(firstDifference(validated, restored) or "canonical encoding"))
or ("restored state could not be captured: " .. tostring(verifyCode))