diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index 3fc365e8c..a8d60e1ce 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -435,6 +435,11 @@ int FIWadManager::IdentifyVersion (TArray &wadfiles, const char *iwad, } } } + TArray gog_paths = I_GetGogPaths(); + for (i = 0; i < gog_paths.Size(); ++i) + { + CheckIWAD (gog_paths[i], &wads[0]); + } TArray steam_path = I_GetSteamPath(); for (i = 0; i < steam_path.Size(); ++i) { diff --git a/src/posix/i_system.cpp b/src/posix/i_system.cpp index fd6bb4c0c..84b953717 100644 --- a/src/posix/i_system.cpp +++ b/src/posix/i_system.cpp @@ -758,3 +758,9 @@ unsigned int I_MakeRNGSeed() } return seed; } + +TArray I_GetGogPaths() +{ + // GOG's Doom games are Windows only at the moment + return TArray(); +} diff --git a/src/posix/i_system.h b/src/posix/i_system.h index abda490c4..391503602 100644 --- a/src/posix/i_system.h +++ b/src/posix/i_system.h @@ -124,6 +124,8 @@ int I_PickIWad (WadStuff *wads, int numwads, bool queryiwad, int defaultiwad); // directories for IWADs if the user purchased any through Steam. TArray I_GetSteamPath(); +TArray I_GetGogPaths(); + // The ini could not be saved at exit bool I_WriteIniFailed (); diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp index 6d8fb8595..372da8685 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -1504,30 +1504,83 @@ int I_FindClose(void *handle) static bool QueryPathKey(HKEY key, const char *keypath, const char *valname, FString &value) { - HKEY steamkey; + HKEY pathkey; DWORD pathtype; DWORD pathlen; LONG res; - if(ERROR_SUCCESS == RegOpenKeyEx(key, keypath, 0, KEY_QUERY_VALUE, &steamkey)) + if(ERROR_SUCCESS == RegOpenKeyEx(key, keypath, 0, KEY_QUERY_VALUE, &pathkey)) { - if (ERROR_SUCCESS == RegQueryValueEx(steamkey, valname, 0, &pathtype, NULL, &pathlen) && + if (ERROR_SUCCESS == RegQueryValueEx(pathkey, valname, 0, &pathtype, NULL, &pathlen) && pathtype == REG_SZ && pathlen != 0) { // Don't include terminating null in count char *chars = value.LockNewBuffer(pathlen - 1); - res = RegQueryValueEx(steamkey, valname, 0, NULL, (LPBYTE)chars, &pathlen); + res = RegQueryValueEx(pathkey, valname, 0, NULL, (LPBYTE)chars, &pathlen); value.UnlockBuffer(); if (res != ERROR_SUCCESS) { value = ""; } } - RegCloseKey(steamkey); + RegCloseKey(pathkey); } return value.IsNotEmpty(); } +//========================================================================== +// +// I_GetGogPaths +// +// Check the registry for GOG installation paths, so we can search for IWADs +// that were bought from GOG.com. This is a bit different from the Steam +// version because each game has its own independent installation path, no +// such thing as /SteamApps/common/. +// +//========================================================================== + +TArray I_GetGogPaths() +{ + TArray result; + FString path; + FString gamepath; + +#ifdef _WIN64 + FString gogregistrypath = "Software\\Wow6432Node\\GOG.com\\Games"; +#else + // If a 32-bit ZDoom runs on a 64-bit Windows, this will be transparently and + // automatically redirected to the Wow6432Node address instead, so this address + // should be safe to use in all cases. + FString gogregistrypath = "Software\\GOG.com\\Games"; +#endif + + // Look for Ultimate Doom + gamepath = gogregistrypath + "\\1435827232"; + if (QueryPathKey(HKEY_LOCAL_MACHINE, gamepath.GetChars(), "Path", path)) + { + result.Push(path); // directly in install folder + } + + // Look for Doom II + gamepath = gogregistrypath + "\\1435848814"; + if (QueryPathKey(HKEY_LOCAL_MACHINE, gamepath.GetChars(), "Path", path)) + { + result.Push(path + "/doom2"); // in a subdirectory + // If direct support for the Master Levels is ever added, they are in path + /master/wads + } + + // Look for Final Doom + gamepath = gogregistrypath + "\\1435848742"; + if (QueryPathKey(HKEY_LOCAL_MACHINE, gamepath.GetChars(), "Path", path)) + { + // in subdirectories + result.Push(path + "/TNT"); + result.Push(path + "/Plutonia"); + } + + return result; +} + //========================================================================== // // I_GetSteamPath diff --git a/src/win32/i_system.h b/src/win32/i_system.h index 566ca1977..03f4f3c0f 100644 --- a/src/win32/i_system.h +++ b/src/win32/i_system.h @@ -168,6 +168,9 @@ void I_SetWndProc(); // directories for IWADs if the user purchased any through Steam. TArray I_GetSteamPath(); +// [GZ] Same deal for GOG paths +TArray I_GetGogPaths(); + // Damn Microsoft for doing Get/SetWindowLongPtr half-assed. Instead of // giving them proper prototypes under Win32, they are just macros for // Get/SetWindowLong, meaning they take LONGs and not LONG_PTRs. diff --git a/wadsrc/static/actors/doom/spidermaster.txt b/wadsrc/static/actors/doom/spidermaster.txt index 97ebbf143..c2a742f1e 100644 --- a/wadsrc/static/actors/doom/spidermaster.txt +++ b/wadsrc/static/actors/doom/spidermaster.txt @@ -6,7 +6,7 @@ ACTOR SpiderMastermind { Health 3000 - Radius 100 + Radius 128 Height 100 Mass 1000 Speed 12