diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/d_main.c | 30 |
1 files changed, 28 insertions, 2 deletions
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) { |