shithub: choc

Download patch

ref: 7742f0d45950980423839c7145f6dc70f6daa63b
parent: 1efd274daf5e10dd78e0a5cb0181b75ddca10db0
author: James Haley <haleyjd@hotmail.com>
date: Sat May 21 09:57:58 EDT 2016

Swap order of checks for voices.wad; resolve issue #675

--- a/src/strife/d_main.c
+++ b/src/strife/d_main.c
@@ -830,49 +830,48 @@
     // Load voices.wad 
     if(isregistered)
     {
-        char *name = D_FindWADByName("voices.wad");
+        char *name = NULL;
+        int p;
 
-        if(!name) // not found?
+        // If -iwad was used, check and see if voices.wad exists on the same
+        // filepath.
+        if((p = M_CheckParm("-iwad")) && p < myargc - 1)
         {
-            int p;
+            char   *iwad     = myargv[p + 1];
+            size_t  len      = strlen(iwad) + 1;
+            char   *iwadpath = Z_Malloc(len, PU_STATIC, NULL);
+            char   *voiceswad;
 
-            // haleyjd STRIFE-FIXME: Temporary?
-            // If -iwad was used, check and see if voices.wad exists on the
-            // same filepath.
-            if((p = M_CheckParm("-iwad")) && p < myargc - 1)
-            {
-                char   *iwad     = myargv[p + 1];
-                size_t  len      = strlen(iwad) + 1;
-                char   *iwadpath = Z_Malloc(len, PU_STATIC, NULL);
-                char   *voiceswad;
-                
-                // extract base path of IWAD parameter
-                M_GetFilePath(iwad, iwadpath, len);
-                
-                // concatenate with /voices.wad
-                voiceswad = M_SafeFilePath(iwadpath, "voices.wad");
-                Z_Free(iwadpath);
-
-                if(!M_FileExists(voiceswad))
-                {
-                    disable_voices = 1;
-                    Z_Free(voiceswad);
-                }
-                else
-                    name = voiceswad; // STRIFE-FIXME: memory leak!!
-            }
+            // extract base path of IWAD parameter
+            M_GetFilePath(iwad, iwadpath, len);
+
+            // concatenate with /voices.wad
+            voiceswad = M_SafeFilePath(iwadpath, "voices.wad");
+            Z_Free(iwadpath);
+
+            if(!M_FileExists(voiceswad))
+                Z_Free(voiceswad);
             else
-                disable_voices = 1;
+                name = voiceswad; // STRIFE-FIXME: memory leak!!
         }
 
-        if(disable_voices) // voices disabled?
+        // not found? try global search paths
+        if(!name)
+            name = D_FindWADByName("voices.wad");
+
+        // still not found? too bad.
+        if(!name)
         {
+            disable_voices = 1;
+
             if(devparm)
                  printf("Voices disabled\n");
-            return;
         }
-
-        D_AddFile(name);
+        else
+        {
+            // add it.
+            D_AddFile(name);
+        }
     }
 }