summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2011-05-17 22:06:22 +0000
committerSimon Howard2011-05-17 22:06:22 +0000
commitdcd1a6c3a4b692e0fa905075ef38273f85c138f4 (patch)
tree7d30423a484ed29d204e87f62b8e7c31915ecbde
parenta0ce233f505cecf8a9e5235dcfddf3e78a2231c6 (diff)
downloadchocolate-doom-dcd1a6c3a4b692e0fa905075ef38273f85c138f4.tar.gz
chocolate-doom-dcd1a6c3a4b692e0fa905075ef38273f85c138f4.tar.bz2
chocolate-doom-dcd1a6c3a4b692e0fa905075ef38273f85c138f4.zip
Detect chex.deh if it is in the same directory as the IWAD file.
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2340
-rw-r--r--NEWS2
-rw-r--r--src/d_main.c30
2 files changed, 30 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 759e6af3..fd727429 100644
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,8 @@
the setup tool, which will appear in the main menu on desktop
environments such as Gnome and KDE (thanks Adrián Chaves
Fernández).
+ * The Chex Quest dehacked patch (chex.deh) will now be detected
+ if it is in the same directory as the IWAD file.
Compatibility:
* Added support for the alternate version of the Final Doom
diff --git a/src/d_main.c b/src/d_main.c
index 2cfc6b44..c6979712 100644
--- a/src/d_main.c
+++ b/src/d_main.c
@@ -777,11 +777,37 @@ void PrintGameVersion(void)
static void LoadChexDeh(void)
{
- char *chex_deh;
+ char *chex_deh = NULL;
+ char *sep;
if (gameversion == exe_chex)
{
- chex_deh = D_FindWADByName("chex.deh");
+ // Look for chex.deh in the same directory as the IWAD file.
+
+ sep = strrchr(iwadfile, DIR_SEPARATOR);
+
+ if (sep != NULL)
+ {
+ chex_deh = malloc(strlen(iwadfile) + 9);
+ strcpy(chex_deh, iwadfile);
+ chex_deh[sep - iwadfile + 1] = '\0';
+ strcat(chex_deh, "chex.deh");
+ }
+ else
+ {
+ chex_deh = strdup("chex.deh");
+ }
+
+ // If the dehacked patch isn't found, try searching the WAD
+ // search path instead. We might find it...
+
+ if (!M_FileExists(chex_deh))
+ {
+ free(chex_deh);
+ chex_deh = D_FindWADByName("chex.deh");
+ }
+
+ // Still not found?
if (chex_deh == NULL)
{