diff --git a/code/client/cl_main.c b/code/client/cl_main.c index 67c6745c..502c4e9e 100644 --- a/code/client/cl_main.c +++ b/code/client/cl_main.c @@ -3392,8 +3392,8 @@ void CL_Shutdown(char *finalmsg, qboolean disconnect) if(disconnect) CL_Disconnect(qtrue); - CL_Snd_Shutdown(); CL_ClearMemory(qtrue); + CL_Snd_Shutdown(); Cmd_RemoveCommand ("cmd"); Cmd_RemoveCommand ("configstrings"); diff --git a/code/qcommon/common.c b/code/qcommon/common.c index c5ff163f..cf7fbbe5 100644 --- a/code/qcommon/common.c +++ b/code/qcommon/common.c @@ -475,7 +475,7 @@ void Com_StartupVariable( const char *match ) { if(Cvar_Flags(s) == CVAR_NONEXISTENT) Cvar_Get(s, Cmd_Argv(2), CVAR_USER_CREATED); else - Cvar_Set(s, Cmd_Argv(2)); + Cvar_Set2(s, Cmd_Argv(2), qfalse); } } } @@ -2391,9 +2391,10 @@ void Com_GameRestart(int checksumFeed, qboolean disconnect) // make sure no recursion can be triggered if(!com_gameRestarting && com_fullyInitialized) { - int clWasRunning = com_cl_running->integer; + int clWasRunning; com_gameRestarting = qtrue; + clWasRunning = com_cl_running->integer; // Kill server if we have one if(com_sv_running->integer) @@ -2441,7 +2442,16 @@ Expose possibility to change current running mod to the user void Com_GameRestart_f(void) { - Cvar_Set("fs_game", Cmd_Argv(1)); + if(!FS_FilenameCompare(Cmd_Argv(1), com_basegame->string)) + { + // This is the standard base game. Servers and clients should + // use "" and not the standard basegame name because this messes + // up pak file negotiation and lots of other stuff + + Cvar_Set("fs_game", ""); + } + else + Cvar_Set("fs_game", Cmd_Argv(1)); Com_GameRestart(0, qtrue); } @@ -2703,7 +2713,6 @@ void Com_Init( char *commandLine ) { if(!com_basegame->string[0]) Cvar_ForceReset("com_basegame"); - // Com_StartupVariable( FS_InitFilesystem (); Com_InitJournaling(); diff --git a/code/qcommon/cvar.c b/code/qcommon/cvar.c index 2c3f1f4f..68f25070 100644 --- a/code/qcommon/cvar.c +++ b/code/qcommon/cvar.c @@ -35,8 +35,6 @@ int cvar_numIndexes; #define FILE_HASH_SIZE 256 static cvar_t *hashTable[FILE_HASH_SIZE]; -cvar_t *Cvar_Set2( const char *var_name, const char *value, qboolean force); - /* ================ return a hash value for the filename diff --git a/code/qcommon/files.c b/code/qcommon/files.c index af031422..59ede021 100644 --- a/code/qcommon/files.c +++ b/code/qcommon/files.c @@ -3792,9 +3792,12 @@ void FS_InitFilesystem( void ) { // we have to specially handle this, because normal command // line variable sets don't happen until after the filesystem // has already been initialized - Com_StartupVariable( "fs_basepath" ); - Com_StartupVariable( "fs_homepath" ); - Com_StartupVariable( "fs_game" ); + Com_StartupVariable("fs_basepath"); + Com_StartupVariable("fs_homepath"); + Com_StartupVariable("fs_game"); + + if(!FS_FilenameCompare(Cvar_VariableString("fs_game"), com_basegame->string)) + Cvar_Set("fs_game", ""); // try to start up normally FS_Startup(com_basegame->string); diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h index c80209d3..cc114633 100644 --- a/code/qcommon/qcommon.h +++ b/code/qcommon/qcommon.h @@ -504,6 +504,9 @@ void Cvar_Update( vmCvar_t *vmCvar ); void Cvar_Set( const char *var_name, const char *value ); // will create the variable with no flags if it doesn't exist +cvar_t *Cvar_Set2(const char *var_name, const char *value, qboolean force); +// same as Cvar_Set, but allows more control over setting of cvar + void Cvar_SetSafe( const char *var_name, const char *value ); // sometimes we set variables from an untrusted source: fail if flags & CVAR_PROTECTED