From 10f33b892bc95ce27ccb1e31849a7650b959da9b Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Thu, 27 Oct 2016 22:54:33 -0500 Subject: [PATCH] Fix removing/creating PID file for base game when switching to/from mods --- code/qcommon/files.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/code/qcommon/files.c b/code/qcommon/files.c index 345907d2..92a9e405 100644 --- a/code/qcommon/files.c +++ b/code/qcommon/files.c @@ -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)); }