foxygit / doom Log in
commit b695b71233b831c49fa3155c36ace08bcffcf5c6
Author:     Simon Howard <fraggle@soulsphere.org>
AuthorDate: Sun Sep 9 18:45:23 2018 -0400
Commit:     Simon Howard <fraggle@soulsphere.org>
CommitDate: Sun Sep 9 18:45:23 2018 -0400

    iwad: Check executable location for IWADs.

    This adds an additional search path when looking for IWADs - in addition
    to checking the current working directory, also look in the directory
    where the program executable is located.

    To give some context for why I'm adding this: apparently there's a small
    number of users who do something very unpleasant that I'd really prefer
    they didn't: they "install" Chocolate Doom into Steam by replacing
    dosbox.exe from their Steam installation of Doom with a renamed version
    of `chocolate-doom.exe`. Yuck, I don't approve - it's a grotesque hack.

    This works but it has a bug: Chocolate Doom picks up the Steam IWADs
    from Windows registry keys. This means that it always starts doom2.wad,
    and launching "Ultimate Doom" will actually launch Doom II. This solves
    that problem, and while I don't approve of dumb Steam hacks, the change
    itself is reasonable and it's an eminently sensible place to look for an
    IWAD file.
---
 src/d_iwad.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/d_iwad.c b/src/d_iwad.c
index 02984cd7..5e87ebc7 100644
--- a/src/d_iwad.c
+++ b/src/d_iwad.c
@@ -668,6 +668,10 @@ static void BuildIWADDirList(void)
     // Look in the current directory.  Doom always does this.
     AddIWADDir(".");

+    // Next check the directory where the executable is located. This might
+    // be different from the current directory.
+    AddIWADDir(M_DirName(myargv[0]));
+
     // Add DOOMWADDIR if it is in the environment
     env = getenv("DOOMWADDIR");
     if (env != NULL)