foxygit / doom Log in
commit 9981c42b4a8ab3000b22b9acf6ad4b0edd4b0ae7
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Tue Mar 25 22:39:51 2014 -0400
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Tue Mar 25 22:39:51 2014 -0400

    Set GUS patch path variable using D_SetVariable.

    commit 42faefce1fd03 added code to set the GUS patch path
    automatically when the BFG Edition is installed, but this caused
    problems because gusconf.c is not included as part of the build for
    the setup tool. Use D_SetVariable() instead which accomplishes the
    same thing without a hard dependency.
---
 src/d_iwad.c        | 12 +++++-------
 src/doom/d_main.c   | 25 +++++++++++++------------
 src/strife/d_main.c | 24 ++++++++++++------------
 3 files changed, 30 insertions(+), 31 deletions(-)

diff --git a/src/d_iwad.c b/src/d_iwad.c
index 0d3e5e48..ae66db79 100644
--- a/src/d_iwad.c
+++ b/src/d_iwad.c
@@ -32,7 +32,6 @@
 #include "deh_str.h"
 #include "doomkeys.h"
 #include "d_iwad.h"
-#include "gusconf.h"
 #include "i_system.h"
 #include "m_argv.h"
 #include "m_config.h"
@@ -336,12 +335,14 @@ static void CheckSteamEdition(void)

 static void CheckSteamGUSPatches(void)
 {
+    const char *current_path;
     char *install_path;
     char *patch_path;
     int len;

     // Already configured? Don't stomp on the user's choices.
-    if (gus_patch_path != NULL && strlen(gus_patch_path) > 0)
+    current_path = D_GetStrVariable("gus_patch_path");
+    if (current_path != NULL && strlen(current_path) > 0)
     {
         return;
     }
@@ -363,13 +364,10 @@ static void CheckSteamGUSPatches(void)
     {
         snprintf(patch_path, len, "%s\\%s",
                  install_path, STEAM_BFG_GUS_PATCHES);
-        gus_patch_path = patch_path;
-    }
-    else
-    {
-        free(patch_path);
+        D_SetVariable("gus_patch_path", patch_path);
     }

+    free(patch_path);
     free(install_path);
 }

diff --git a/src/doom/d_main.c b/src/doom/d_main.c
index b2566176..e6b993c4 100644
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -1156,18 +1156,6 @@ void D_DoomMain (void)
     DEH_Init();
 #endif

-    iwadfile = D_FindIWAD(IWAD_MASK_DOOM, &gamemission);
-
-    // None found?
-
-    if (iwadfile == NULL)
-    {
-        I_Error("Game mode indeterminate.  No IWAD file was found.  Try\n"
-                "specifying one with the '-iwad' command line parameter.\n");
-    }
-
-    modifiedgame = false;
-
     //!
     // @vanilla
     //
@@ -1293,6 +1281,19 @@ void D_DoomMain (void)
     // Save configuration at exit.
     I_AtExit(M_SaveDefaults, false);

+    // Find main IWAD file and load it.
+    iwadfile = D_FindIWAD(IWAD_MASK_DOOM, &gamemission);
+
+    // None found?
+
+    if (iwadfile == NULL)
+    {
+        I_Error("Game mode indeterminate.  No IWAD file was found.  Try\n"
+                "specifying one with the '-iwad' command line parameter.\n");
+    }
+
+    modifiedgame = false;
+
     DEH_printf("W_Init: Init WADfiles.\n");
     D_AddFile(iwadfile);

diff --git a/src/strife/d_main.c b/src/strife/d_main.c
index 7cd2387f..6769c8ed 100644
--- a/src/strife/d_main.c
+++ b/src/strife/d_main.c
@@ -1394,18 +1394,6 @@ void D_DoomMain (void)
     DEH_Init();
 #endif

-    iwadfile = D_FindIWAD(IWAD_MASK_STRIFE, &gamemission);
-
-    // None found?
-
-    if (iwadfile == NULL)
-    {
-        I_Error("Game mode indeterminate.  No IWAD file was found.  Try\n"
-                "specifying one with the '-iwad' command line parameter.\n");
-    }
-
-    modifiedgame = false;
-
     //!
     // @vanilla
     //
@@ -1551,6 +1539,18 @@ void D_DoomMain (void)
     // Save configuration at exit.
     I_AtExit(M_SaveDefaults, false);

+    // Find the main IWAD file and load it.
+    iwadfile = D_FindIWAD(IWAD_MASK_STRIFE, &gamemission);
+
+    // None found?
+    if (iwadfile == NULL)
+    {
+        I_Error("Game mode indeterminate.  No IWAD file was found.  Try\n"
+                "specifying one with the '-iwad' command line parameter.\n");
+    }
+
+    modifiedgame = false;
+
     if(devparm) // [STRIFE] Devparm only
         DEH_printf("W_Init: Init WADfiles.\n");
     D_AddFile(iwadfile);