mirror of
https://github.com/FWGS/xash3d-fwgs
synced 2024-11-25 11:19:59 +01:00
filesystem: only create readwrite directories if they look like a gamedirectory in rodir
This commit is contained in:
parent
3ccbc7a28c
commit
e673fe9a02
@ -907,33 +907,57 @@ static qboolean FS_ReadGameInfo( const char *filepath, const char *gamedir, game
|
||||
|
||||
/*
|
||||
================
|
||||
FS_CheckForGameDir
|
||||
FS_CheckForQuakeGameDir
|
||||
|
||||
Checks if game directory resembles Quake Engine game directory
|
||||
(some of checks may as well work with Xash gamedirs, it's not a bug)
|
||||
================
|
||||
*/
|
||||
static qboolean FS_CheckForGameDir( const char *gamedir )
|
||||
static qboolean FS_CheckForQuakeGameDir( const char *gamedir, qboolean direct )
|
||||
{
|
||||
// if directory contain config.cfg or progs.dat it's 100% gamedir
|
||||
// quake mods probably always archived but can missed config.cfg before first running
|
||||
const char *files[] = { "config.cfg", "progs.dat", "pak0.pak" };
|
||||
int i;
|
||||
|
||||
for( i = 0; i < sizeof( files ) / sizeof( files[0] ); i++ )
|
||||
{
|
||||
char buf[MAX_VA_STRING];
|
||||
|
||||
// if directory contain config.cfg it's 100% gamedir
|
||||
Q_snprintf( buf, sizeof( buf ), "%s/config.cfg", gamedir );
|
||||
if( FS_FileExists( buf, false ))
|
||||
Q_snprintf( buf, sizeof( buf ), "%s/%s", gamedir, files[i] );
|
||||
if( direct ? FS_SysFileExists( buf ) : FS_FileExists( buf, false ))
|
||||
return true;
|
||||
|
||||
// if directory contain progs.dat it's 100% gamedir
|
||||
Q_snprintf( buf, sizeof( buf ), "%s/progs.dat", gamedir );
|
||||
if( FS_FileExists( buf, false ))
|
||||
return true;
|
||||
|
||||
// quake mods probably always archived but can missed config.cfg before first running
|
||||
Q_snprintf( buf, sizeof( buf ), "%s/pak0.pak", gamedir );
|
||||
if( FS_FileExists( buf, false ))
|
||||
return true;
|
||||
|
||||
// NOTE; adds here some additional checks if you wished
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
FS_CheckForXashGameDir
|
||||
|
||||
Checks if game directory resembles Xash3D game directory
|
||||
===============
|
||||
*/
|
||||
static qboolean FS_CheckForXashGameDir( const char *gamedir, qboolean direct )
|
||||
{
|
||||
// if directory contain gameinfo.txt or liblist.gam it's 100% gamedir
|
||||
const char *files[] = { "gameinfo.txt", "liblist.gam" };
|
||||
int i;
|
||||
|
||||
for( i = 0; i < sizeof( files ) / sizeof( files[0] ); i++ )
|
||||
{
|
||||
char buf[MAX_SYSPATH];
|
||||
|
||||
Q_snprintf( buf, sizeof( buf ), "%s/%s", gamedir, files[i] );
|
||||
if( direct ? FS_SysFileExists( buf ) : FS_FileExists( buf, false ))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
FS_ParseGameInfo
|
||||
@ -990,7 +1014,7 @@ static qboolean FS_ParseGameInfo( const char *gamedir, gameinfo_t *GameInfo )
|
||||
FS_ConvertGameInfo( gamedir, gameinfo_path, liblist_path );
|
||||
|
||||
// force to create gameinfo for specified game if missing
|
||||
if(( FS_CheckForGameDir( gamedir ) || !Q_stricmp( fs_gamedir, gamedir )) && !FS_FileExists( gameinfo_path, false ))
|
||||
if(( FS_CheckForQuakeGameDir( gamedir, false ) || !Q_stricmp( fs_gamedir, gamedir )) && !FS_FileExists( gameinfo_path, false ))
|
||||
{
|
||||
gameinfo_t tmpGameInfo;
|
||||
memset( &tmpGameInfo, 0, sizeof( tmpGameInfo ));
|
||||
@ -1340,18 +1364,22 @@ qboolean FS_InitStdio( qboolean caseinsensitive, const char *rootdir, const char
|
||||
for( i = 0; i < dirs.numstrings; i++ )
|
||||
{
|
||||
char roPath[MAX_SYSPATH];
|
||||
char rwPath[MAX_SYSPATH];
|
||||
|
||||
Q_snprintf( roPath, sizeof( roPath ), "%s/%s/", fs_rodir, dirs.strings[i] );
|
||||
Q_snprintf( rwPath, sizeof( rwPath ), "%s/%s/", fs_rootdir, dirs.strings[i] );
|
||||
|
||||
// check if it's a directory
|
||||
if( !FS_SysFolderExists( roPath ))
|
||||
continue;
|
||||
|
||||
// no need to check folders here, FS_CreatePath will not fail
|
||||
// check if it's gamedir
|
||||
if( FS_CheckForXashGameDir( roPath, true ) || FS_CheckForQuakeGameDir( roPath, true ))
|
||||
{
|
||||
char rwPath[MAX_SYSPATH];
|
||||
|
||||
Q_snprintf( rwPath, sizeof( rwPath ), "%s/%s/", fs_rootdir, dirs.strings[i] );
|
||||
FS_CreatePath( rwPath );
|
||||
}
|
||||
}
|
||||
|
||||
stringlistfreecontents( &dirs );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user