LambdaHack-0.2.6: A roguelike game engine in early and active development

Safe HaskellNone



Saving and restoring games and player diaries.



saveGameFile :: State -> IO ()Source

Save a simple serialized version of the current state. Protected by a lock to avoid corrupting the file.

restoreGame :: (FilePath -> IO FilePath) -> CP -> String -> IO (Either (State, Diary, Msg) (Diary, Msg))Source

Restore a saved game, if it exists. Initialize directory structure, if needed.

rmBkpSaveDiary :: CP -> Diary -> IO ()Source

Remove the backup of the savegame and save the player diary. Should be called before any non-error exit from the game. Sometimes the backup file does not exist and it's OK. We don't bother reporting any other removal exceptions, either, because the backup file is relatively unimportant. We wait on the mvar, because saving the diary at game shutdown is important.

saveGameBkp :: State -> Diary -> IO ()Source

Save the diary and a backup of the save game file, in case of crashes. This is only a backup, so no problem is the game is shut down before saving finishes, so we don't wait on the mvar. However, if a previous save is already in progress, we skip this save.