From 2f77a98afee2daf6de9a7e2d304e52e15c40510b Mon Sep 17 00:00:00 2001 From: SmileTheory Date: Fri, 25 Sep 2015 04:55:41 -0700 Subject: [PATCH] Use Windows uninstall path to find Steam Quake 3 install. Thanks Pan- and Ensiform for pointing this out. --- code/qcommon/q_shared.h | 2 ++ code/sys/sys_win32.c | 45 +++++++++++++++++++++++++++++++---------- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/code/qcommon/q_shared.h b/code/qcommon/q_shared.h index 8f82348f..1baa3e1b 100644 --- a/code/qcommon/q_shared.h +++ b/code/qcommon/q_shared.h @@ -35,6 +35,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define HOMEPATH_NAME_WIN "FooBar" #define HOMEPATH_NAME_MACOSX HOMEPATH_NAME_WIN // #define STEAMPATH_NAME "Foo Bar" +// #define STEAMPATH_APPID "" #define GAMENAME_FOR_MASTER "foobar" // must NOT contain whitespace // #define LEGACY_PROTOCOL // You probably don't need this for your standalone game #else @@ -46,6 +47,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define HOMEPATH_NAME_WIN "Quake3" #define HOMEPATH_NAME_MACOSX HOMEPATH_NAME_WIN #define STEAMPATH_NAME "Quake 3 Arena" + #define STEAMPATH_APPID "2200" #define GAMENAME_FOR_MASTER "Quake3Arena" #define LEGACY_PROTOCOL #endif diff --git a/code/sys/sys_win32.c b/code/sys/sys_win32.c index 4c08ef7a..4771e390 100644 --- a/code/sys/sys_win32.c +++ b/code/sys/sys_win32.c @@ -136,29 +136,52 @@ Sys_SteamPath */ char *Sys_SteamPath( void ) { -#ifdef STEAMPATH_NAME +#if defined(STEAMPATH_NAME) || defined(STEAMPATH_APPID) HKEY steamRegKey; + DWORD pathLen = MAX_OSPATH; + qboolean finishPath = qfalse; +#endif - if (!RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Valve\\Steam", 0, KEY_QUERY_VALUE, &steamRegKey)) +#ifdef STEAMPATH_APPID + if (!steamPath[0] && !RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App " STEAMPATH_APPID, 0, KEY_QUERY_VALUE, &steamRegKey)) { - DWORD pathLen = MAX_OSPATH; + pathLen = MAX_OSPATH; + if (RegQueryValueEx(steamRegKey, "InstallLocation", NULL, NULL, (LPBYTE)steamPath, &pathLen)) + steamPath[0] = '\0'; + } + if (!steamPath[0] && !RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App " STEAMPATH_APPID, 0, KEY_QUERY_VALUE, &steamRegKey)) + { + pathLen = MAX_OSPATH; + if (RegQueryValueEx(steamRegKey, "InstallLocation", NULL, NULL, (LPBYTE)steamPath, &pathLen)) + steamPath[0] = '\0'; + } +#endif + +#ifdef STEAMPATH_NAME + if (!steamPath[0] && !RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Valve\\Steam", 0, KEY_QUERY_VALUE, &steamRegKey)) + { + pathLen = MAX_OSPATH; if (RegQueryValueEx(steamRegKey, "SteamPath", NULL, NULL, (LPBYTE)steamPath, &pathLen)) if (RegQueryValueEx(steamRegKey, "InstallPath", NULL, NULL, (LPBYTE)steamPath, &pathLen)) steamPath[0] = '\0'; if (steamPath[0]) - { - if (pathLen == MAX_OSPATH) - pathLen--; - - steamPath[pathLen] = '\0'; - - Q_strcat(steamPath, MAX_OSPATH, "\\SteamApps\\common\\" STEAMPATH_NAME ); - } + finishPath = qtrue; } #endif + if (steamPath[0]) + { + if (pathLen == MAX_OSPATH) + pathLen--; + + steamPath[pathLen] = '\0'; + + if (finishPath) + Q_strcat(steamPath, MAX_OSPATH, "\\SteamApps\\common\\" STEAMPATH_NAME ); + } + return steamPath; }