[iortcw] 53/95: All: Detect GOG install path

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


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

smcv pushed a commit to tag 1.51
in repository iortcw.

commit ca3cb6f7e19b729dce0324d8e72312da867c8846
Author: MAN-AT-ARMS <M4N4T4RMS at gmail.com>
Date:   Tue Apr 11 19:11:37 2017 -0400

    All:  Detect GOG install path
    
    Unverified Game ID
---
 MP/code/qcommon/files.c    | 50 ++++++++++++++++++++++++++++++++++++++++++----
 MP/code/qcommon/q_shared.h |  1 +
 MP/code/qcommon/qcommon.h  |  1 +
 MP/code/sys/sys_unix.c     | 14 +++++++++++++
 MP/code/sys/sys_win32.c    | 35 ++++++++++++++++++++++++++++++++
 SP/code/qcommon/files.c    | 50 ++++++++++++++++++++++++++++++++++++++++++----
 SP/code/qcommon/q_shared.h |  1 +
 SP/code/qcommon/qcommon.h  |  1 +
 SP/code/sys/sys_unix.c     | 14 +++++++++++++
 SP/code/sys/sys_win32.c    | 35 ++++++++++++++++++++++++++++++++
 10 files changed, 194 insertions(+), 8 deletions(-)

diff --git a/MP/code/qcommon/files.c b/MP/code/qcommon/files.c
index 0c37070..7161002 100644
--- a/MP/code/qcommon/files.c
+++ b/MP/code/qcommon/files.c
@@ -254,6 +254,7 @@ static  cvar_t          *fs_apppath;
 
 #ifndef STANDALONE
 static	cvar_t		*fs_steampath;
+static	cvar_t		*fs_gogpath;
 #endif
 
 static cvar_t      *fs_basepath;
@@ -757,7 +758,7 @@ long FS_SV_FOpenFileRead( const char *filename, fileHandle_t *fp ) {
 		}
 
 #ifndef STANDALONE
-		// Check fs_steampath too
+		// Check fs_steampath
 		if (!fsh[f].handleFiles.file.o && fs_steampath->string[0])
 		{
 			ospath = FS_BuildOSPath( fs_steampath->string, filename, "" );
@@ -771,6 +772,21 @@ long FS_SV_FOpenFileRead( const char *filename, fileHandle_t *fp ) {
 			fsh[f].handleFiles.file.o = Sys_FOpen( ospath, "rb" );
 			fsh[f].handleSync = qfalse;
 		}
+
+		// Check fs_gogpath
+		if (!fsh[f].handleFiles.file.o && fs_gogpath->string[0])
+		{
+			ospath = FS_BuildOSPath( fs_gogpath->string, filename, "" );
+			ospath[strlen(ospath)-1] = '\0';
+
+			if ( fs_debug->integer )
+			{
+				Com_Printf( "FS_SV_FOpenFileRead (fs_gogpath): %s\n", ospath );
+			}
+
+			fsh[f].handleFiles.file.o = Sys_FOpen( ospath, "rb" );
+			fsh[f].handleSync = qfalse;
+		}
 #endif
 
 
@@ -2742,6 +2758,8 @@ int	FS_GetModList( char *listbuf, int bufsize ) {
 #ifndef STANDALONE
 	char **pFiles2 = NULL;
 	char **pFiles3 = NULL;
+	char **pFiles4 = NULL;
+	char **pFiles5 = NULL;
 #endif
 
 	qboolean bDrop = qfalse;
@@ -2753,12 +2771,14 @@ int	FS_GetModList( char *listbuf, int bufsize ) {
 	pFiles1 = Sys_ListFiles( fs_basepath->string, NULL, NULL, &dummy, qtrue );
 #ifndef STANDALONE
 	pFiles2 = Sys_ListFiles( fs_steampath->string, NULL, NULL, &dummy, qtrue );
+	pFiles3 = Sys_ListFiles( fs_gogpath->string, NULL, NULL, &dummy, qtrue );
 #endif
-	// we searched for mods in the three paths
+	// we searched for mods in up to four 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 );
+	pFiles4 = Sys_ConcatenateFileLists( pFiles0, pFiles1 );
+	pFiles5 = Sys_ConcatenateFileLists( pFiles2, pFiles3 );
+	pFiles = Sys_ConcatenateFileLists( pFiles4, pFiles5 );
 #else
 	pFiles = Sys_ConcatenateFileLists( pFiles0, pFiles1 );
 #endif
@@ -2813,6 +2833,15 @@ int	FS_GetModList( char *listbuf, int bufsize ) {
 				pPaks = Sys_ListFiles( path, ".pk3", NULL, &nPaks, qfalse );
 				Sys_FreeFileList( pPaks );
 			}
+
+			/* try on gog path */
+			if ( nPaks <= 0 )
+			{
+				path = FS_BuildOSPath( fs_gogpath->string, name, "" );
+				nPaks = 0;
+				pPaks = Sys_ListFiles( path, ".pk3", NULL, &nPaks, qfalse );
+				Sys_FreeFileList( pPaks );
+			}
 #endif
 
 			if (nPaks > 0) {
@@ -3498,6 +3527,11 @@ static void FS_Startup( const char *gameName ) {
 
 	// add search path elements in reverse priority order
 #ifndef STANDALONE
+	fs_gogpath = Cvar_Get ("fs_gogpath", Sys_GogPath(), CVAR_INIT|CVAR_PROTECTED );
+	if (fs_gogpath->string[0]) {
+		FS_AddGameDirectory( fs_gogpath->string, gameName, qtrue );
+	}
+
 	fs_steampath = Cvar_Get ("fs_steampath", Sys_SteamPath(), CVAR_INIT|CVAR_PROTECTED );
 	if (fs_steampath->string[0]) {
 		FS_AddGameDirectory( fs_steampath->string, gameName, qtrue );
@@ -3524,6 +3558,10 @@ 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_gogpath->string[0]) {
+			FS_AddGameDirectory( fs_gogpath->string, fs_basegame->string, qtrue );
+		}
+
 		if ( fs_steampath->string[0] ) {
 			FS_AddGameDirectory( fs_steampath->string, fs_basegame->string, qtrue );
 		}
@@ -3541,6 +3579,10 @@ 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_gogpath->string[0]) {
+			FS_AddGameDirectory( fs_gogpath->string, fs_gamedirvar->string, qtrue );
+		}
+
 		if ( fs_steampath->string[0] ) {
 			FS_AddGameDirectory( fs_steampath->string, fs_gamedirvar->string, qtrue );
 		}
diff --git a/MP/code/qcommon/q_shared.h b/MP/code/qcommon/q_shared.h
index b728d15..6f53652 100644
--- a/MP/code/qcommon/q_shared.h
+++ b/MP/code/qcommon/q_shared.h
@@ -70,6 +70,7 @@ If you have questions concerning this license or the applicable additional terms
   #define HOMEPATH_NAME_WIN		"RTCW"
   #define STEAMPATH_NAME		"Return To Castle Wolfenstein"
   #define STEAMPATH_APPID		"9010"
+  #define GOGPATH_ID			"1443699418"
   #define HOMEPATH_NAME_MACOSX		HOMEPATH_NAME_WIN
   #define GAMENAME_FOR_MASTER		"wolfmp"
   #define CINEMATICS_LOGO		"gmlogo.RoQ"	// non-existent
diff --git a/MP/code/qcommon/qcommon.h b/MP/code/qcommon/qcommon.h
index db22e30..517ff37 100644
--- a/MP/code/qcommon/qcommon.h
+++ b/MP/code/qcommon/qcommon.h
@@ -1233,6 +1233,7 @@ char    *Sys_DefaultInstallPath( void );
 
 #ifndef STANDALONE
 char    *Sys_SteamPath(void);
+char	*Sys_GogPath(void);
 #endif
 
 #ifdef __APPLE__
diff --git a/MP/code/sys/sys_unix.c b/MP/code/sys/sys_unix.c
index 941b689..59d9f5b 100644
--- a/MP/code/sys/sys_unix.c
+++ b/MP/code/sys/sys_unix.c
@@ -50,6 +50,9 @@ static const char DEFAULT_XDG_DATA_HOME[] = {'.', 'l', 'o', 'c', 'a', 'l', PATH_
 #ifndef STANDALONE
 // Used to store the Steam RTCW installation path
 static char steamPath[ MAX_OSPATH ] = { 0 };
+
+// Used to store the GOG RTCW installation path
+static char gogPath[ MAX_OSPATH ] = { 0 };
 #endif
 
 /*
@@ -140,6 +143,17 @@ char *Sys_SteamPath( void )
 
 	return steamPath;
 }
+
+/*
+================
+Sys_GogPath
+================
+*/
+char *Sys_GogPath( void )
+{
+	// GOG also doesn't let you install RTCW on Mac/Linux
+	return gogPath;
+}
 #endif
 
 /*
diff --git a/MP/code/sys/sys_win32.c b/MP/code/sys/sys_win32.c
index bc687c4..033adb3 100644
--- a/MP/code/sys/sys_win32.c
+++ b/MP/code/sys/sys_win32.c
@@ -45,6 +45,9 @@ static char homePath[ MAX_OSPATH ] = { 0 };
 #ifndef STANDALONE
 // Used to store the Steam RTCW installation path
 static char steamPath[ MAX_OSPATH ] = { 0 };
+
+// Used to store the GOG RTCW installation path
+static char gogPath[ MAX_OSPATH ] = { 0 };
 #endif
 
 #ifndef DEDICATED
@@ -186,6 +189,38 @@ char *Sys_SteamPath( void )
 
 	return steamPath;
 }
+
+/*
+================
+Sys_GogPath
+================
+*/
+char *Sys_GogPath( void )
+{
+#ifdef GOGPATH_ID
+	HKEY gogRegKey;
+	DWORD pathLen = MAX_OSPATH;
+
+	if (!gogPath[0] && !RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\GOG.com\\Games\\" GOGPATH_ID, 0, KEY_QUERY_VALUE | KEY_WOW64_32KEY, &gogRegKey))
+	{
+		pathLen = MAX_OSPATH;
+		if (RegQueryValueEx(gogRegKey, "PATH", NULL, NULL, (LPBYTE)gogPath, &pathLen))
+			gogPath[0] = '\0';
+
+		RegCloseKey(gogRegKey);
+	}
+
+	if (gogPath[0])
+	{
+		if (pathLen == MAX_OSPATH)
+			pathLen--;
+
+		gogPath[pathLen] = '\0';
+	}
+#endif
+
+	return gogPath;
+}
 #endif
 
 /*
diff --git a/SP/code/qcommon/files.c b/SP/code/qcommon/files.c
index c9a55b5..e27ee99 100644
--- a/SP/code/qcommon/files.c
+++ b/SP/code/qcommon/files.c
@@ -281,6 +281,7 @@ static  cvar_t          *fs_apppath;
 
 #ifndef STANDALONE
 static	cvar_t		*fs_steampath;
+static	cvar_t		*fs_gogpath;
 #endif
 
 static cvar_t      *fs_basepath;
@@ -888,7 +889,7 @@ long FS_SV_FOpenFileRead(const char *filename, fileHandle_t *fp)
 		}
 
 #ifndef STANDALONE
-		// Check fs_steampath too
+		// Check fs_steampath
 		if (!fsh[f].handleFiles.file.o && fs_steampath->string[0])
 		{
 			ospath = FS_BuildOSPath( fs_steampath->string, filename, "" );
@@ -902,6 +903,21 @@ long FS_SV_FOpenFileRead(const char *filename, fileHandle_t *fp)
 			fsh[f].handleFiles.file.o = Sys_FOpen( ospath, "rb" );
 			fsh[f].handleSync = qfalse;
 		}
+
+		// Check fs_gogpath
+		if (!fsh[f].handleFiles.file.o && fs_gogpath->string[0])
+		{
+			ospath = FS_BuildOSPath( fs_gogpath->string, filename, "" );
+			ospath[strlen(ospath)-1] = '\0';
+
+			if ( fs_debug->integer )
+			{
+				Com_Printf( "FS_SV_FOpenFileRead (fs_gogpath): %s\n", ospath );
+			}
+
+			fsh[f].handleFiles.file.o = Sys_FOpen( ospath, "rb" );
+			fsh[f].handleSync = qfalse;
+		}
 #endif
 
 		if ( !fsh[f].handleFiles.file.o )
@@ -2777,6 +2793,8 @@ int	FS_GetModList( char *listbuf, int bufsize ) {
 #ifndef STANDALONE
 	char **pFiles2 = NULL;
 	char **pFiles3 = NULL;
+	char **pFiles4 = NULL;
+	char **pFiles5 = NULL;
 #endif
 	qboolean bDrop = qfalse;
 
@@ -2787,12 +2805,14 @@ int	FS_GetModList( char *listbuf, int bufsize ) {
 	pFiles1 = Sys_ListFiles( fs_basepath->string, NULL, NULL, &dummy, qtrue );
 #ifndef STANDALONE
 	pFiles2 = Sys_ListFiles( fs_steampath->string, NULL, NULL, &dummy, qtrue );
+	pFiles3 = Sys_ListFiles( fs_gogpath->string, NULL, NULL, &dummy, qtrue );
 #endif
-	// we searched for mods in the three paths
+	// we searched for mods in up to four 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 );
+	pFiles4 = Sys_ConcatenateFileLists( pFiles0, pFiles1 );
+	pFiles5 = Sys_ConcatenateFileLists( pFiles2, pFiles3 );
+	pFiles = Sys_ConcatenateFileLists( pFiles4, pFiles5 );
 #else
 	pFiles = Sys_ConcatenateFileLists( pFiles0, pFiles1 );
 #endif
@@ -2847,6 +2867,15 @@ int	FS_GetModList( char *listbuf, int bufsize ) {
 				pPaks = Sys_ListFiles( path, ".pk3", NULL, &nPaks, qfalse );
 				Sys_FreeFileList( pPaks );
 			}
+
+			/* try on gog path */
+			if ( nPaks <= 0 )
+			{
+				path = FS_BuildOSPath( fs_gogpath->string, name, "" );
+				nPaks = 0;
+				pPaks = Sys_ListFiles( path, ".pk3", NULL, &nPaks, qfalse );
+				Sys_FreeFileList( pPaks );
+			}
 #endif
 
 			if (nPaks > 0) {
@@ -3531,6 +3560,11 @@ static void FS_Startup( const char *gameName )
 
 	// add search path elements in reverse priority order
 #ifndef STANDALONE
+	fs_gogpath = Cvar_Get ("fs_gogpath", Sys_GogPath(), CVAR_INIT|CVAR_PROTECTED );
+	if (fs_gogpath->string[0]) {
+		FS_AddGameDirectory( fs_gogpath->string, gameName );
+	}
+
 	fs_steampath = Cvar_Get ("fs_steampath", Sys_SteamPath(), CVAR_INIT|CVAR_PROTECTED );
 	if (fs_steampath->string[0]) {
 		FS_AddGameDirectory( fs_steampath->string, gameName );
@@ -3557,6 +3591,10 @@ 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_gogpath->string[0]) {
+			FS_AddGameDirectory( fs_gogpath->string, fs_basegame->string );
+		}
+
 		if ( fs_steampath->string[0] ) {
 			FS_AddGameDirectory( fs_steampath->string, fs_basegame->string );
 		}
@@ -3574,6 +3612,10 @@ 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_gogpath->string[0]) {
+			FS_AddGameDirectory( fs_gogpath->string, fs_gamedirvar->string );
+		}
+
 		if ( fs_steampath->string[0] ) {
 			FS_AddGameDirectory( fs_steampath->string, fs_gamedirvar->string );
 		}
diff --git a/SP/code/qcommon/q_shared.h b/SP/code/qcommon/q_shared.h
index 2703b64..d5fd2b5 100644
--- a/SP/code/qcommon/q_shared.h
+++ b/SP/code/qcommon/q_shared.h
@@ -67,6 +67,7 @@ If you have questions concerning this license or the applicable additional terms
   #define HOMEPATH_NAME_WIN		"RTCW"
   #define STEAMPATH_NAME		"Return To Castle Wolfenstein"
   #define STEAMPATH_APPID		"9010"
+  #define GOGPATH_ID			"1443699418"
   #define HOMEPATH_NAME_MACOSX		HOMEPATH_NAME_WIN
   #define GAMENAME_FOR_MASTER		"wolfsp"
   #define CINEMATICS_LOGO		"gmlogo.RoQ"	// non-existent
diff --git a/SP/code/qcommon/qcommon.h b/SP/code/qcommon/qcommon.h
index e07f68b..d6331bf 100644
--- a/SP/code/qcommon/qcommon.h
+++ b/SP/code/qcommon/qcommon.h
@@ -1151,6 +1151,7 @@ char    *Sys_DefaultInstallPath( void );
 
 #ifndef STANDALONE
 char    *Sys_SteamPath(void);
+char	*Sys_GogPath(void);
 #endif
 
 #ifdef __APPLE__
diff --git a/SP/code/sys/sys_unix.c b/SP/code/sys/sys_unix.c
index 1d82b2d..1fadd39 100644
--- a/SP/code/sys/sys_unix.c
+++ b/SP/code/sys/sys_unix.c
@@ -50,6 +50,9 @@ static const char DEFAULT_XDG_DATA_HOME[] = {'.', 'l', 'o', 'c', 'a', 'l', PATH_
 #ifndef STANDALONE
 // Used to store the Steam RTCW installation path
 static char steamPath[ MAX_OSPATH ] = { 0 };
+
+// Used to store the GOG RTCW installation path
+static char gogPath[ MAX_OSPATH ] = { 0 };
 #endif
 
 /*
@@ -140,6 +143,17 @@ char *Sys_SteamPath( void )
 
 	return steamPath;
 }
+
+/*
+================
+Sys_GogPath
+================
+*/
+char *Sys_GogPath( void )
+{
+	// GOG also doesn't let you install RTCW on Mac/Linux
+	return gogPath;
+}
 #endif
 
 /*
diff --git a/SP/code/sys/sys_win32.c b/SP/code/sys/sys_win32.c
index fae6646..52ec543 100644
--- a/SP/code/sys/sys_win32.c
+++ b/SP/code/sys/sys_win32.c
@@ -45,6 +45,9 @@ static char homePath[ MAX_OSPATH ] = { 0 };
 #ifndef STANDALONE
 // Used to store the Steam RTCW installation path
 static char steamPath[ MAX_OSPATH ] = { 0 };
+
+// Used to store the GOG RTCW installation path
+static char gogPath[ MAX_OSPATH ] = { 0 };
 #endif
 
 #ifndef DEDICATED
@@ -186,6 +189,38 @@ char *Sys_SteamPath( void )
 
 	return steamPath;
 }
+
+/*
+================
+Sys_GogPath
+================
+*/
+char *Sys_GogPath( void )
+{
+#ifdef GOGPATH_ID
+	HKEY gogRegKey;
+	DWORD pathLen = MAX_OSPATH;
+
+	if (!gogPath[0] && !RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\GOG.com\\Games\\" GOGPATH_ID, 0, KEY_QUERY_VALUE | KEY_WOW64_32KEY, &gogRegKey))
+	{
+		pathLen = MAX_OSPATH;
+		if (RegQueryValueEx(gogRegKey, "PATH", NULL, NULL, (LPBYTE)gogPath, &pathLen))
+			gogPath[0] = '\0';
+
+		RegCloseKey(gogRegKey);
+	}
+
+	if (gogPath[0])
+	{
+		if (pathLen == MAX_OSPATH)
+			pathLen--;
+
+		gogPath[pathLen] = '\0';
+	}
+#endif
+
+	return gogPath;
+}
 #endif
 
 /*

-- 
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