From ea10e01cc333de4c68020280aa34a8ac7c57a3f9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 30 Oct 2019 18:27:52 +0100 Subject: [PATCH] - adjustments for last commit. --- source/common/i_specialpaths.h | 3 --- source/common/searchpaths.cpp | 34 ++++++++++++------------ source/platform/win32/i_specialpaths.cpp | 31 --------------------- 3 files changed, 17 insertions(+), 51 deletions(-) diff --git a/source/common/i_specialpaths.h b/source/common/i_specialpaths.h index 092c7f47f..7c51bae37 100644 --- a/source/common/i_specialpaths.h +++ b/source/common/i_specialpaths.h @@ -12,9 +12,6 @@ FString M_GetScreenshotsPath(); FString M_GetSavegamesPath(); FString M_GetDocumentsPath(); -#ifdef _WIN32 -int ReadRegistryValue(char const* const SubKey, char const* const Value, char* const Output, unsigned long* OutputSize); -#endif #ifdef __APPLE__ FString M_GetMacAppSupportPath(const bool create = true); diff --git a/source/common/searchpaths.cpp b/source/common/searchpaths.cpp index d34d10a11..9686b0a07 100644 --- a/source/common/searchpaths.cpp +++ b/source/common/searchpaths.cpp @@ -34,6 +34,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "sc_man.h" #include "resourcefile.h" #include "printf.h" +#include "common.h" #include "gamecontrol.h" @@ -201,8 +202,8 @@ void G_AddExternalSearchPaths(TArray &searchpaths) } } -#elif defined (_WIN32) - +#endif +#else //------------------------------------------------------------------------- // // @@ -217,14 +218,14 @@ void G_AddExternalSearchPaths(TArray &searchpaths) // Duke Nukem 3D: 20th Anniversary World Tour (Steam) bufsize = sizeof(buf); - if (ReadRegistryValue(R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 434050)", "InstallLocation", buf, &bufsize)) + if (Paths_ReadRegistryValue(R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 434050)", "InstallLocation", buf, &bufsize)) { AddSearchPath(searchpaths, buf); } // Duke Nukem 3D: Megaton Edition (Steam) bufsize = sizeof(buf); - if (ReadRegistryValue(R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 225140)", "InstallLocation", buf, &bufsize)) + if (Paths_ReadRegistryValue(R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 225140)", "InstallLocation", buf, &bufsize)) { char * const suffix = buf + bufsize - 1; size_t const remaining = sizeof(buf) - bufsize; @@ -241,7 +242,7 @@ void G_AddExternalSearchPaths(TArray &searchpaths) // Duke Nukem 3D (3D Realms Anthology (Steam) / Kill-A-Ton Collection 2015) bufsize = sizeof(buf); - if (ReadRegistryValue(R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 359850)", "InstallLocation", buf, &bufsize)) + if (Paths_ReadRegistryValue(R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 359850)", "InstallLocation", buf, &bufsize)) { char * const suffix = buf + bufsize - 1; size_t const remaining = sizeof(buf) - bufsize; @@ -252,14 +253,14 @@ void G_AddExternalSearchPaths(TArray &searchpaths) // Duke Nukem 3D: Atomic Edition (GOG.com) bufsize = sizeof(buf); - if (ReadRegistryValue("SOFTWARE\\GOG.com\\GOGDUKE3D", "PATH", buf, &bufsize)) + if (Paths_ReadRegistryValue("SOFTWARE\\GOG.com\\GOGDUKE3D", "PATH", buf, &bufsize)) { AddSearchPath(searchpaths, buf); } // Duke Nukem 3D (3D Realms Anthology) bufsize = sizeof(buf); - if (ReadRegistryValue("SOFTWARE\\3DRealms\\Duke Nukem 3D", NULL, buf, &bufsize)) + if (Paths_ReadRegistryValue("SOFTWARE\\3DRealms\\Duke Nukem 3D", NULL, buf, &bufsize)) { char * const suffix = buf + bufsize - 1; size_t const remaining = sizeof(buf) - bufsize; @@ -270,7 +271,7 @@ void G_AddExternalSearchPaths(TArray &searchpaths) // 3D Realms Anthology bufsize = sizeof(buf); - if (ReadRegistryValue("SOFTWARE\\3DRealms\\Anthology", NULL, buf, &bufsize)) + if (Paths_ReadRegistryValue("SOFTWARE\\3DRealms\\Anthology", NULL, buf, &bufsize)) { char * const suffix = buf + bufsize - 1; size_t const remaining = sizeof(buf) - bufsize; @@ -281,7 +282,7 @@ void G_AddExternalSearchPaths(TArray &searchpaths) // NAM (Steam) bufsize = sizeof(buf); - if (ReadRegistryValue(R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 329650)", "InstallLocation", buf, &bufsize)) + if (Paths_ReadRegistryValue(R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 329650)", "InstallLocation", buf, &bufsize)) { char * const suffix = buf + bufsize - 1; size_t const remaining = sizeof(buf) - bufsize; @@ -292,7 +293,7 @@ void G_AddExternalSearchPaths(TArray &searchpaths) // WWII GI (Steam) bufsize = sizeof(buf); - if (ReadRegistryValue(R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 376750)", "InstallLocation", buf, &bufsize)) + if (Paths_ReadRegistryValue(R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 376750)", "InstallLocation", buf, &bufsize)) { char * const suffix = buf + bufsize - 1; size_t const remaining = sizeof(buf) - bufsize; @@ -303,35 +304,35 @@ void G_AddExternalSearchPaths(TArray &searchpaths) // Redneck Rampage (GOG.com) bufsize = sizeof(buf); - if (ReadRegistryValue("SOFTWARE\\GOG.com\\GOGREDNECKRAMPAGE", "PATH", buf, &bufsize)) + if (Paths_ReadRegistryValue("SOFTWARE\\GOG.com\\GOGREDNECKRAMPAGE", "PATH", buf, &bufsize)) { AddSearchPath(searchpaths, buf); } // Redneck Rampage Rides Again (GOG.com) bufsize = sizeof(buf); - if (ReadRegistryValue("SOFTWARE\\GOG.com\\GOGCREDNECKRIDESAGAIN", "PATH", buf, &bufsize)) + if (Paths_ReadRegistryValue("SOFTWARE\\GOG.com\\GOGCREDNECKRIDESAGAIN", "PATH", buf, &bufsize)) { AddSearchPath(searchpaths, buf); } // Blood: One Unit Whole Blood (Steam) bufsize = sizeof(buf); - if (ReadRegistryValue(R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 299030)", "InstallLocation", buf, &bufsize)) + if (Paths_ReadRegistryValue(R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 299030)", "InstallLocation", buf, &bufsize)) { AddSearchPath(searchpaths, buf); } // Blood: One Unit Whole Blood (GOG.com) bufsize = sizeof(buf); - if (ReadRegistryValue("SOFTWARE\\GOG.com\\GOGONEUNITONEBLOOD", "PATH", buf, &bufsize)) + if (Paths_ReadRegistryValue("SOFTWARE\\GOG.com\\GOGONEUNITONEBLOOD", "PATH", buf, &bufsize)) { AddSearchPath(searchpaths, buf); } // Blood: Fresh Supply (Steam) bufsize = sizeof(buf); - if (ReadRegistryValue(R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 1010750)", "InstallLocation", buf, &bufsize)) + if (Paths_ReadRegistryValue(R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 1010750)", "InstallLocation", buf, &bufsize)) { AddSearchPath(searchpaths, buf); strncat(buf, R"(\addons\Cryptic Passage)", 23); @@ -340,7 +341,7 @@ void G_AddExternalSearchPaths(TArray &searchpaths) // Blood: Fresh Supply (GOG.com) bufsize = sizeof(buf); - if (ReadRegistryValue(R"(SOFTWARE\Wow6432Node\GOG.com\Games\1374469660)", "path", buf, &bufsize)) + if (Paths_ReadRegistryValue(R"(SOFTWARE\Wow6432Node\GOG.com\Games\1374469660)", "path", buf, &bufsize)) { AddSearchPath(searchpaths, buf); strncat(buf, R"(\addons\Cryptic Passage)", 23); @@ -349,7 +350,6 @@ void G_AddExternalSearchPaths(TArray &searchpaths) } #endif - //========================================================================== // // diff --git a/source/platform/win32/i_specialpaths.cpp b/source/platform/win32/i_specialpaths.cpp index 466972856..cd8a88569 100644 --- a/source/platform/win32/i_specialpaths.cpp +++ b/source/platform/win32/i_specialpaths.cpp @@ -336,34 +336,3 @@ FString M_GetDocumentsPath() return path; } -//=========================================================================== -// -// ReadRegistryValue Windows -// -// Reads a value from the registry -// -//=========================================================================== - -int ReadRegistryValue(char const* const SubKey, char const* const Value, char* const Output, unsigned long* OutputSize) -{ - // KEY_WOW64_32KEY gets us around Wow6432Node on 64-bit builds - REGSAM const wow64keys[] = { KEY_WOW64_32KEY, KEY_WOW64_64KEY }; - - for (auto& wow64key : wow64keys) - { - HKEY hkey; - LONG keygood = RegOpenKeyExA(HKEY_LOCAL_MACHINE, NULL, 0, KEY_READ | wow64key, &hkey); - - if (keygood != ERROR_SUCCESS) - continue; - - LONG retval = SHGetValueA(hkey, SubKey, Value, NULL, Output, OutputSize); - - RegCloseKey(hkey); - - if (retval == ERROR_SUCCESS) - return 1; - } - - return 0; -}