shithub: choc

Download patch

ref: c8f42b1cc99bc3c099ff94bdeff79fe4be08a81c
parent: a82e9f6157b06a05f78a74127fa9071074f6d450
author: Simon Howard <fraggle@gmail.com>
date: Mon Mar 26 08:09:53 EDT 2007

Search WAD search dirs when loading dehacked patches.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 863

--- a/src/d_iwad.c
+++ b/src/d_iwad.c
@@ -43,6 +43,8 @@
 // "128 IWAD search directories should be enough for anybody".
 
 #define MAX_IWAD_DIRS 128
+
+static boolean iwad_dirs_built = false;
 static char *iwad_dirs[MAX_IWAD_DIRS];
 static int num_iwad_dirs = 0;
 
@@ -388,6 +390,11 @@
 {
     char *doomwaddir;
 
+    if (iwad_dirs_built)
+    {
+        return;
+    }
+
     // Look in the current directory.  Doom always does this.
 
     AddIWADDir(".");
@@ -420,6 +427,10 @@
     AddIWADDir("/usr/local/share/games/doom");
 
 #endif
+
+    // Don't run this function again.
+
+    iwad_dirs_built = true;
 }
 
 //
@@ -438,6 +449,8 @@
     {
         return name;
     }
+
+    BuildIWADDirList();
     
     // Search through all IWAD paths for a file with the given name.
 
@@ -500,10 +513,6 @@
     int iwadparm;
     int i;
 
-    // Build a list of locations to look for an IWAD
-
-    BuildIWADDirList();
-
     // Check for the -iwad parameter
 
     //!
@@ -535,6 +544,8 @@
 
         result = NULL;
 
+        BuildIWADDirList();
+    
         for (i=0; result == NULL && i<num_iwad_dirs; ++i)
         {
             result = SearchDirectoryForIWAD(iwad_dirs[i]);
--- a/src/deh_main.c
+++ b/src/deh_main.c
@@ -29,6 +29,7 @@
 
 #include "doomdef.h"
 #include "doomtype.h"
+#include "d_iwad.h"
 #include "m_argv.h"
 
 #include "deh_defs.h"
@@ -335,6 +336,7 @@
 
 void DEH_Init(void)
 {
+    char *filename;
     int p;
 
     InitialiseSections();
@@ -354,8 +356,9 @@
 
         while (p < myargc && myargv[p][0] != '-')
         {
-            printf(" loading %s\n", myargv[p]);
-            DEH_ParseFile(myargv[p]);
+            filename = D_TryFindWADByName(myargv[p]);
+            printf(" loading %s\n", filename);
+            DEH_ParseFile(filename);
             ++p;
         }
     }