Fix removing/creating PID file for base game when switching to/from mods

This commit is contained in:
Zack Middleton 2016-10-27 22:54:33 -05:00
parent f7711a8119
commit 10f33b892b

View file

@ -303,6 +303,8 @@ static char *fs_serverReferencedPakNames[MAX_SEARCH_PATHS]; // pk3 names
// last valid game folder used
char lastValidBase[MAX_OSPATH];
char lastValidComBaseGame[MAX_OSPATH];
char lastValidFsBaseGame[MAX_OSPATH];
char lastValidGame[MAX_OSPATH];
#ifdef FS_MISSING
@ -3963,6 +3965,8 @@ void FS_InitFilesystem( void ) {
}
Q_strncpyz(lastValidBase, fs_basepath->string, sizeof(lastValidBase));
Q_strncpyz(lastValidComBaseGame, com_basegame->string, sizeof(lastValidComBaseGame));
Q_strncpyz(lastValidFsBaseGame, fs_basegame->string, sizeof(lastValidFsBaseGame));
Q_strncpyz(lastValidGame, fs_gamedirvar->string, sizeof(lastValidGame));
}
@ -3973,6 +3977,7 @@ FS_Restart
================
*/
void FS_Restart( int checksumFeed ) {
const char *lastGameDir;
// free anything we currently have loaded
FS_Shutdown(qfalse);
@ -3999,8 +4004,12 @@ void FS_Restart( int checksumFeed ) {
if (lastValidBase[0]) {
FS_PureServerSetLoadedPaks("", "");
Cvar_Set("fs_basepath", lastValidBase);
Cvar_Set("com_basegame", lastValidComBaseGame);
Cvar_Set("fs_basegame", lastValidFsBaseGame);
Cvar_Set("fs_game", lastValidGame);
lastValidBase[0] = '\0';
lastValidComBaseGame[0] = '\0';
lastValidFsBaseGame[0] = '\0';
lastValidGame[0] = '\0';
FS_Restart(checksumFeed);
Com_Error( ERR_DROP, "Invalid game folder" );
@ -4009,9 +4018,11 @@ void FS_Restart( int checksumFeed ) {
Com_Error( ERR_FATAL, "Couldn't load default.cfg" );
}
if ( Q_stricmp(fs_gamedirvar->string, lastValidGame) ) {
Sys_RemovePIDFile( lastValidGame );
Sys_InitPIDFile( fs_gamedirvar->string );
lastGameDir = ( lastValidGame[0] ) ? lastValidGame : lastValidComBaseGame;
if ( Q_stricmp( FS_GetCurrentGameDir(), lastGameDir ) ) {
Sys_RemovePIDFile( lastGameDir );
Sys_InitPIDFile( FS_GetCurrentGameDir() );
// skip the q3config.cfg if "safe" is on the command line
if ( !Com_SafeMode() ) {
@ -4020,6 +4031,8 @@ void FS_Restart( int checksumFeed ) {
}
Q_strncpyz(lastValidBase, fs_basepath->string, sizeof(lastValidBase));
Q_strncpyz(lastValidComBaseGame, com_basegame->string, sizeof(lastValidComBaseGame));
Q_strncpyz(lastValidFsBaseGame, fs_basegame->string, sizeof(lastValidFsBaseGame));
Q_strncpyz(lastValidGame, fs_gamedirvar->string, sizeof(lastValidGame));
}