summaryrefslogtreecommitdiff
path: root/src/d_iwad.c
diff options
context:
space:
mode:
authorSimon Howard2014-03-23 22:04:22 -0400
committerSimon Howard2014-03-23 22:04:22 -0400
commit42faefce1fd03f5d613bf709d3c14925ee560064 (patch)
tree21dc51df17e21302a7b138d5180afba0f90a0998 /src/d_iwad.c
parentda6a260461920d4cafd4c6d1d624aebf2d9b975c (diff)
downloadchocolate-doom-42faefce1fd03f5d613bf709d3c14925ee560064.tar.gz
chocolate-doom-42faefce1fd03f5d613bf709d3c14925ee560064.tar.bz2
chocolate-doom-42faefce1fd03f5d613bf709d3c14925ee560064.zip
Autodetect GUS patches installed with BFG Edition.
Doom 3: BFG Edition installs copies of the GUS instrument files (patches) that can be used for the GUS pseudo-emulation. Detect these on startup if no GUS patch path has been configured and configure gus_patch_path config variable automatically. This fixes #333.
Diffstat (limited to 'src/d_iwad.c')
-rw-r--r--src/d_iwad.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/d_iwad.c b/src/d_iwad.c
index bfef4859..0d3e5e48 100644
--- a/src/d_iwad.c
+++ b/src/d_iwad.c
@@ -32,6 +32,7 @@
#include "deh_str.h"
#include "doomkeys.h"
#include "d_iwad.h"
+#include "gusconf.h"
#include "i_system.h"
#include "m_argv.h"
#include "m_config.h"
@@ -193,6 +194,9 @@ static char *steam_install_subdirs[] =
"steamapps\\common\\DOOM 3 BFG Edition\\base\\wads",
};
+#define STEAM_BFG_GUS_PATCHES \
+ "steamapps\\common\\DOOM 3 BFG Edition\\base\\classicmusic\\instruments"
+
static char *GetRegistryString(registry_value_t *reg_val)
{
HKEY key;
@@ -327,6 +331,48 @@ static void CheckSteamEdition(void)
free(install_path);
}
+// The BFG edition ships with a full set of GUS patches. If we find them,
+// we can autoconfigure to use them.
+
+static void CheckSteamGUSPatches(void)
+{
+ char *install_path;
+ char *patch_path;
+ int len;
+
+ // Already configured? Don't stomp on the user's choices.
+ if (gus_patch_path != NULL && strlen(gus_patch_path) > 0)
+ {
+ return;
+ }
+
+ install_path = GetRegistryString(&steam_install_location);
+
+ if (install_path == NULL)
+ {
+ return;
+ }
+
+ len = strlen(install_path) + strlen(STEAM_BFG_GUS_PATCHES) + 20;
+ patch_path = malloc(len);
+ snprintf(patch_path, len, "%s\\%s\\ACBASS.PAT",
+ install_path, STEAM_BFG_GUS_PATCHES);
+
+ // Does acbass.pat exist? If so, then set gus_patch_path.
+ if (M_FileExists(patch_path))
+ {
+ snprintf(patch_path, len, "%s\\%s",
+ install_path, STEAM_BFG_GUS_PATCHES);
+ gus_patch_path = patch_path;
+ }
+ else
+ {
+ free(patch_path);
+ }
+
+ free(install_path);
+}
+
// Default install directories for DOS Doom
static void CheckDOSDefaults(void)
@@ -565,6 +611,10 @@ static void BuildIWADDirList(void)
CheckSteamEdition();
CheckDOSDefaults();
+ // Check for GUS patches installed with the BFG edition!
+
+ CheckSteamGUSPatches();
+
#else
// Standard places where IWAD files are installed under Unix.