diff options
author | Simon Howard | 2007-08-07 01:19:49 +0000 |
---|---|---|
committer | Simon Howard | 2007-08-07 01:19:49 +0000 |
commit | 309a199f761549c53219e88a1040948a1b9a71f9 (patch) | |
tree | 0b0903d4caa940f1d1972adb3339fd008e50c5ec | |
parent | 69cd2345e29316f8bfb247b2f1f97c4076b47d27 (diff) | |
download | chocolate-doom-309a199f761549c53219e88a1040948a1b9a71f9.tar.gz chocolate-doom-309a199f761549c53219e88a1040948a1b9a71f9.tar.bz2 chocolate-doom-309a199f761549c53219e88a1040948a1b9a71f9.zip |
Autodetect IWADs installed by Steam.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 945
-rw-r--r-- | src/d_iwad.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/d_iwad.c b/src/d_iwad.c index 320ee835..8f2078c9 100644 --- a/src/d_iwad.c +++ b/src/d_iwad.c @@ -140,6 +140,24 @@ static char *collectors_edition_subdirs[] = "Ultimate Doom", }; +// Location where Steam is installed + +static registry_value_t steam_install_location = +{ + HKEY_LOCAL_MACHINE, + "Software\\Valve\\Steam", + "InstallPath", +}; + +// Subdirs of the steam install directory where IWADs are found + +static char *steam_install_subdirs[] = +{ + "steamapps\\common\\doom 2", + "steamapps\\common\\ultimate doom", + "steamapps\\common\\final doom\\base", +}; + static char *GetRegistryString(registry_value_t *reg_val) { HKEY key; @@ -251,6 +269,41 @@ static void CheckCollectorsEdition(void) free(install_path); } + +// Check for Doom downloaded via Steam + +static void CheckSteamEdition(void) +{ + char *install_path; + char *subpath; + int i; + + install_path = GetRegistryString(&steam_install_location); + + if (install_path == NULL) + { + return; + } + + for (i=0; i<arrlen(steam_install_subdirs); ++i) + { + subpath = malloc(strlen(install_path) + + strlen(steam_install_subdirs[i]) + 5); + + sprintf(subpath, "%s%s", install_path, steam_install_subdirs[i]); + + if (M_FileExists(subpath)) + { + AddIWADDir(subpath); + } + else + { + free(subpath); + } + } +} + + #endif static struct @@ -417,6 +470,7 @@ static void BuildIWADDirList(void) CheckUninstallStrings(); CheckCollectorsEdition(); + CheckSteamEdition(); #else |