CleverRaven/Cataclysm-DDA — pull request #9325 by BevapDin (2014-09-29 18:37:26+00:00)
Title: Fixes some of the move-to-graveyard code

Fixes #9322

Problem fixed: graveyard was created with permissions 0777 - who does this?

Problem fixed: current working directory was changed (`chdir`), but not reverted correctly: it only changes back to the parent directory (`chdir("..")`), which works fine without USE_HOME_DIR, because the savedir is "save/", changing back to "save/.." is the main folder again. With USE_HOME_DIR, savedir is "$HOME/.cataclysm/save", and the main folder is most likely *not* "$HOME/.cataclysm/save/..". Upon starting a new world, all the json data has been loaded, but of course not found as the game looked in "$HOME/.cataclysm/data/". This leads to those debug messages and finally to the crash because `profession::weighted_random` simply assumes there is at least one profession. No profession has been loaded, so it fails as reported in #9322.

Problem fixed: the move-to-graveyard code looked for files in the savedir ("save/"), not in the world folder ("save//").

Problem fixed: the code compared the base64 encoded player name to the files in the save dir, but this leads to false positive if one base64 encoded player name is a prefix of another base64 encoded player name - code looks for everything starting with "abc", but also finds stuff starting with "abcdef", it should look for stuff starting with "abc." - the dot terminates the player name specific part.

Problem fixed: the graveyard was somehow pointless: upon death the game deletes the player save files (see `game::is_game_over`) which would have been moved to the graveyard. But they are already delete, so the move-to-graveyard code does nothing. This is fixed, the games saves right before the moving to the graveyard (or if that fails, it simply deletes the player files).

----

Also: isn't it time to get rid of the weather file (move it's content into the master save file), the current data is small enough for this. Also, weather should not be player specific, which it currently is. It should be world specific.