Saving and restoring games and player diaries.
Save a simple serialized version of the current state. Protected by a lock to avoid corrupting the file.
Restore a saved game, if it exists. Initialize directory structure, if needed.
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.
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.