From 9ff63977237ba7d7edb7f863c9a6ad4dd5b07cbe Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 5 Sep 2011 21:57:23 +0000 Subject: Refactor savegamedir calculation code to work the same as trunk. Subversion-branch: /branches/raven-branch Subversion-revision: 2360 --- src/doom/d_main.c | 57 +++++++++++++++++++++---------------------------------- 1 file changed, 22 insertions(+), 35 deletions(-) (limited to 'src/doom') diff --git a/src/doom/d_main.c b/src/doom/d_main.c index f626d408..0e5324b4 100644 --- a/src/doom/d_main.c +++ b/src/doom/d_main.c @@ -786,40 +786,6 @@ void D_SetGameDescription(void) } } -static void SetSaveGameDir(char *iwad_filename) -{ - char *sep; - char *basefile; - - // Extract the base filename - - sep = strrchr(iwad_filename, DIR_SEPARATOR); - - if (sep == NULL) - { - basefile = iwad_filename; - } - else - { - basefile = sep + 1; - } - - // ~/.chocolate-doom/savegames/ - - savegamedir = Z_Malloc(strlen(configdir) + 30, PU_STATIC, 0); - sprintf(savegamedir, "%ssavegames%c", configdir, - DIR_SEPARATOR); - - M_MakeDirectory(savegamedir); - - // eg. ~/.chocolate-doom/savegames/doom2.wad/ - - sprintf(savegamedir + strlen(savegamedir), "%s%c", - basefile, DIR_SEPARATOR); - - M_MakeDirectory(savegamedir); -} - // Check if the IWAD file is the Chex Quest IWAD. // Returns true if this is chex.wad. @@ -1121,6 +1087,27 @@ static void LoadHacxDeh(void) } } +// Figure out what IWAD name to use for savegames. + +static char *SaveGameIWADName(void) +{ + // Chex quest hack + + if (gameversion == exe_chex) + { + return "chex.wad"; + } + + // Hacx hack + + if (gameversion == exe_hacx) + { + return "hacx.wad"; + } + + return D_SaveGameIWADName(gamemission); +} + // // D_DoomMain // @@ -1439,7 +1426,7 @@ void D_DoomMain (void) LoadChexDeh(); LoadHacxDeh(); D_SetGameDescription(); - SetSaveGameDir(iwadfile); + savegamedir = M_GetSaveGameDir(SaveGameIWADName()); // Check for -file in shareware if (modifiedgame) -- cgit v1.2.3