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 9b531cd4a47b3c4fea5b1de32b5d46bd28ed4d4d
Author: MAN-AT-ARMS <m4n4t4...@gmail.com>
Date:   Mon Sep 21 10:33:28 2015 -0400

    All: Add Steam's install folder to search path
---
 MP/code/qcommon/files.c    | 21 +++++++++++++++++++++
 MP/code/qcommon/q_shared.h |  2 ++
 MP/code/qcommon/qcommon.h  |  1 +
 MP/code/sys/sys_unix.c     | 28 ++++++++++++++++++++++++++++
 MP/code/sys/sys_win32.c    | 34 ++++++++++++++++++++++++++++++++++
 SP/code/qcommon/files.c    | 20 ++++++++++++++++++++
 SP/code/qcommon/q_shared.h |  2 ++
 SP/code/qcommon/qcommon.h  |  1 +
 SP/code/sys/sys_unix.c     | 28 ++++++++++++++++++++++++++++
 SP/code/sys/sys_win32.c    | 34 ++++++++++++++++++++++++++++++++++
 10 files changed, 171 insertions(+)

diff --git a/MP/code/qcommon/files.c b/MP/code/qcommon/files.c
index 8e55976..448cb51 100644
--- a/MP/code/qcommon/files.c
+++ b/MP/code/qcommon/files.c
@@ -251,6 +251,7 @@ static cvar_t      *fs_homepath;
 // Also search the .app bundle for .pk3 files
 static  cvar_t          *fs_apppath;
 #endif
+static cvar_t          *fs_steampath;
 
 static cvar_t      *fs_basepath;
 static cvar_t      *fs_basegame;
@@ -751,6 +752,22 @@ long FS_SV_FOpenFileRead( const char *filename, 
fileHandle_t *fp ) {
                        fsh[f].handleSync = qfalse;
                }
 
+               // Check fs_steampath too
+               if (!fsh[f].handleFiles.file.o && fs_steampath->string[0])
+               {
+                       ospath = FS_BuildOSPath( fs_steampath->string, 
filename, "" );
+                       ospath[strlen(ospath)-1] = '\0';
+
+                       if ( fs_debug->integer )
+                       {
+                               Com_Printf( "FS_SV_FOpenFileRead 
(fs_steampath): %s\n", ospath );
+                       }
+
+                       fsh[f].handleFiles.file.o = Sys_FOpen( ospath, "rb" );
+                       fsh[f].handleSync = qfalse;
+               }
+
+
                if ( !fsh[f].handleFiles.file.o )
                {
                        f = 0;
@@ -3465,6 +3482,10 @@ 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
+       fs_steampath = Cvar_Get ("fs_steampath", Sys_SteamPath(), 
CVAR_INIT|CVAR_PROTECTED );
+       if (fs_steampath->string[0]) {
+               FS_AddGameDirectory( fs_steampath->string, gameName, qtrue );
+       }
        if ( fs_basepath->string[0] ) {
                FS_AddGameDirectory( fs_basepath->string, gameName, qtrue );
        }
diff --git a/MP/code/qcommon/q_shared.h b/MP/code/qcommon/q_shared.h
index 2944e17..0d800dd 100644
--- a/MP/code/qcommon/q_shared.h
+++ b/MP/code/qcommon/q_shared.h
@@ -49,6 +49,7 @@ If you have questions concerning this license or the 
applicable additional terms
   #define CLIENT_WINDOW_MIN_TITLE      "changeme2"
   #define HOMEPATH_NAME_UNIX           ".foo"
   #define HOMEPATH_NAME_WIN            "FooBar"
+  #define STEAMPATH_NAME               "Foo Bar"
   #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
@@ -60,6 +61,7 @@ If you have questions concerning this license or the 
applicable additional terms
   #define CLIENT_WINDOW_MIN_TITLE      "iowolfmp"
   #define HOMEPATH_NAME_UNIX           ".iortcw"
   #define HOMEPATH_NAME_WIN            "RTCW"
+  #define STEAMPATH_NAME               "Return To Castle Wolfenstein"
   #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 0727d4e..f0107b7 100644
--- a/MP/code/qcommon/qcommon.h
+++ b/MP/code/qcommon/qcommon.h
@@ -1229,6 +1229,7 @@ FILE      *Sys_Mkfifo( const char *ospath );
 char    *Sys_Cwd( void );
 char    *Sys_DefaultBasePath( void );
 char    *Sys_DefaultInstallPath( void );
+char   *Sys_SteamPath(void);
 
 #ifdef MACOS_X
 char    *Sys_DefaultAppPath(void);
diff --git a/MP/code/sys/sys_unix.c b/MP/code/sys/sys_unix.c
index 62c95ee..db2facc 100644
--- a/MP/code/sys/sys_unix.c
+++ b/MP/code/sys/sys_unix.c
@@ -44,6 +44,9 @@ qboolean stdinIsATTY;
 // Used to determine where to store user-specific files
 static char homePath[ MAX_OSPATH ] = { 0 };
 
+// Used to store the Steam RTCW installation path
+static char steamPath[ MAX_OSPATH ] = { 0 };
+
 /*
 ==================
 Sys_DefaultHomePath
@@ -80,6 +83,31 @@ char *Sys_DefaultHomePath(void)
 
 /*
 ================
+Sys_SteamPath
+================
+*/
+char *Sys_SteamPath( void )
+{
+       // Disabled since Steam doesn't let you install RTCW on Mac/Linux
+#if 0
+       char *p;
+
+       if( ( p = getenv( "HOME" ) ) != NULL )
+       {
+#ifdef MACOS_X
+               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;
+}
+
+/*
+================
 Sys_Milliseconds
 ================
 */
diff --git a/MP/code/sys/sys_win32.c b/MP/code/sys/sys_win32.c
index 84dce76..e74e40d 100644
--- a/MP/code/sys/sys_win32.c
+++ b/MP/code/sys/sys_win32.c
@@ -42,6 +42,9 @@ 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 };
 
+// Used to store the Steam Quake 3 installation path
+static char steamPath[ MAX_OSPATH ] = { 0 };
+
 #ifndef DEDICATED
 static UINT timerResolution = 0;
 #endif
@@ -129,6 +132,37 @@ char *Sys_DefaultHomePath( void )
 
 /*
 ================
+Sys_SteamPath
+================
+*/
+char *Sys_SteamPath( void )
+{
+       HKEY steamRegKey;
+
+       if (!RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Valve\\Steam", 0, 
KEY_QUERY_VALUE, &steamRegKey))
+       {
+               DWORD 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--;
+
+                       steamPath[pathLen] = '\0';
+
+                       Q_strcat(steamPath, MAX_OSPATH, "\\SteamApps\\common\\" 
STEAMPATH_NAME );
+               }
+       }
+
+       return steamPath;
+}
+
+/*
+================
 Sys_Milliseconds
 ================
 */
diff --git a/SP/code/qcommon/files.c b/SP/code/qcommon/files.c
index 02725a9..f5e45db 100644
--- a/SP/code/qcommon/files.c
+++ b/SP/code/qcommon/files.c
@@ -254,6 +254,7 @@ static cvar_t      *fs_homepath;
 // Also search the .app bundle for .pk3 files
 static  cvar_t          *fs_apppath;
 #endif
+static cvar_t          *fs_steampath;
 
 static cvar_t      *fs_basepath;
 static cvar_t      *fs_basegame;
@@ -858,6 +859,21 @@ long FS_SV_FOpenFileRead(const char *filename, 
fileHandle_t *fp)
                        fsh[f].handleSync = qfalse;
                }
 
+               // Check fs_steampath too
+               if (!fsh[f].handleFiles.file.o && fs_steampath->string[0])
+               {
+                       ospath = FS_BuildOSPath( fs_steampath->string, 
filename, "" );
+                       ospath[strlen(ospath)-1] = '\0';
+
+                       if ( fs_debug->integer )
+                       {
+                               Com_Printf( "FS_SV_FOpenFileRead 
(fs_steampath): %s\n", ospath );
+                       }
+
+                       fsh[f].handleFiles.file.o = Sys_FOpen( ospath, "rb" );
+                       fsh[f].handleSync = qfalse;
+               }
+
                if ( !fsh[f].handleFiles.file.o )
                {
                        f = 0;
@@ -3470,6 +3486,10 @@ 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
+       fs_steampath = Cvar_Get ("fs_steampath", Sys_SteamPath(), 
CVAR_INIT|CVAR_PROTECTED );
+       if (fs_steampath->string[0]) {
+               FS_AddGameDirectory( fs_steampath->string, gameName );
+       }
        if ( fs_basepath->string[0] ) {
                FS_AddGameDirectory( fs_basepath->string, gameName );
        }
diff --git a/SP/code/qcommon/q_shared.h b/SP/code/qcommon/q_shared.h
index fd377a3..94848d4 100644
--- a/SP/code/qcommon/q_shared.h
+++ b/SP/code/qcommon/q_shared.h
@@ -47,6 +47,7 @@ If you have questions concerning this license or the 
applicable additional terms
   #define CLIENT_WINDOW_MIN_TITLE      "changeme2"
   #define HOMEPATH_NAME_UNIX           ".foo"
   #define HOMEPATH_NAME_WIN            "FooBar"
+  #define STEAMPATH_NAME               "Foo Bar"
   #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
@@ -57,6 +58,7 @@ If you have questions concerning this license or the 
applicable additional terms
   #define CLIENT_WINDOW_MIN_TITLE      "iowolfsp"
   #define HOMEPATH_NAME_UNIX           ".iortcw"
   #define HOMEPATH_NAME_WIN            "RTCW"
+  #define STEAMPATH_NAME               "Return To Castle Wolfenstein"
   #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 425e9a4..0dd7ba2 100644
--- a/SP/code/qcommon/qcommon.h
+++ b/SP/code/qcommon/qcommon.h
@@ -1145,6 +1145,7 @@ FILE      *Sys_Mkfifo( const char *ospath );
 char    *Sys_Cwd( void );
 char    *Sys_DefaultBasePath( void );
 char    *Sys_DefaultInstallPath( void );
+char   *Sys_SteamPath(void);
 
 #ifdef MACOS_X
 char    *Sys_DefaultAppPath(void);
diff --git a/SP/code/sys/sys_unix.c b/SP/code/sys/sys_unix.c
index 02286dd..17f874d 100644
--- a/SP/code/sys/sys_unix.c
+++ b/SP/code/sys/sys_unix.c
@@ -44,6 +44,9 @@ 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 };
+
 /*
 ==================
 Sys_DefaultHomePath
@@ -80,6 +83,31 @@ char *Sys_DefaultHomePath(void)
 
 /*
 ================
+Sys_SteamPath
+================
+*/
+char *Sys_SteamPath( void )
+{
+       // Disabled since Steam doesn't let you install Quake 3 on Mac/Linux
+#if 0
+       char *p;
+
+       if( ( p = getenv( "HOME" ) ) != NULL )
+       {
+#ifdef MACOS_X
+               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;
+}
+
+/*
+================
 Sys_Milliseconds
 ================
 */
diff --git a/SP/code/sys/sys_win32.c b/SP/code/sys/sys_win32.c
index 8f67cc7..459ca24 100644
--- a/SP/code/sys/sys_win32.c
+++ b/SP/code/sys/sys_win32.c
@@ -42,6 +42,9 @@ 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 };
 
+// Used to store the Steam Quake 3 installation path
+static char steamPath[ MAX_OSPATH ] = { 0 };
+
 #ifndef DEDICATED
 static UINT timerResolution = 0;
 #endif
@@ -129,6 +132,37 @@ char *Sys_DefaultHomePath( void )
 
 /*
 ================
+Sys_SteamPath
+================
+*/
+char *Sys_SteamPath( void )
+{
+       HKEY steamRegKey;
+
+       if (!RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Valve\\Steam", 0, 
KEY_QUERY_VALUE, &steamRegKey))
+       {
+               DWORD 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--;
+
+                       steamPath[pathLen] = '\0';
+
+                       Q_strcat(steamPath, MAX_OSPATH, "\\SteamApps\\common\\" 
STEAMPATH_NAME );
+               }
+       }
+
+       return steamPath;
+}
+
+/*
+================
 Sys_Milliseconds
 ================
 */

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

_______________________________________________
Pkg-games-commits mailing list
Pkg-games-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

Reply via email to