Detect GOG install path

This commit is contained in:
Max Crofts 2017-04-07 15:18:42 +10:00
parent f5143405f1
commit 7ff610db35
5 changed files with 94 additions and 4 deletions

View file

@ -251,6 +251,7 @@ static cvar_t *fs_homepath;
static cvar_t *fs_apppath;
#endif
static cvar_t *fs_steampath;
static cvar_t *fs_gogpath;
static cvar_t *fs_basepath;
static cvar_t *fs_basegame;
@ -750,7 +751,7 @@ long FS_SV_FOpenFileRead(const char *filename, fileHandle_t *fp)
fsh[f].handleSync = qfalse;
}
// Check fs_steampath too
// Check fs_steampath
if (!fsh[f].handleFiles.file.o && fs_steampath->string[0])
{
ospath = FS_BuildOSPath( fs_steampath->string, filename, "" );
@ -765,6 +766,21 @@ long FS_SV_FOpenFileRead(const char *filename, fileHandle_t *fp)
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;
}
if ( !fsh[f].handleFiles.file.o )
{
f = 0;
@ -2510,6 +2526,8 @@ int FS_GetModList( char *listbuf, int bufsize ) {
char **pFiles1 = NULL;
char **pFiles2 = NULL;
char **pFiles3 = NULL;
char **pFiles4 = NULL;
char **pFiles5 = NULL;
qboolean bDrop = qfalse;
*listbuf = 0;
@ -2518,10 +2536,12 @@ 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 );
pFiles2 = Sys_ListFiles( fs_steampath->string, NULL, NULL, &dummy, qtrue );
// we searched for mods in the three paths
pFiles3 = Sys_ListFiles( fs_gogpath->string, NULL, NULL, &dummy, qtrue );
// we searched for mods in the four paths
// it is likely that we have duplicate names now, which we will cleanup below
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 );
nPotential = Sys_CountFileList(pFiles);
@ -2573,6 +2593,15 @@ int FS_GetModList( char *listbuf, int bufsize ) {
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 );
}
if (nPaks > 0) {
nLen = strlen(name) + 1;
// nLen is the length of the mod path
@ -3301,6 +3330,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_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 );
@ -3325,6 +3358,9 @@ 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 ) ) {
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);
}
@ -3338,6 +3374,9 @@ 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 ) ) {
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);
}