shithub: choc

Download patch

ref: 358db83778b46427fe267f86532d3a84d25a50ac
parent: 2e67fde263924a1f3f3b792dbd38bd58b7a3b948
author: Simon Howard <fraggle@gmail.com>
date: Mon Aug 29 16:37:26 EDT 2011

Fix bug with detection of IWAD type by filename (thanks mether).

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

--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@
      * Fixed gnome-screensaver desktop file (thanks Rahul Sundaram).
      * Updated COPYING to current version of GPL2 (thanks Rahul
        Sundaram).
+     * Fix bug with detection of IWAD type by filename (thanks mether).
 
 1.6.0 (2011-05-17):
 
--- a/src/d_iwad.c
+++ b/src/d_iwad.c
@@ -430,22 +430,24 @@
 static void IdentifyIWADByName(char *name)
 {
     size_t i;
+    char *p;
 
-    gamemission = none;
-    
-    for (i=0; i<arrlen(iwads); ++i)
-    {
-        char *iwadname;
+    // Trim down the name to just the filename, ignoring the path.
 
-        iwadname = DEH_String(iwads[i].name);
+    p = strrchr(name, DIR_SEPARATOR);
 
-        if (strlen(name) < strlen(iwadname))
-            continue;
+    if (p != NULL)
+    {
+        name = p + 1;
+    }
 
-        // Check if it ends in this IWAD name.
+    gamemission = none;
 
-        if (!strcasecmp(name + strlen(name) - strlen(iwadname), 
-                        iwadname))
+    for (i=0; i<arrlen(iwads); ++i)
+    {
+        // Check if the filename is this IWAD name.
+
+        if (!strcasecmp(name, DEH_String(iwads[i].name)))
         {
             CheckSpecialIWADs(iwads[i].name);
             gamemission = iwads[i].mission;