mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 14:51:46 +00:00
Added support for GOG paths
This works a bit differently from the Steam version, because each game has its own registry keys and its own independent path.
This commit is contained in:
parent
0a8255f34b
commit
98f214ee66
3 changed files with 66 additions and 5 deletions
|
@ -435,6 +435,11 @@ int FIWadManager::IdentifyVersion (TArray<FString> &wadfiles, const char *iwad,
|
|||
}
|
||||
}
|
||||
}
|
||||
TArray<FString> gog_paths = I_GetGogPaths();
|
||||
for (i = 0; i < gog_paths.Size(); ++i)
|
||||
{
|
||||
CheckIWAD (gog_paths[i], &wads[0]);
|
||||
}
|
||||
TArray<FString> steam_path = I_GetSteamPath();
|
||||
for (i = 0; i < steam_path.Size(); ++i)
|
||||
{
|
||||
|
|
|
@ -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 <steamdir>/SteamApps/common/<GameName>.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
TArray<FString> I_GetGogPaths()
|
||||
{
|
||||
TArray<FString> 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
|
||||
|
|
|
@ -168,6 +168,9 @@ void I_SetWndProc();
|
|||
// directories for IWADs if the user purchased any through Steam.
|
||||
TArray<FString> I_GetSteamPath();
|
||||
|
||||
// [GZ] Same deal for GOG paths
|
||||
TArray<FString> 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.
|
||||
|
|
Loading…
Reference in a new issue