Tracking what is happening.
WHAT STATE EXISTS
- World state: what is where
- Player state: position, health, inventory, progress
- Session state: current level, score, time
- Persistent state: saves, settings, unlocks
WHAT TO KEEP SEPARATE
Persistent from transient.
WHY
Only one needs saving, and mixing them complicates both.
WHAT A SAVE SYSTEM MUST DO
Capture enough to restore the situation Write reliably, without corruption on interruption Load into a valid state Handle saves from earlier versions
WHY THAT LAST POINT MATTERS
Players update mid-playthrough, and a broken save loses their progress permanently.
WHAT TO IMPLEMENT
A version number in every save Migration for older versions Validation on load, with a clear failure rather than a crash
WHAT TO WRITE SAFELY
To a temporary file, then replace atomically.
WHY
Interrupted writes otherwise destroy the existing save.
WHAT TO AVOID SAVING
Anything derivable Object references that will not survive reloading
WHAT TO TEST
Saving and loading at every point Loading a save from the previous release
WHAT TO PROVIDE
Several save slots, and automatic saves.