shithub: choc

Download patch

ref: b695b71233b831c49fa3155c36ace08bcffcf5c6
parent: b34edc6d3ee93b5ea6ffc6c6994ad38e54384221
author: Simon Howard <fraggle@soulsphere.org>
date: Sun Sep 9 14:45:23 EDT 2018

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.

--- a/src/d_iwad.c
+++ b/src/d_iwad.c
@@ -668,6 +668,10 @@
     // 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)