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.
This commit is contained in:
Simon Howard 2018-09-09 18:45:23 -04:00
parent b34edc6d3e
commit b695b71233

View file

@ -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)