shithub: choc

Download patch

ref: 2f38d73f55a8927ceca131e74874d1d544d11fac
parent: 7a6f9ad53b3917b00d3815ed8d948c69d4d48efd
author: Simon Howard <[email protected]>
date: Thu Feb 1 07:21:14 EST 2007

Search IWAD search directories when loading PWAD files.

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

--- a/src/d_iwad.c
+++ b/src/d_iwad.c
@@ -416,10 +416,10 @@
 }
 
 //
-// Searches IWAD search paths for an IWAD with a specific name.
+// Searches WAD search paths for an WAD with a specific filename.
 // 
 
-char *D_FindIWADByName(char *name)
+char *D_FindWADByName(char *name)
 {
     char *buf;
     int i;
@@ -457,6 +457,29 @@
 }
 
 //
+// D_TryWADByName
+//
+// Searches for a WAD by its filename, or passes through the filename
+// if not found.
+//
+
+char *D_TryFindWADByName(char *filename)
+{
+    char *result;
+
+    result = D_FindWADByName(filename);
+
+    if (result != NULL)
+    {
+        return result;
+    }
+    else
+    {
+        return filename;
+    }
+}
+
+//
 // FindIWAD
 // Checks availability of IWAD files by name,
 // to determine whether registered/commercial features
@@ -490,7 +513,7 @@
 
         iwadfile = myargv[iwadparm + 1];
 
-        result = D_FindIWADByName(iwadfile);
+        result = D_FindWADByName(iwadfile);
 
         if (result == NULL)
         {
@@ -762,7 +785,7 @@
 
     for (i=0; i<sizeof(iwads) / sizeof(*iwads); ++i)
     {
-        if (D_FindIWADByName(iwads[i].name) != NULL)
+        if (D_FindWADByName(iwads[i].name) != NULL)
         {
             result |= 1 << i;
         }
--- a/src/d_iwad.h
+++ b/src/d_iwad.h
@@ -27,6 +27,8 @@
 #ifndef __D_IWAD__
 #define __D_IWAD__
 
+char *D_FindWADByName(char *filename);
+char *D_TryFindWADByName(char *filename);
 char *D_FindIWAD(void);
 void D_SetSaveGameDir(void);
 void D_IdentifyVersion(void);
--- a/src/d_main.c
+++ b/src/d_main.c
@@ -954,8 +954,12 @@
     {
         for (p = p + 1; p<myargc && myargv[p][0] != '-'; ++p)
         {
-            printf(" merging %s\n", myargv[p]);
-            W_MergeFile(myargv[p]);
+            char *filename;
+
+            filename = D_TryFindWADByName(myargv[p]);
+
+            printf(" merging %s\n", filename);
+            W_MergeFile(filename);
         }
     }
 
@@ -976,8 +980,12 @@
     {
         for (p = p + 1; p<myargc && myargv[p][0] != '-'; ++p)
         {
-            printf(" performing NWT-style merge of %s\n", myargv[p]);
-            W_NWTDashMerge(myargv[p]);
+            char *filename;
+
+            filename = D_TryFindWADByName(myargv[p]);
+
+            printf(" performing NWT-style merge of %s\n", filename);
+            W_NWTDashMerge(filename);
         }
     }
     
@@ -997,8 +1005,12 @@
     {
         for (p = p + 1; p<myargc && myargv[p][0] != '-'; ++p)
         {
-            printf(" merging flats from %s\n", myargv[p]);
-            W_NWTMergeFile(myargv[p], W_NWT_MERGE_FLATS);
+            char *filename;
+
+            filename = D_TryFindWADByName(myargv[p]);
+
+            printf(" merging flats from %s\n", filename);
+            W_NWTMergeFile(filename, W_NWT_MERGE_FLATS);
         }
     }
 
@@ -1016,8 +1028,12 @@
     {
         for (p = p + 1; p<myargc && myargv[p][0] != '-'; ++p)
         {
-            printf(" merging sprites from %s\n", myargv[p]);
-            W_NWTMergeFile(myargv[p], W_NWT_MERGE_SPRITES);
+            char *filename;
+
+            filename = D_TryFindWADByName(myargv[p]);
+
+            printf(" merging sprites from %s\n", filename);
+            W_NWTMergeFile(filename, W_NWT_MERGE_SPRITES);
         }
     }
 
@@ -1034,8 +1050,12 @@
     {
         for (p = p + 1; p<myargc && myargv[p][0] != '-'; ++p)
         {
-            printf(" merging sprites and flats from %s\n", myargv[p]);
-            W_NWTMergeFile(myargv[p], W_NWT_MERGE_SPRITES | W_NWT_MERGE_FLATS);
+            char *filename;
+
+            filename = D_TryFindWADByName(myargv[p]);
+
+            printf(" merging sprites and flats from %s\n", filename);
+            W_NWTMergeFile(filename, W_NWT_MERGE_SPRITES | W_NWT_MERGE_FLATS);
         }
     }
 
@@ -1054,7 +1074,13 @@
 	// until end of parms or another - preceded parm
 	modifiedgame = true;            // homebrew levels
 	while (++p != myargc && myargv[p][0] != '-')
-	    D_AddFile (myargv[p]);
+        {
+            char *filename;
+
+            filename = D_TryFindWADByName(myargv[p]);
+
+	    D_AddFile(filename);
+        }
     }
 
     // Debug: