From f2b603a812364a4c7da36ffe7a6d9c91b6d8ff65 Mon Sep 17 00:00:00 2001 From: m3ultra Date: Sun, 26 Jul 2026 00:39:19 +1000 Subject: [PATCH] core: make save_data/restore_data public for filesystem-less saves MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Save slots aren't always files. The MRP3GI browser build hands a SaveData straight to localStorage instead of saves/.json, so the two halves of the checkpoint machinery need to be reachable from outside the crate. Native behavior is unchanged — SaveGame/RestoreGame still go through the same two functions. Co-Authored-By: Claude Opus 5 --- mrpci-core/src/state.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mrpci-core/src/state.rs b/mrpci-core/src/state.rs index 8154da0..d34993c 100644 --- a/mrpci-core/src/state.rs +++ b/mrpci-core/src/state.rs @@ -726,7 +726,10 @@ impl GameState { ev } - fn save_data(&self) -> SaveData { + /// The whole restorable moment, in memory. Public because save slots + /// aren't always files: the browser build hands this straight to + /// localStorage instead of `saves/`. + pub fn save_data(&self) -> SaveData { SaveData { room: self.world.current, ego: (self.ego.x, self.ego.y), @@ -743,7 +746,9 @@ impl GameState { } } - fn restore_data(&mut self, d: SaveData) -> Vec { + /// Restore a moment produced by [`GameState::save_data`] — the same path + /// death and `RestoreGame` take, minus the filesystem. + pub fn restore_data(&mut self, d: SaveData) -> Vec { self.inventory = d.inventory.clone(); self.taken = d.taken.clone(); self.scored = d.scored.clone();