foxygit / doom Log in
commit 28445ff77a0cc82d29900a6e5867a0fa577f4275
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Tue Feb 14 20:32:21 2012 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Tue Feb 14 20:32:21 2012 +0000

    Fix save game directory behavior under Windows.

    Subversion-branch: /branches/v2-branch
    Subversion-revision: 2504
---
 src/strife/d_main.c  | 42 ++++--------------------------------------
 src/strife/m_saves.c |  5 +++++
 2 files changed, 9 insertions(+), 38 deletions(-)

diff --git a/src/strife/d_main.c b/src/strife/d_main.c
index d7f61016..34d3ad30 100644
--- a/src/strife/d_main.c
+++ b/src/strife/d_main.c
@@ -893,43 +893,6 @@ void D_SetGameDescription(void)
     gamedescription = GetGameName("Strife: Quest for the Sigil");
 }

-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);
-
-    // haleyjd 20110210: Create Strife hub save folders
-    M_CreateSaveDirs(savegamedir);
-}
-
 //      print title for every printed line
 char            title[128];

@@ -1706,7 +1669,10 @@ void D_DoomMain (void)
     D_IdentifyVersion();
     InitGameVersion();
     D_SetGameDescription();
-    SetSaveGameDir(iwadfile);
+    savegamedir = M_GetSaveGameDir("strife1.wad");
+
+    // haleyjd 20110210: Create Strife hub save folders
+    M_CreateSaveDirs(savegamedir);

     I_GraphicsCheckCommandLine();

diff --git a/src/strife/m_saves.c b/src/strife/m_saves.c
index 74717dbd..a4068c4f 100644
--- a/src/strife/m_saves.c
+++ b/src/strife/m_saves.c
@@ -430,6 +430,11 @@ char *M_SafeFilePath(const char *basepath, const char *newcomponent)
     int   newstrlen = 0;
     char *newstr = NULL;

+    if (!strcmp(basepath, ""))
+    {
+        basepath = ".";
+    }
+
     // Always throw in a slash. M_NormalizeSlashes will remove it in the case
     // that either basepath or newcomponent includes a redundant slash at the
     // end or beginning respectively.