- 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
This commit is contained in:
Thilo Schulz 2011-06-22 23:00:36 +00:00
parent 664f8e578d
commit d57ba6a57b
5 changed files with 23 additions and 10 deletions

View file

@ -3392,8 +3392,8 @@ void CL_Shutdown(char *finalmsg, qboolean disconnect)
if(disconnect) if(disconnect)
CL_Disconnect(qtrue); CL_Disconnect(qtrue);
CL_Snd_Shutdown();
CL_ClearMemory(qtrue); CL_ClearMemory(qtrue);
CL_Snd_Shutdown();
Cmd_RemoveCommand ("cmd"); Cmd_RemoveCommand ("cmd");
Cmd_RemoveCommand ("configstrings"); Cmd_RemoveCommand ("configstrings");

View file

@ -475,7 +475,7 @@ void Com_StartupVariable( const char *match ) {
if(Cvar_Flags(s) == CVAR_NONEXISTENT) if(Cvar_Flags(s) == CVAR_NONEXISTENT)
Cvar_Get(s, Cmd_Argv(2), CVAR_USER_CREATED); Cvar_Get(s, Cmd_Argv(2), CVAR_USER_CREATED);
else 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 // make sure no recursion can be triggered
if(!com_gameRestarting && com_fullyInitialized) if(!com_gameRestarting && com_fullyInitialized)
{ {
int clWasRunning = com_cl_running->integer; int clWasRunning;
com_gameRestarting = qtrue; com_gameRestarting = qtrue;
clWasRunning = com_cl_running->integer;
// Kill server if we have one // Kill server if we have one
if(com_sv_running->integer) if(com_sv_running->integer)
@ -2441,6 +2442,15 @@ Expose possibility to change current running mod to the user
void Com_GameRestart_f(void) void Com_GameRestart_f(void)
{ {
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)); Cvar_Set("fs_game", Cmd_Argv(1));
Com_GameRestart(0, qtrue); Com_GameRestart(0, qtrue);
@ -2703,7 +2713,6 @@ void Com_Init( char *commandLine ) {
if(!com_basegame->string[0]) if(!com_basegame->string[0])
Cvar_ForceReset("com_basegame"); Cvar_ForceReset("com_basegame");
// Com_StartupVariable(
FS_InitFilesystem (); FS_InitFilesystem ();
Com_InitJournaling(); Com_InitJournaling();

View file

@ -35,8 +35,6 @@ int cvar_numIndexes;
#define FILE_HASH_SIZE 256 #define FILE_HASH_SIZE 256
static cvar_t *hashTable[FILE_HASH_SIZE]; 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 return a hash value for the filename

View file

@ -3792,9 +3792,12 @@ void FS_InitFilesystem( void ) {
// we have to specially handle this, because normal command // we have to specially handle this, because normal command
// line variable sets don't happen until after the filesystem // line variable sets don't happen until after the filesystem
// has already been initialized // has already been initialized
Com_StartupVariable( "fs_basepath" ); Com_StartupVariable("fs_basepath");
Com_StartupVariable( "fs_homepath" ); Com_StartupVariable("fs_homepath");
Com_StartupVariable( "fs_game" ); Com_StartupVariable("fs_game");
if(!FS_FilenameCompare(Cvar_VariableString("fs_game"), com_basegame->string))
Cvar_Set("fs_game", "");
// try to start up normally // try to start up normally
FS_Startup(com_basegame->string); FS_Startup(com_basegame->string);

View file

@ -504,6 +504,9 @@ void Cvar_Update( vmCvar_t *vmCvar );
void Cvar_Set( const char *var_name, const char *value ); void Cvar_Set( const char *var_name, const char *value );
// will create the variable with no flags if it doesn't exist // 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 ); void Cvar_SetSafe( const char *var_name, const char *value );
// sometimes we set variables from an untrusted source: fail if flags & CVAR_PROTECTED // sometimes we set variables from an untrusted source: fail if flags & CVAR_PROTECTED