shithub: choc

Download patch

ref: 211c7f396a34571a0f8a33dc8ba9f6573c9b4903
parent: 293b22549c00c996f3c88e00365c78a4ad980b64
author: mfrancis95 <[email protected]>
date: Sun Jul 5 08:21:28 EDT 2020

Add separate savegame directories for Freedoom (resolve #896)

--- a/src/d_iwad.c
+++ b/src/d_iwad.c
@@ -928,7 +928,7 @@
 // Get the IWAD name used for savegames.
 //
 
-const char *D_SaveGameIWADName(GameMission_t gamemission)
+const char *D_SaveGameIWADName(GameMission_t gamemission, GameVariant_t gamevariant)
 {
     size_t i;
 
@@ -938,6 +938,22 @@
     // Note that we match on gamemission rather than on IWAD name.
     // This ensures that doom1.wad and doom.wad saves are stored
     // in the same place.
+
+    if (gamevariant == freedoom)
+    {
+        if (gamemission == doom)
+        {
+            return "freedoom1.wad";
+        }
+        else if (gamemission == doom2)
+        {
+            return "freedoom2.wad";
+        }
+    }
+    else if (gamevariant == freedm && gamemission == doom2)
+    {
+        return "freedm.wad";
+    }
 
     for (i=0; i<arrlen(iwads); ++i)
     {
--- a/src/d_iwad.h
+++ b/src/d_iwad.h
@@ -44,7 +44,7 @@
 char *D_TryFindWADByName(const char *filename);
 char *D_FindIWAD(int mask, GameMission_t *mission);
 const iwad_t **D_FindAllIWADs(int mask);
-const char *D_SaveGameIWADName(GameMission_t gamemission);
+const char *D_SaveGameIWADName(GameMission_t gamemission, GameVariant_t gamevariant);
 const char *D_SuggestIWADName(GameMission_t mission, GameMode_t mode);
 const char *D_SuggestGameName(GameMission_t mission, GameMode_t mode);
 void D_CheckCorrectIWAD(GameMission_t mission);
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -1567,8 +1567,7 @@
         }
 
         // auto-loaded files per IWAD
-
-        autoload_dir = M_GetAutoloadDir(D_SaveGameIWADName(gamemission));
+        autoload_dir = M_GetAutoloadDir(D_SaveGameIWADName(gamemission, gamevariant));
         DEH_AutoLoadPatches(autoload_dir);
         W_AutoLoadWADs(autoload_dir);
         free(autoload_dir);
@@ -1681,7 +1680,7 @@
     // we've finished loading Dehacked patches.
     D_SetGameDescription();
 
-    savegamedir = M_GetSaveGameDir(D_SaveGameIWADName(gamemission));
+    savegamedir = M_GetSaveGameDir(D_SaveGameIWADName(gamemission, gamevariant));
 
     // Check for -file in shareware
     if (modifiedgame && (gamevariant != freedoom))