[iortcw] 400/497: All: Some more Steam path merges

Simon McVittie smcv at debian.org
Fri Sep 8 10:37:36 UTC 2017


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to annotated tag 1.42d
in repository iortcw.

commit 4d684f960b4f232f141f250f928f662aa60d2259
Author: MAN-AT-ARMS <M4N4T4RMS at gmail.com>
Date:   Fri Sep 25 12:33:32 2015 -0400

    All: Some more Steam path merges
---
 MP/code/qcommon/files.c    | 41 ++++++++++++++++++++++++++++++++++++++---
 MP/code/qcommon/q_shared.h |  2 ++
 MP/code/qcommon/qcommon.h  |  2 +-
 MP/code/sys/sys_unix.c     |  4 ++--
 MP/code/sys/sys_win32.c    | 43 ++++++++++++++++++++++++++++++++++---------
 SP/code/qcommon/files.c    | 40 +++++++++++++++++++++++++++++++++++++---
 SP/code/qcommon/q_shared.h |  2 ++
 SP/code/qcommon/qcommon.h  |  2 +-
 SP/code/sys/sys_unix.c     |  4 ++--
 SP/code/sys/sys_win32.c    | 43 ++++++++++++++++++++++++++++++++++---------
 10 files changed, 153 insertions(+), 30 deletions(-)

diff --git a/MP/code/qcommon/files.c b/MP/code/qcommon/files.c
index a53944d..cce9ddb 100644
--- a/MP/code/qcommon/files.c
+++ b/MP/code/qcommon/files.c
@@ -252,7 +252,7 @@ static cvar_t      *fs_homepath;
 static  cvar_t          *fs_apppath;
 #endif
 
-#ifdef STEAMPATH_NAME
+#ifndef STANDALONE
 static	cvar_t		*fs_steampath;
 #endif
 
@@ -755,7 +755,7 @@ long FS_SV_FOpenFileRead( const char *filename, fileHandle_t *fp ) {
 			fsh[f].handleSync = qfalse;
 		}
 
-#ifdef STEAMPATH_NAME
+#ifndef STANDALONE
 		// Check fs_steampath too
 		if (!fsh[f].handleFiles.file.o && fs_steampath->string[0])
 		{
@@ -2739,6 +2739,11 @@ int	FS_GetModList( char *listbuf, int bufsize ) {
 	int dummy;
 	char **pFiles0 = NULL;
 	char **pFiles1 = NULL;
+#ifndef STANDALONE
+	char **pFiles2 = NULL;
+	char **pFiles3 = NULL;
+#endif
+
 	qboolean bDrop = qfalse;
 
 	*listbuf = 0;
@@ -2746,9 +2751,18 @@ int	FS_GetModList( char *listbuf, int bufsize ) {
 
 	pFiles0 = Sys_ListFiles( fs_homepath->string, NULL, NULL, &dummy, qtrue );
 	pFiles1 = Sys_ListFiles( fs_basepath->string, NULL, NULL, &dummy, qtrue );
+#ifndef STANDALONE
+	pFiles2 = Sys_ListFiles( fs_steampath->string, NULL, NULL, &dummy, qtrue );
+#endif
 	// we searched for mods in the three paths
 	// it is likely that we have duplicate names now, which we will cleanup below
+#ifndef STANDALONE
+	pFiles3 = Sys_ConcatenateFileLists( pFiles0, pFiles1 );
+	pFiles = Sys_ConcatenateFileLists( pFiles2, pFiles3 );
+#else
 	pFiles = Sys_ConcatenateFileLists( pFiles0, pFiles1 );
+#endif
+
 	nPotential = Sys_CountFileList(pFiles);
 
 	for ( i = 0 ; i < nPotential ; i++ ) {
@@ -2790,6 +2804,17 @@ int	FS_GetModList( char *listbuf, int bufsize ) {
 				Sys_FreeFileList( pPaks );
 			}
 
+#ifndef STANDALONE
+			/* try on steam path */
+			if ( nPaks <= 0 )
+			{
+				path = FS_BuildOSPath( fs_steampath->string, name, "" );
+				nPaks = 0;
+				pPaks = Sys_ListFiles( path, ".pk3", NULL, &nPaks, qfalse );
+				Sys_FreeFileList( pPaks );
+			}
+#endif
+
 			if (nPaks > 0) {
 				nLen = strlen(name) + 1;
 				// nLen is the length of the mod path
@@ -3487,7 +3512,7 @@ static void FS_Startup( const char *gameName ) {
 	fs_gamedirvar = Cvar_Get( "fs_game", "", CVAR_INIT | CVAR_SYSTEMINFO );
 
 	// add search path elements in reverse priority order
-#ifdef STEAMPATH_NAME
+#ifndef STANDALONE
 	fs_steampath = Cvar_Get ("fs_steampath", Sys_SteamPath(), CVAR_INIT|CVAR_PROTECTED );
 	if (fs_steampath->string[0]) {
 		FS_AddGameDirectory( fs_steampath->string, gameName, qtrue );
@@ -3513,6 +3538,11 @@ static void FS_Startup( const char *gameName ) {
 
 	// check for additional base game so mods can be based upon other mods
 	if ( fs_basegame->string[0] && Q_stricmp( fs_basegame->string, gameName ) ) {
+#ifndef STANDALONE
+		if (fs_steampath->string[0]) {
+			FS_AddGameDirectory(fs_steampath->string, fs_basegame->string, qtrue );
+		}
+#endif
 		if ( fs_basepath->string[0] ) {
 			FS_AddGameDirectory( fs_basepath->string, fs_basegame->string, qtrue );
 		}
@@ -3523,6 +3553,11 @@ static void FS_Startup( const char *gameName ) {
 
 	// check for additional game folder for mods
 	if ( fs_gamedirvar->string[0] && Q_stricmp( fs_gamedirvar->string, gameName ) ) {
+#ifndef STANDALONE
+		if (fs_steampath->string[0]) {
+			FS_AddGameDirectory(fs_steampath->string, fs_gamedirvar->string, qtrue );
+		}
+#endif
 		if ( fs_basepath->string[0] ) {
 			FS_AddGameDirectory( fs_basepath->string, fs_gamedirvar->string, qtrue );
 		}
diff --git a/MP/code/qcommon/q_shared.h b/MP/code/qcommon/q_shared.h
index ad3ebf2..b79983c 100644
--- a/MP/code/qcommon/q_shared.h
+++ b/MP/code/qcommon/q_shared.h
@@ -50,6 +50,7 @@ If you have questions concerning this license or the applicable additional terms
   #define HOMEPATH_NAME_UNIX		".foo"
   #define HOMEPATH_NAME_WIN		"FooBar"
 //  #define STEAMPATH_NAME		"Foo Bar"
+//  #define STEAMPATH_APPID		""
   #define HOMEPATH_NAME_MACOSX		HOMEPATH_NAME_WIN
   #define GAMENAME_FOR_MASTER		"foobar"	// must NOT contain whitespace
 // #define LEGACY_PROTOCOL	// You probably don't need this for your standalone game
@@ -62,6 +63,7 @@ If you have questions concerning this license or the applicable additional terms
   #define HOMEPATH_NAME_UNIX		".iortcw"
   #define HOMEPATH_NAME_WIN		"RTCW"
   #define STEAMPATH_NAME		"Return To Castle Wolfenstein"
+  #define STEAMPATH_APPID		"9010"
   #define HOMEPATH_NAME_MACOSX		HOMEPATH_NAME_WIN
   #define GAMENAME_FOR_MASTER		"wolfmp"
   #define LEGACY_PROTOCOL
diff --git a/MP/code/qcommon/qcommon.h b/MP/code/qcommon/qcommon.h
index c6dee66..2ba91bb 100644
--- a/MP/code/qcommon/qcommon.h
+++ b/MP/code/qcommon/qcommon.h
@@ -1230,7 +1230,7 @@ char    *Sys_Cwd( void );
 char    *Sys_DefaultBasePath( void );
 char    *Sys_DefaultInstallPath( void );
 
-#ifdef STEAMPATH_NAME
+#ifndef STANDALONE
 char    *Sys_SteamPath(void);
 #endif
 
diff --git a/MP/code/sys/sys_unix.c b/MP/code/sys/sys_unix.c
index 35bafd2..8558749 100644
--- a/MP/code/sys/sys_unix.c
+++ b/MP/code/sys/sys_unix.c
@@ -44,7 +44,7 @@ qboolean stdinIsATTY;
 // Used to determine where to store user-specific files
 static char homePath[ MAX_OSPATH ] = { 0 };
 
-#ifdef STEAMPATH_NAME
+#ifndef STANDALONE
 // Used to store the Steam RTCW installation path
 static char steamPath[ MAX_OSPATH ] = { 0 };
 #endif
@@ -83,7 +83,7 @@ char *Sys_DefaultHomePath(void)
 	return homePath;
 }
 
-#ifdef STEAMPATH_NAME
+#ifndef STANDALONE
 /*
 ================
 Sys_SteamPath
diff --git a/MP/code/sys/sys_win32.c b/MP/code/sys/sys_win32.c
index 9150993..1ae7b10 100644
--- a/MP/code/sys/sys_win32.c
+++ b/MP/code/sys/sys_win32.c
@@ -42,7 +42,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 // Used to determine where to store user-specific files
 static char homePath[ MAX_OSPATH ] = { 0 };
 
-#ifdef STEAMPATH_NAME
+#ifndef STANDALONE
 // Used to store the Steam RTCW installation path
 static char steamPath[ MAX_OSPATH ] = { 0 };
 #endif
@@ -132,7 +132,7 @@ char *Sys_DefaultHomePath( void )
 	return homePath;
 }
 
-#ifdef STEAMPATH_NAME
+#ifndef STANDALONE
 /*
 ================
 Sys_SteamPath
@@ -140,25 +140,50 @@ Sys_SteamPath
 */
 char *Sys_SteamPath( void )
 {
+#if defined(STEAMPATH_NAME) || defined(STEAMPATH_APPID)
 	HKEY steamRegKey;
+	DWORD pathLen = MAX_OSPATH;
+	qboolean finishPath = qfalse;
+#endif
+
+#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))
+	{
+		pathLen = MAX_OSPATH;
+		if (RegQueryValueEx(steamRegKey, "InstallLocation", NULL, NULL, (LPBYTE)steamPath, &pathLen))
+			steamPath[0] = '\0';
+	}
 
-	if (!RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Valve\\Steam", 0, KEY_QUERY_VALUE, &steamRegKey))
+	if (!steamPath[0] && !RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\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';
+	}
+#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--;
+			finishPath = qtrue;
+	}
+#endif
+
+	if (steamPath[0])
+	{
+		if (pathLen == MAX_OSPATH)
+			pathLen--;
 
-			steamPath[pathLen] = '\0';
+		steamPath[pathLen] = '\0';
 
+		if (finishPath)
 			Q_strcat(steamPath, MAX_OSPATH, "\\SteamApps\\common\\" STEAMPATH_NAME );
-		}
 	}
 
 	return steamPath;
diff --git a/SP/code/qcommon/files.c b/SP/code/qcommon/files.c
index 65639e6..48bdae1 100644
--- a/SP/code/qcommon/files.c
+++ b/SP/code/qcommon/files.c
@@ -255,7 +255,7 @@ static cvar_t      *fs_homepath;
 static  cvar_t          *fs_apppath;
 #endif
 
-#ifdef STEAMPATH_NAME
+#ifndef STANDALONE
 static	cvar_t		*fs_steampath;
 #endif
 
@@ -862,7 +862,7 @@ long FS_SV_FOpenFileRead(const char *filename, fileHandle_t *fp)
 			fsh[f].handleSync = qfalse;
 		}
 
-#ifdef STEAMPATH_NAME
+#ifndef STANDALONE
 		// Check fs_steampath too
 		if (!fsh[f].handleFiles.file.o && fs_steampath->string[0])
 		{
@@ -2744,6 +2744,10 @@ int	FS_GetModList( char *listbuf, int bufsize ) {
 	int dummy;
 	char **pFiles0 = NULL;
 	char **pFiles1 = NULL;
+#ifndef STANDALONE
+	char **pFiles2 = NULL;
+	char **pFiles3 = NULL;
+#endif
 	qboolean bDrop = qfalse;
 
 	*listbuf = 0;
@@ -2751,9 +2755,18 @@ int	FS_GetModList( char *listbuf, int bufsize ) {
 
 	pFiles0 = Sys_ListFiles( fs_homepath->string, NULL, NULL, &dummy, qtrue );
 	pFiles1 = Sys_ListFiles( fs_basepath->string, NULL, NULL, &dummy, qtrue );
+#ifndef STANDALONE
+	pFiles2 = Sys_ListFiles( fs_steampath->string, NULL, NULL, &dummy, qtrue );
+#endif
 	// we searched for mods in the three paths
 	// it is likely that we have duplicate names now, which we will cleanup below
+#ifndef STANDALONE
+	pFiles3 = Sys_ConcatenateFileLists( pFiles0, pFiles1 );
+	pFiles = Sys_ConcatenateFileLists( pFiles2, pFiles3 );
+#else
 	pFiles = Sys_ConcatenateFileLists( pFiles0, pFiles1 );
+#endif
+
 	nPotential = Sys_CountFileList(pFiles);
 
 	for ( i = 0 ; i < nPotential ; i++ ) {
@@ -2795,6 +2808,17 @@ int	FS_GetModList( char *listbuf, int bufsize ) {
 				Sys_FreeFileList( pPaks );
 			}
 
+#ifndef STANDALONE
+			/* try on steam path */
+			if ( nPaks <= 0 )
+			{
+				path = FS_BuildOSPath( fs_steampath->string, name, "" );
+				nPaks = 0;
+				pPaks = Sys_ListFiles( path, ".pk3", NULL, &nPaks, qfalse );
+				Sys_FreeFileList( pPaks );
+			}
+#endif
+
 			if (nPaks > 0) {
 				nLen = strlen(name) + 1;
 				// nLen is the length of the mod path
@@ -3491,7 +3515,7 @@ static void FS_Startup( const char *gameName )
 	fs_gamedirvar = Cvar_Get( "fs_game", "", CVAR_INIT | CVAR_SYSTEMINFO );
 
 	// add search path elements in reverse priority order
-#ifdef STEAMPATH_NAME
+#ifndef STANDALONE
 	fs_steampath = Cvar_Get ("fs_steampath", Sys_SteamPath(), CVAR_INIT|CVAR_PROTECTED );
 	if (fs_steampath->string[0]) {
 		FS_AddGameDirectory( fs_steampath->string, gameName );
@@ -3517,6 +3541,11 @@ static void FS_Startup( const char *gameName )
 
 	// check for additional base game so mods can be based upon other mods
 	if ( fs_basegame->string[0] && Q_stricmp( fs_basegame->string, gameName ) ) {
+#ifndef STANDALONE
+		if (fs_steampath->string[0]) {
+			FS_AddGameDirectory(fs_steampath->string, fs_basegame->string );
+		}
+#endif
 		if ( fs_basepath->string[0] ) {
 			FS_AddGameDirectory( fs_basepath->string, fs_basegame->string );
 		}
@@ -3527,6 +3556,11 @@ static void FS_Startup( const char *gameName )
 
 	// check for additional game folder for mods
 	if ( fs_gamedirvar->string[0] && Q_stricmp( fs_gamedirvar->string, gameName ) ) {
+#ifndef STANDALONE
+		if (fs_steampath->string[0]) {
+			FS_AddGameDirectory(fs_steampath->string, fs_gamedirvar->string );
+		}
+#endif
 		if ( fs_basepath->string[0] ) {
 			FS_AddGameDirectory( fs_basepath->string, fs_gamedirvar->string );
 		}
diff --git a/SP/code/qcommon/q_shared.h b/SP/code/qcommon/q_shared.h
index b7d2026..0e74c7c 100644
--- a/SP/code/qcommon/q_shared.h
+++ b/SP/code/qcommon/q_shared.h
@@ -48,6 +48,7 @@ If you have questions concerning this license or the applicable additional terms
   #define HOMEPATH_NAME_UNIX		".foo"
   #define HOMEPATH_NAME_WIN		"FooBar"
 //  #define STEAMPATH_NAME		"Foo Bar"
+//  #define STEAMPATH_APPID		""
   #define HOMEPATH_NAME_MACOSX		HOMEPATH_NAME_WIN
   #define GAMENAME_FOR_MASTER		"foobar"	// must NOT contain whitespace
 //  #define LEGACY_PROTOCOL	// You probably don't need this for your standalone game
@@ -59,6 +60,7 @@ If you have questions concerning this license or the applicable additional terms
   #define HOMEPATH_NAME_UNIX		".iortcw"
   #define HOMEPATH_NAME_WIN		"RTCW"
   #define STEAMPATH_NAME		"Return To Castle Wolfenstein"
+  #define STEAMPATH_APPID		"9010"
   #define HOMEPATH_NAME_MACOSX		HOMEPATH_NAME_WIN
   #define GAMENAME_FOR_MASTER		"wolfsp"
   #define LEGACY_PROTOCOL
diff --git a/SP/code/qcommon/qcommon.h b/SP/code/qcommon/qcommon.h
index 508a420..a3f7fae 100644
--- a/SP/code/qcommon/qcommon.h
+++ b/SP/code/qcommon/qcommon.h
@@ -1146,7 +1146,7 @@ char    *Sys_Cwd( void );
 char    *Sys_DefaultBasePath( void );
 char    *Sys_DefaultInstallPath( void );
 
-#ifdef STEAMPATH_NAME
+#ifndef STANDALONE
 char    *Sys_SteamPath(void);
 #endif
 
diff --git a/SP/code/sys/sys_unix.c b/SP/code/sys/sys_unix.c
index 72aa1f6..888f005 100644
--- a/SP/code/sys/sys_unix.c
+++ b/SP/code/sys/sys_unix.c
@@ -44,7 +44,7 @@ qboolean stdinIsATTY;
 // Used to determine where to store user-specific files
 static char homePath[ MAX_OSPATH ] = { 0 };
 
-#ifdef STEAMPATH_NAME
+#ifndef STANDALONE
 // Used to store the Steam RTCW installation path
 static char steamPath[ MAX_OSPATH ] = { 0 };
 #endif
@@ -83,7 +83,7 @@ char *Sys_DefaultHomePath(void)
 	return homePath;
 }
 
-#ifdef STEAMPATH_NAME
+#ifndef STANDALONE
 /*
 ================
 Sys_SteamPath
diff --git a/SP/code/sys/sys_win32.c b/SP/code/sys/sys_win32.c
index 8d8b192..a303247 100644
--- a/SP/code/sys/sys_win32.c
+++ b/SP/code/sys/sys_win32.c
@@ -42,7 +42,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 // Used to determine where to store user-specific files
 static char homePath[ MAX_OSPATH ] = { 0 };
 
-#ifdef STEAMPATH_NAME
+#ifndef STANDALONE
 // Used to store the Steam RTCW installation path
 static char steamPath[ MAX_OSPATH ] = { 0 };
 #endif
@@ -132,7 +132,7 @@ char *Sys_DefaultHomePath( void )
 	return homePath;
 }
 
-#ifdef STEAMPATH_NAME
+#ifndef STANDALONE
 /*
 ================
 Sys_SteamPath
@@ -140,25 +140,50 @@ Sys_SteamPath
 */
 char *Sys_SteamPath( void )
 {
+#if defined(STEAMPATH_NAME) || defined(STEAMPATH_APPID)
 	HKEY steamRegKey;
+	DWORD pathLen = MAX_OSPATH;
+	qboolean finishPath = qfalse;
+#endif
+
+#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))
+	{
+		pathLen = MAX_OSPATH;
+		if (RegQueryValueEx(steamRegKey, "InstallLocation", NULL, NULL, (LPBYTE)steamPath, &pathLen))
+			steamPath[0] = '\0';
+	}
 
-	if (!RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Valve\\Steam", 0, KEY_QUERY_VALUE, &steamRegKey))
+	if (!steamPath[0] && !RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\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';
+	}
+#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--;
+			finishPath = qtrue;
+	}
+#endif
+
+	if (steamPath[0])
+	{
+		if (pathLen == MAX_OSPATH)
+			pathLen--;
 
-			steamPath[pathLen] = '\0';
+		steamPath[pathLen] = '\0';
 
+		if (finishPath)
 			Q_strcat(steamPath, MAX_OSPATH, "\\SteamApps\\common\\" STEAMPATH_NAME );
-		}
 	}
 
 	return steamPath;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git



More information about the Pkg-games-commits mailing list