mirror of
https://github.com/bearstonem/openmohaa-vr.git
synced 2026-10-28 13:00:37 +01:00
Reduce duplication in FS path search code
Co-authored-by: smallmodel <15067410+smallmodel@users.noreply.github.com>
This commit is contained in:
1 parent
eb6b6173ee
commit
e299031470
12 files changed
+347
-383
No files matched your search
+6
-31
@@ -45,18 +45,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
qboolean stdinIsATTY;
|
||||
|
||||
// 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 };
|
||||
|
||||
/*
|
||||
==================
|
||||
Sys_DefaultHomePath
|
||||
@@ -64,6 +52,7 @@ Sys_DefaultHomePath
|
||||
*/
|
||||
char *Sys_DefaultHomePath(void)
|
||||
{
|
||||
static char homePath[ MAX_OSPATH ] = { 0 };
|
||||
char *p;
|
||||
|
||||
if( !*homePath && com_homepath != NULL )
|
||||
@@ -130,22 +119,8 @@ Sys_SteamPath
|
||||
*/
|
||||
char *Sys_SteamPath( void )
|
||||
{
|
||||
// Disabled since Steam doesn't let you install Quake 3 on Mac/Linux
|
||||
#if 0 //#ifdef STEAMPATH_NAME
|
||||
char *p;
|
||||
|
||||
if( ( p = getenv( "HOME" ) ) != NULL )
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
char *steamPathEnd = "/Library/Application Support/Steam/SteamApps/common/" STEAMPATH_NAME;
|
||||
#else
|
||||
char *steamPathEnd = "/.steam/steam/SteamApps/common/" STEAMPATH_NAME;
|
||||
#endif
|
||||
Com_sprintf(steamPath, sizeof(steamPath), "%s%s", p, steamPathEnd);
|
||||
}
|
||||
#endif
|
||||
|
||||
return steamPath;
|
||||
// Steam doesn't let you install Quake 3 on Mac/Linux
|
||||
return "";
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -155,8 +130,8 @@ Sys_GogPath
|
||||
*/
|
||||
char *Sys_GogPath( void )
|
||||
{
|
||||
// GOG also doesn't let you install Quake 3 on Mac/Linux
|
||||
return gogPath;
|
||||
// GOG doesn't let you install Quake 3 on Mac/Linux
|
||||
return "";
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -167,7 +142,7 @@ Sys_MicrosoftStorePath
|
||||
char* Sys_MicrosoftStorePath(void)
|
||||
{
|
||||
// Microsoft Store doesn't exist on Mac/Linux
|
||||
return microsoftStorePath;
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
+33
-24
@@ -48,18 +48,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
|
||||
@@ -104,10 +92,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 ) ) )
|
||||
@@ -134,14 +123,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))
|
||||
@@ -149,9 +144,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;
|
||||
@@ -164,7 +157,6 @@ char *Sys_SteamPath( void )
|
||||
|
||||
RegCloseKey(steamRegKey);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (steamPath[0])
|
||||
{
|
||||
@@ -176,9 +168,11 @@ char *Sys_SteamPath( void )
|
||||
if (finishPath)
|
||||
Q_strcat(steamPath, MAX_OSPATH, "\\SteamApps\\common\\" STEAMPATH_NAME );
|
||||
}
|
||||
#endif
|
||||
|
||||
return steamPath;
|
||||
#else
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -188,7 +182,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;
|
||||
|
||||
@@ -208,9 +207,11 @@ char *Sys_GogPath( void )
|
||||
|
||||
gogPath[pathLen] = '\0';
|
||||
}
|
||||
#endif
|
||||
|
||||
return gogPath;
|
||||
#else
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -220,7 +221,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];
|
||||
@@ -235,8 +241,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
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in new issue
Block a user