commit 358db83778b46427fe267f86532d3a84d25a50ac
Author: Simon Howard <fraggle@gmail.com>
AuthorDate: Mon Aug 29 20:37:26 2011 +0000
Commit: Simon Howard <fraggle@gmail.com>
CommitDate: Mon Aug 29 20:37:26 2011 +0000
Fix bug with detection of IWAD type by filename (thanks mether).
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 2359
---
NEWS | 1 +
src/d_iwad.c | 24 +++++++++++++-----------
2 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/NEWS b/NEWS
index e2d95b7d..425da376 100644
--- 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):
diff --git a/src/d_iwad.c b/src/d_iwad.c
index c0d33707..be5a3880 100644
--- a/src/d_iwad.c
+++ b/src/d_iwad.c
@@ -430,22 +430,24 @@ static char *SearchDirectoryForIWAD(char *dir)
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;
+ }
+
+ gamemission = none;
- // Check if it ends in this IWAD name.
+ for (i=0; i<arrlen(iwads); ++i)
+ {
+ // Check if the filename is this IWAD name.
- if (!strcasecmp(name + strlen(name) - strlen(iwadname),
- iwadname))
+ if (!strcasecmp(name, DEH_String(iwads[i].name)))
{
CheckSpecialIWADs(iwads[i].name);
gamemission = iwads[i].mission;