Use Windows uninstall path to find Steam Quake 3 install.

Thanks Pan- and Ensiform for pointing this out.
This commit is contained in:
SmileTheory 2015-09-25 04:55:41 -07:00
parent 3bd7a8d842
commit 2f77a98afe
2 changed files with 36 additions and 11 deletions

View file

@ -35,6 +35,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define HOMEPATH_NAME_WIN "FooBar" #define HOMEPATH_NAME_WIN "FooBar"
#define HOMEPATH_NAME_MACOSX HOMEPATH_NAME_WIN #define HOMEPATH_NAME_MACOSX HOMEPATH_NAME_WIN
// #define STEAMPATH_NAME "Foo Bar" // #define STEAMPATH_NAME "Foo Bar"
// #define STEAMPATH_APPID ""
#define GAMENAME_FOR_MASTER "foobar" // must NOT contain whitespace #define GAMENAME_FOR_MASTER "foobar" // must NOT contain whitespace
// #define LEGACY_PROTOCOL // You probably don't need this for your standalone game // #define LEGACY_PROTOCOL // You probably don't need this for your standalone game
#else #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_WIN "Quake3"
#define HOMEPATH_NAME_MACOSX HOMEPATH_NAME_WIN #define HOMEPATH_NAME_MACOSX HOMEPATH_NAME_WIN
#define STEAMPATH_NAME "Quake 3 Arena" #define STEAMPATH_NAME "Quake 3 Arena"
#define STEAMPATH_APPID "2200"
#define GAMENAME_FOR_MASTER "Quake3Arena" #define GAMENAME_FOR_MASTER "Quake3Arena"
#define LEGACY_PROTOCOL #define LEGACY_PROTOCOL
#endif #endif

View file

@ -136,29 +136,52 @@ Sys_SteamPath
*/ */
char *Sys_SteamPath( void ) char *Sys_SteamPath( void )
{ {
#ifdef STEAMPATH_NAME #if defined(STEAMPATH_NAME) || defined(STEAMPATH_APPID)
HKEY steamRegKey; 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, "SteamPath", NULL, NULL, (LPBYTE)steamPath, &pathLen))
if (RegQueryValueEx(steamRegKey, "InstallPath", NULL, NULL, (LPBYTE)steamPath, &pathLen)) if (RegQueryValueEx(steamRegKey, "InstallPath", NULL, NULL, (LPBYTE)steamPath, &pathLen))
steamPath[0] = '\0'; steamPath[0] = '\0';
if (steamPath[0]) if (steamPath[0])
{ finishPath = qtrue;
if (pathLen == MAX_OSPATH)
pathLen--;
steamPath[pathLen] = '\0';
Q_strcat(steamPath, MAX_OSPATH, "\\SteamApps\\common\\" STEAMPATH_NAME );
}
} }
#endif #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; return steamPath;
} }