core: make save_data/restore_data public for filesystem-less saves

Save slots aren't always files. The MRP3GI browser build hands a SaveData
straight to localStorage instead of saves/<slot>.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 <noreply@anthropic.com>
This commit is contained in:
m3ultra 2026-07-26 00:39:19 +10:00
parent 662e6c4bc4
commit f2b603a812

View File

@ -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<Event> {
/// 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<Event> {
self.inventory = d.inventory.clone();
self.taken = d.taken.clone();
self.scored = d.scored.clone();