From fd76af637f7c0661d0e40ff1e4702646d5ac7c54 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Tue, 2 Sep 2025 15:39:17 +0100 Subject: [PATCH] Move online store defines closer to where they're used It makes little sense to centralise the definitions for things like Steam, GoG, etc.. These paths are only useful in the case where the user has derived the data from such a store, has installed ioq3 in a separate location, and we want it do be able to find said data. If a derivative project has deployed (binaries and all) on e.g. Steam then for them fs_basepath will already be correct, and fs_steampath is not useful. --- code/qcommon/q_shared.h | 6 ----- code/sys/sys_win32.c | 57 ++++++++++++++++++++++++----------------- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/code/qcommon/q_shared.h b/code/qcommon/q_shared.h index d7ede8af..cc39c361 100644 --- a/code/qcommon/q_shared.h +++ b/code/qcommon/q_shared.h @@ -34,8 +34,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define HOMEPATH_NAME_UNIX ".foo" #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 CINEMATICS_LOGO "foologo.roq" #define CINEMATICS_INTRO "intro.roq" @@ -49,10 +47,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define HOMEPATH_NAME_UNIX ".q3a" #define HOMEPATH_NAME_WIN "Quake3" #define HOMEPATH_NAME_MACOSX HOMEPATH_NAME_WIN - #define STEAMPATH_NAME "Quake 3 Arena" - #define STEAMPATH_APPID "2200" - #define GOGPATH_ID "1441704920" - #define MSSTORE_PATH "Quake 3" #define GAMENAME_FOR_MASTER "Quake3Arena" #define CINEMATICS_LOGO "idlogo.RoQ" #define CINEMATICS_INTRO "intro.RoQ" diff --git a/code/sys/sys_win32.c b/code/sys/sys_win32.c index d67c0716..59230c56 100644 --- a/code/sys/sys_win32.c +++ b/code/sys/sys_win32.c @@ -46,18 +46,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define KEY_WOW64_32KEY 0x0200 #endif -// Used to determine where to store user-specific files -static char homePath[ MAX_OSPATH ] = { 0 }; - -// Used to store the Steam Quake 3 installation path -static char steamPath[ MAX_OSPATH ] = { 0 }; - -// Used to store the GOG Quake 3 installation path -static char gogPath[ MAX_OSPATH ] = { 0 }; - -// Used to store the Microsoft Store Quake 3 installation path -static char microsoftStorePath[MAX_OSPATH] = { 0 }; - #ifndef DEDICATED static UINT timerResolution = 0; #endif @@ -102,10 +90,11 @@ Sys_DefaultHomePath */ char *Sys_DefaultHomePath( void ) { - TCHAR szPath[MAX_PATH]; + static char homePath[ MAX_OSPATH ] = { 0 }; if(!*homePath && com_homepath) { + TCHAR szPath[MAX_PATH]; if( !SUCCEEDED( SHGetFolderPathA( NULL, CSIDL_APPDATA, NULL, 0, szPath ) ) ) @@ -132,14 +121,20 @@ Sys_SteamPath */ char *Sys_SteamPath( void ) { -#if defined(STEAMPATH_NAME) || defined(STEAMPATH_APPID) +#ifndef STANDALONE + +#define STEAMPATH_NAME "Quake 3 Arena" +#define STEAMPATH_APPID "2200" + + static char steamPath[ MAX_OSPATH ] = { 0 }; + HKEY steamRegKey; DWORD pathLen = MAX_OSPATH; qboolean finishPath = qfalse; -#ifdef STEAMPATH_APPID // Assuming Steam is a 32-bit app - if (!steamPath[0] && !RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App " STEAMPATH_APPID, 0, KEY_QUERY_VALUE | KEY_WOW64_32KEY, &steamRegKey)) + if (!steamPath[0] && !RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App " + STEAMPATH_APPID, 0, KEY_QUERY_VALUE | KEY_WOW64_32KEY, &steamRegKey)) { pathLen = MAX_OSPATH; if (RegQueryValueEx(steamRegKey, "InstallLocation", NULL, NULL, (LPBYTE)steamPath, &pathLen)) @@ -147,9 +142,7 @@ char *Sys_SteamPath( void ) RegCloseKey(steamRegKey); } -#endif -#ifdef STEAMPATH_NAME if (!steamPath[0] && !RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Valve\\Steam", 0, KEY_QUERY_VALUE, &steamRegKey)) { pathLen = MAX_OSPATH; @@ -162,7 +155,6 @@ char *Sys_SteamPath( void ) RegCloseKey(steamRegKey); } -#endif if (steamPath[0]) { @@ -174,9 +166,11 @@ char *Sys_SteamPath( void ) if (finishPath) Q_strcat(steamPath, MAX_OSPATH, "\\SteamApps\\common\\" STEAMPATH_NAME ); } -#endif return steamPath; +#else + return ""; +#endif } /* @@ -186,7 +180,12 @@ Sys_GogPath */ char *Sys_GogPath( void ) { -#ifdef GOGPATH_ID +#ifndef STANDALONE + +#define GOGPATH_ID "1441704920" + + static char gogPath[ MAX_OSPATH ] = { 0 }; + HKEY gogRegKey; DWORD pathLen = MAX_OSPATH; @@ -206,9 +205,11 @@ char *Sys_GogPath( void ) gogPath[pathLen] = '\0'; } -#endif return gogPath; +#else + return ""; +#endif } /* @@ -218,7 +219,12 @@ Sys_MicrosoftStorePath */ char* Sys_MicrosoftStorePath(void) { -#ifdef MSSTORE_PATH +#ifndef STANDALONE + +#define MSSTORE_PATH "Quake 3" + + static char microsoftStorePath[MAX_OSPATH] = { 0 }; + if (!microsoftStorePath[0]) { TCHAR szPath[MAX_PATH]; @@ -233,8 +239,11 @@ char* Sys_MicrosoftStorePath(void) // default: C:\Program Files\ModifiableWindowsApps\Quake 3\EN Com_sprintf(microsoftStorePath, sizeof(microsoftStorePath), "%s%cModifiableWindowsApps%c%s%cEN", szPath, PATH_SEP, PATH_SEP, MSSTORE_PATH, PATH_SEP); } -#endif + return microsoftStorePath; +#else + return ""; +#endif } /*