pub struct SaveStack { /* private fields */ }Expand description
The save/restore stack.
Implementations§
Source§impl SaveStack
impl SaveStack
Sourcepub fn save(&mut self, snapshot: SaveSnapshot) -> (u16, u32)
pub fn save(&mut self, snapshot: SaveSnapshot) -> (u16, u32)
Push a new save level. Returns (level, save_id).
Sourcepub fn add_record(&mut self, record: SaveRecord)
pub fn add_record(&mut self, record: SaveRecord)
Add a COW record to the current save level.
Sourcepub fn restore(&mut self) -> Option<SaveLevel>
pub fn restore(&mut self) -> Option<SaveLevel>
Pop the topmost save level, returning its records for restore processing.
Returns None if the stack is empty.
Sourcepub fn restore_to(&mut self, save_id: u32) -> Option<Vec<SaveLevel>>
pub fn restore_to(&mut self, save_id: u32) -> Option<Vec<SaveLevel>>
Pop all save levels from save_id upward (inclusive), returning them
in stack order (target level first, newest level last).
Per PLRM, restore can target any valid save — not just the topmost.
All newer saves are invalidated and their COW records are also returned
so they can be undone.
Sourcepub fn current_level(&self) -> u16
pub fn current_level(&self) -> u16
Current save level (0 if no save active).
Sourcepub fn last_save_id(&self) -> u32
pub fn last_save_id(&self) -> u32
Save ID of the most recent save (0 if no save active). Used for entity creation tracking (invalidrestore).
Sourcepub fn is_valid(&self, save_id: u32) -> bool
pub fn is_valid(&self, save_id: u32) -> bool
Check if a save_id is valid (exists and not invalidated).
Sourcepub fn levels_ref(&self) -> &[SaveLevel]
pub fn levels_ref(&self) -> &[SaveLevel]
Read-only access to the levels (for validation checks).
Sourcepub fn invalidate_newer(&mut self, save_id: u32)
pub fn invalidate_newer(&mut self, save_id: u32)
Invalidate all save levels newer than the given save_id.