From aa3e32997bf3decdce451c8a6a915c27a489d84c Mon Sep 17 00:00:00 2001 From: Thilo Schulz Date: Wed, 22 Jun 2011 23:00:36 +0000 Subject: - Automatically reset fs_game to "" if it was supplied by the user and is equal to com_basegame - Fix problem where users could change values of CVAR_INIT variables after the call to Cvar_Get() via Com_StartupVariable() - Move sound shutdown after client shutdown so VMs don't hold invalid sound handles in memory --- src/client/cl_main.c | 2 +- src/qcommon/common.c | 17 +++++++++++++---- src/qcommon/cvar.c | 2 -- src/qcommon/files.c | 9 ++++++--- src/qcommon/qcommon.h | 3 +++ 5 files changed, 23 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/client/cl_main.c b/src/client/cl_main.c index 3b30625d..05406179 100644 --- a/src/client/cl_main.c +++ b/src/client/cl_main.c @@ -3608,8 +3608,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/src/qcommon/common.c b/src/qcommon/common.c index c08ea8a0..acf1b2f0 100644 --- a/src/qcommon/common.c +++ b/src/qcommon/common.c @@ -474,7 +474,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); } } } @@ -2390,9 +2390,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) @@ -2440,7 +2441,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), BASEGAME)) + { + // 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); } @@ -2575,7 +2585,6 @@ void Com_Init( char *commandLine ) { com_homepath = Cvar_Get("com_homepath", "", CVAR_INIT); - // Com_StartupVariable( FS_InitFilesystem (); Com_InitJournaling(); diff --git a/src/qcommon/cvar.c b/src/qcommon/cvar.c index b5a6a281..f4aaf60c 100644 --- a/src/qcommon/cvar.c +++ b/src/qcommon/cvar.c @@ -36,8 +36,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/src/qcommon/files.c b/src/qcommon/files.c index c11e9ba8..8e32c9ff 100644 --- a/src/qcommon/files.c +++ b/src/qcommon/files.c @@ -3512,9 +3512,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"), BASEGAME)) + Cvar_Set("fs_game", ""); // try to start up normally FS_Startup( BASEGAME ); diff --git a/src/qcommon/qcommon.h b/src/qcommon/qcommon.h index 10f548e3..8a7dbe7f 100644 --- a/src/qcommon/qcommon.h +++ b/src/qcommon/qcommon.h @@ -493,6 +493,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 -- cgit