Skip to main content

load_handler

Function load_handler 

Source
pub fn load_handler(
    world: &mut AmbleWorld,
    view: &mut View,
    gamefile: &str,
) -> bool
Expand description

Loads a previously saved game state from disk.

This handler attempts to restore a complete game session from a save file, including all world state, player progress, and game configuration. The system handles version compatibility and provides appropriate feedback for various failure conditions.

§Parameters

  • world - Mutable reference to replace with loaded game state
  • view - Mutable reference to display load results and feedback
  • gamefile - Name of the save slot to load (without path or extension)

§Save File Location

Files are loaded from: saved_games/<world>/{gamefile}-amble-{version}.ron

§Version Compatibility

  • Save files include version metadata for compatibility checking
  • Mismatched versions generate warnings but attempt to load anyway
  • Version conflicts are logged for debugging purposes
  • Players are informed of version mismatches with clear messaging

§Error Conditions

  • File not found: Save slot doesn’t exist or is inaccessible
  • Parse error: Save file is corrupted or from incompatible version
  • Version mismatch: Save file version differs from current game version

§Success Behavior

On successful load:

  • Complete world state is replaced with loaded data
  • Success message displayed with save file information
  • Load event is logged with file path details
  • Game continues from the loaded state

§Failure Behavior

On failure:

  • Appropriate error message displayed to player
  • Original world state remains unchanged
  • Error details logged for debugging
  • Game continues with current state