mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-26 00:40:56 +00:00
- fixed GOG path lookup.
I was unable to verify the Steam paths so they may or may not work.
This commit is contained in:
parent
e79a693313
commit
681155de65
4 changed files with 67 additions and 196 deletions
|
@ -55,6 +55,7 @@ set( PCH_SOURCES
|
||||||
src/mirrors.cpp
|
src/mirrors.cpp
|
||||||
src/misc.cpp
|
src/misc.cpp
|
||||||
src/network.cpp
|
src/network.cpp
|
||||||
|
src/nnexts.cpp
|
||||||
src/osdcmd.cpp
|
src/osdcmd.cpp
|
||||||
src/player.cpp
|
src/player.cpp
|
||||||
src/qav.cpp
|
src/qav.cpp
|
||||||
|
|
|
@ -58,6 +58,7 @@ int g_gameType;
|
||||||
void AddSearchPath(TArray<FString>& searchpaths, const char* path)
|
void AddSearchPath(TArray<FString>& searchpaths, const char* path)
|
||||||
{
|
{
|
||||||
auto fpath = M_GetNormalizedPath(path);
|
auto fpath = M_GetNormalizedPath(path);
|
||||||
|
if (fpath.Back() == '/') fpath.Truncate(fpath.Len() - 1);
|
||||||
if (DirExists(fpath))
|
if (DirExists(fpath))
|
||||||
{
|
{
|
||||||
if (searchpaths.Find(fpath) == searchpaths.Size())
|
if (searchpaths.Find(fpath) == searchpaths.Size())
|
||||||
|
@ -83,8 +84,8 @@ void G_AddExternalSearchPaths(TArray<FString> &searchpaths)
|
||||||
|
|
||||||
struct RegistryPathInfo
|
struct RegistryPathInfo
|
||||||
{
|
{
|
||||||
const char *regPath;
|
const wchar_t *regPath;
|
||||||
const char *regKey;
|
const wchar_t *regKey;
|
||||||
const char **subpaths;
|
const char **subpaths;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -96,29 +97,39 @@ static const char * ww2gi[] = { "/WW2GI", nullptr};
|
||||||
static const char * bloodfs[] = { "", R"(\addons\Cryptic Passage)", nullptr};
|
static const char * bloodfs[] = { "", R"(\addons\Cryptic Passage)", nullptr};
|
||||||
static const char * sw[] = { "/Shadow Warrior", nullptr};
|
static const char * sw[] = { "/Shadow Warrior", nullptr};
|
||||||
|
|
||||||
|
#ifndef _WIN64
|
||||||
|
#define WOW64 "\\"
|
||||||
|
#else
|
||||||
|
#define WOW64 "\\Wow6432Node\\"
|
||||||
|
#endif
|
||||||
|
|
||||||
static const RegistryPathInfo paths[] = {
|
static const RegistryPathInfo paths[] = {
|
||||||
{ R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 434050)", "InstallLocation", nullptr },
|
{ L"SOFTWARE" WOW64 "GOG.com\\GOGDUKE3D", L"PATH", nullptr },
|
||||||
{ R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 225140)", "InstallLocation", dukeaddons },
|
{ L"SOFTWARE" WOW64 "GOG.com\\GOGREDNECKRAMPAGE", L"PATH", nullptr },
|
||||||
{ R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 359850)", "InstallLocation", dn3d },
|
{ L"SOFTWARE" WOW64 "GOG.com\\GOGCREDNECKRIDESAGAIN", L"PATH", nullptr },
|
||||||
{ "SOFTWARE\\GOG.com\\GOGDUKE3D", "PATH", nullptr },
|
{ L"SOFTWARE" WOW64 "GOG.com\\GOGONEUNITONEBLOOD", L"PATH", nullptr},
|
||||||
{ "SOFTWARE\\3DRealms\\Duke Nukem 3D", nullptr, dn3d },
|
{ L"SOFTWARE" WOW64 "GOG.com\\GOGSHADOWARRIOR", L"PATH", nullptr},
|
||||||
{ "SOFTWARE\\3DRealms\\Anthology", nullptr, dn3d },
|
{ L"SOFTWARE" WOW64 "GOG.com\\Games\\1374469660", L"path", bloodfs},
|
||||||
{ R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 329650)", "InstallLocation", nam },
|
{ L"SOFTWARE" WOW64 "GOG.com\\Games\\1740836875", L"path", nullptr},
|
||||||
{ R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 376750)", "InstallLocation", ww2gi },
|
|
||||||
{ "SOFTWARE\\GOG.com\\GOGREDNECKRAMPAGE", "PATH", nullptr },
|
{ L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 434050", L"InstallLocation", nullptr },
|
||||||
{ "SOFTWARE\\GOG.com\\GOGCREDNECKRIDESAGAIN", "PATH", nullptr },
|
{ L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 225140", L"InstallLocation", dukeaddons },
|
||||||
{ R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 299030)", "InstallLocation", nullptr }, // Blood: One Unit Whole Blood (Steam)
|
{ L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 359850", L"InstallLocation", dn3d },
|
||||||
{ "SOFTWARE\\GOG.com\\GOGONEUNITONEBLOOD", "PATH", nullptr},
|
{ L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 329650", L"InstallLocation", nam },
|
||||||
{ R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 1010750)", "InstallLocation", bloodfs},
|
{ L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 376750", L"InstallLocation", ww2gi },
|
||||||
{ R"(SOFTWARE\Wow6432Node\GOG.com\Games\1374469660)", "path", bloodfs},
|
{ L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 299030", L"InstallLocation", nullptr }, // Blood: One Unit Whole Blood (Steam)
|
||||||
{ R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 225160)", "InstallLocation", gameroot },
|
{ L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 1010750",L"InstallLocation", bloodfs},
|
||||||
{ R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 238070)", "InstallLocation", gameroot}, // Shadow Warrior Classic (1997) - Steam
|
{ L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 225160", L"InstallLocation", gameroot },
|
||||||
{ R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 358400)", "InstallLocation", sw},
|
{ L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 238070", L"InstallLocation", gameroot}, // Shadow Warrior Classic (1997) - Steam
|
||||||
{ "SOFTWARE\\GOG.com\\GOGSHADOWARRIOR", "PATH", nullptr},
|
{ L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 358400", L"InstallLocation", sw},
|
||||||
{ "SOFTWARE\\3DRealms\\Shadow Warrior", nullptr, sw},
|
{ L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 562860", L"InstallLocation", nullptr}, // Ion Fury (Steam)
|
||||||
{ "SOFTWARE\\3DRealms\\Anthology", nullptr, sw},
|
#if 0
|
||||||
{ R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 562860)", "InstallLocation", nullptr}, // Ion Fury (Steam)
|
{ L"SOFTWARE\\3DRealms\\Duke Nukem 3D", nullptr, dn3d },
|
||||||
{ R"(SOFTWARE\GOG.com\Games\1740836875)", "path", nullptr},
|
{ L"SOFTWARE\\3DRealms\\Anthology", nullptr, dn3d },
|
||||||
|
{ L"SOFTWARE\\3DRealms\\Shadow Warrior", nullptr, sw},
|
||||||
|
{ L"SOFTWARE\\3DRealms\\Anthology", nullptr, sw},
|
||||||
|
#endif
|
||||||
|
|
||||||
{ nullptr}
|
{ nullptr}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -128,10 +139,10 @@ void G_AddExternalSearchPaths(TArray<FString> &searchpaths)
|
||||||
for (auto &entry : paths)
|
for (auto &entry : paths)
|
||||||
{
|
{
|
||||||
// 3D Realms Anthology
|
// 3D Realms Anthology
|
||||||
char buf[PATH_MAX];
|
FString buf;
|
||||||
size_t bufsize = sizeof(buf);
|
if (I_QueryPathKey(entry.regPath, entry.regKey, buf))
|
||||||
if (I_ReadRegistryValue(entry.regPath, entry.regKey, buf, &bufsize))
|
|
||||||
{
|
{
|
||||||
|
FixPathSeperator(buf);
|
||||||
if (!entry.subpaths) AddSearchPath(searchpaths, buf);
|
if (!entry.subpaths) AddSearchPath(searchpaths, buf);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -979,145 +979,6 @@ const char *I_FindName(findstate_t *fileinfo)
|
||||||
return fileinfo->UTF8Name.GetChars();
|
return fileinfo->UTF8Name.GetChars();
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
// QueryPathKey
|
|
||||||
//
|
|
||||||
// Returns the value of a registry key into the output variable value.
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
static bool QueryPathKey(HKEY key, const wchar_t *keypath, const wchar_t *valname, FString &value)
|
|
||||||
{
|
|
||||||
HKEY pathkey;
|
|
||||||
DWORD pathtype;
|
|
||||||
DWORD pathlen;
|
|
||||||
LONG res;
|
|
||||||
|
|
||||||
value = "";
|
|
||||||
if(ERROR_SUCCESS == RegOpenKeyEx(key, keypath, 0, KEY_QUERY_VALUE, &pathkey))
|
|
||||||
{
|
|
||||||
if (ERROR_SUCCESS == RegQueryValueEx(pathkey, valname, 0, &pathtype, NULL, &pathlen) &&
|
|
||||||
pathtype == REG_SZ && pathlen != 0)
|
|
||||||
{
|
|
||||||
// Don't include terminating null in count
|
|
||||||
TArray<wchar_t> chars(pathlen + 1, true);
|
|
||||||
res = RegQueryValueEx(pathkey, valname, 0, NULL, (LPBYTE)chars.Data(), &pathlen);
|
|
||||||
if (res == ERROR_SUCCESS) value = FString(chars.Data());
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
std::wstring gamepath;
|
|
||||||
|
|
||||||
#ifdef _WIN64
|
|
||||||
std::wstring gogregistrypath = L"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.
|
|
||||||
std::wstring gogregistrypath = L"Software\\GOG.com\\Games";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Look for Ultimate Doom
|
|
||||||
gamepath = gogregistrypath + L"\\1435827232";
|
|
||||||
if (QueryPathKey(HKEY_LOCAL_MACHINE, gamepath.c_str(), L"Path", path))
|
|
||||||
{
|
|
||||||
result.Push(path); // directly in install folder
|
|
||||||
}
|
|
||||||
|
|
||||||
// Look for Doom II
|
|
||||||
gamepath = gogregistrypath + L"\\1435848814";
|
|
||||||
if (QueryPathKey(HKEY_LOCAL_MACHINE, gamepath.c_str(), L"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 + L"\\1435848742";
|
|
||||||
if (QueryPathKey(HKEY_LOCAL_MACHINE, gamepath.c_str(), L"Path", path))
|
|
||||||
{
|
|
||||||
// in subdirectories
|
|
||||||
result.Push(path + "/TNT");
|
|
||||||
result.Push(path + "/Plutonia");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Look for Doom 3: BFG Edition
|
|
||||||
gamepath = gogregistrypath + L"\\1135892318";
|
|
||||||
if (QueryPathKey(HKEY_LOCAL_MACHINE, gamepath.c_str(), L"Path", path))
|
|
||||||
{
|
|
||||||
result.Push(path + "/base/wads"); // in a subdirectory
|
|
||||||
}
|
|
||||||
|
|
||||||
// Look for Strife: Veteran Edition
|
|
||||||
gamepath = gogregistrypath + L"\\1432899949";
|
|
||||||
if (QueryPathKey(HKEY_LOCAL_MACHINE, gamepath.c_str(), L"Path", path))
|
|
||||||
{
|
|
||||||
result.Push(path); // directly in install folder
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
// I_GetSteamPath
|
|
||||||
//
|
|
||||||
// Check the registry for the path to Steam, so that we can search for
|
|
||||||
// IWADs that were bought with Steam.
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
TArray<FString> I_GetSteamPath()
|
|
||||||
{
|
|
||||||
TArray<FString> result;
|
|
||||||
static const char *const steam_dirs[] =
|
|
||||||
{
|
|
||||||
"doom 2/base",
|
|
||||||
"final doom/base",
|
|
||||||
"heretic shadow of the serpent riders/base",
|
|
||||||
"hexen/base",
|
|
||||||
"hexen deathkings of the dark citadel/base",
|
|
||||||
"ultimate doom/base",
|
|
||||||
"DOOM 3 BFG Edition/base/wads",
|
|
||||||
"Strife"
|
|
||||||
};
|
|
||||||
|
|
||||||
FString path;
|
|
||||||
|
|
||||||
if (!QueryPathKey(HKEY_CURRENT_USER, L"Software\\Valve\\Steam", L"SteamPath", path))
|
|
||||||
{
|
|
||||||
if (!QueryPathKey(HKEY_LOCAL_MACHINE, L"Software\\Valve\\Steam", L"InstallPath", path))
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
path += "/SteamApps/common/";
|
|
||||||
|
|
||||||
for(unsigned int i = 0; i < countof(steam_dirs); ++i)
|
|
||||||
{
|
|
||||||
result.Push(path + steam_dirs[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// I_MakeRNGSeed
|
// I_MakeRNGSeed
|
||||||
|
@ -1294,35 +1155,34 @@ void I_SetThreadNumaNode(std::thread &thread, int numaNode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifndef KEY_WOW64_64KEY
|
//==========================================================================
|
||||||
# define KEY_WOW64_64KEY 0x0100
|
//
|
||||||
# endif
|
// QueryPathKey
|
||||||
# ifndef KEY_WOW64_32KEY
|
//
|
||||||
# define KEY_WOW64_32KEY 0x0200
|
// Returns the value of a registry key into the output variable value.
|
||||||
# endif
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
int I_ReadRegistryValue(char const * const SubKey, char const * const Value, char * const Output, size_t * OutputSize)
|
bool I_QueryPathKey(const wchar_t* keypath, const wchar_t* valname, FString& value)
|
||||||
{
|
{
|
||||||
// KEY_WOW64_32KEY gets us around Wow6432Node on 64-bit builds
|
HKEY pathkey;
|
||||||
REGSAM const wow64keys[] = { KEY_WOW64_32KEY, KEY_WOW64_64KEY };
|
DWORD pathtype;
|
||||||
|
DWORD pathlen;
|
||||||
|
LONG res;
|
||||||
|
|
||||||
for (auto &wow64key : wow64keys)
|
value = "";
|
||||||
|
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, keypath, 0, KEY_QUERY_VALUE, &pathkey))
|
||||||
{
|
{
|
||||||
HKEY hkey;
|
if (ERROR_SUCCESS == RegQueryValueEx(pathkey, valname, 0, &pathtype, NULL, &pathlen) &&
|
||||||
LONG keygood = RegOpenKeyEx(HKEY_LOCAL_MACHINE, NULL, 0, KEY_READ | wow64key, &hkey);
|
pathtype == REG_SZ && pathlen != 0)
|
||||||
|
{
|
||||||
if (keygood != ERROR_SUCCESS)
|
// Don't include terminating null in count
|
||||||
continue;
|
TArray<wchar_t> chars(pathlen + 1, true);
|
||||||
|
res = RegQueryValueEx(pathkey, valname, 0, NULL, (LPBYTE)chars.Data(), &pathlen);
|
||||||
DWORD os = 0;
|
if (res == ERROR_SUCCESS) value = FString(chars.Data());
|
||||||
LONG retval = SHGetValueA(hkey, SubKey, Value, NULL, Output, &os);
|
}
|
||||||
*OutputSize = os;
|
RegCloseKey(pathkey);
|
||||||
|
}
|
||||||
RegCloseKey(hkey);
|
return value.IsNotEmpty();
|
||||||
|
|
||||||
if (retval == ERROR_SUCCESS)
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
|
@ -153,7 +153,6 @@ inline int I_FindAttr(findstate_t *fileinfo)
|
||||||
int I_GetNumaNodeCount();
|
int I_GetNumaNodeCount();
|
||||||
int I_GetNumaNodeThreadCount(int numaNode);
|
int I_GetNumaNodeThreadCount(int numaNode);
|
||||||
void I_SetThreadNumaNode(std::thread &thread, int numaNode);
|
void I_SetThreadNumaNode(std::thread &thread, int numaNode);
|
||||||
|
bool I_QueryPathKey(const wchar_t* keypath, const wchar_t* valname, FString& value);
|
||||||
int I_ReadRegistryValue(char const * const SubKey, char const * const Value, char * const Output, size_t * OutputSize);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue