From de182882f1fd15b8bbe15e408ee91e332f7af9c8 Mon Sep 17 00:00:00 2001 From: Thilo Schulz Date: Wed, 24 Aug 2011 14:47:57 +0000 Subject: [PATCH] Fix auto game-restart when disconnecting from a server that explicitly set fs_game to "baseq3" instead of "" --- code/client/cl_parse.c | 4 +++- code/qcommon/cvar.c | 9 +++++++-- code/qcommon/files.c | 11 +++-------- code/qcommon/q_shared.h | 4 +++- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/code/client/cl_parse.c b/code/client/cl_parse.c index e269be35..78f4a921 100644 --- a/code/client/cl_parse.c +++ b/code/client/cl_parse.c @@ -538,12 +538,14 @@ void CL_ParseGamestate( msg_t *msg ) { CL_StopRecord_f(); // reinitialize the filesystem if the game directory has changed - if(FS_ConditionalRestart(clc.checksumFeed, qfalse) && !cls.oldGameSet) + if(!cls.oldGameSet && (Cvar_Flags("fs_game") & CVAR_MODIFIED)) { cls.oldGameSet = qtrue; Q_strncpyz(cls.oldGame, oldGame, sizeof(cls.oldGame)); } + FS_ConditionalRestart(clc.checksumFeed, qfalse); + // This used to call CL_StartHunkUsers, but now we enter the download state before loading the // cgame CL_InitDownloads(); diff --git a/code/qcommon/cvar.c b/code/qcommon/cvar.c index 6a090d68..9321e9c7 100644 --- a/code/qcommon/cvar.c +++ b/code/qcommon/cvar.c @@ -168,10 +168,15 @@ int Cvar_Flags(const char *var_name) { cvar_t *var; - if(! (var = Cvar_FindVar(var_name)) ) + if(!(var = Cvar_FindVar(var_name))) return CVAR_NONEXISTENT; else - return var->flags; + { + if(var->modified) + return var->flags | CVAR_MODIFIED; + else + return var->flags; + } } /* diff --git a/code/qcommon/files.c b/code/qcommon/files.c index d2e906a9..7e4d9e2e 100644 --- a/code/qcommon/files.c +++ b/code/qcommon/files.c @@ -3879,13 +3879,13 @@ void FS_Restart( int checksumFeed ) { /* ================= FS_ConditionalRestart -restart if necessary + +Restart if necessary +Return qtrue if restarting due to game directory changed, qfalse otherwise ================= */ qboolean FS_ConditionalRestart(int checksumFeed, qboolean disconnect) { - int retval; - if(fs_gamedirvar->modified) { if(FS_FilenameCompare(lastValidGame, fs_gamedirvar->string) && @@ -3896,13 +3896,8 @@ qboolean FS_ConditionalRestart(int checksumFeed, qboolean disconnect) return qtrue; } else - { fs_gamedirvar->modified = qfalse; - retval = qtrue; - } } - else - retval = qfalse; if(checksumFeed != fs_checksumFeed) FS_Restart(checksumFeed); diff --git a/code/qcommon/q_shared.h b/code/qcommon/q_shared.h index 8257bee6..b925edd4 100644 --- a/code/qcommon/q_shared.h +++ b/code/qcommon/q_shared.h @@ -888,7 +888,9 @@ default values. #define CVAR_SERVER_CREATED 0x0800 // cvar was created by a server the client connected to. #define CVAR_VM_CREATED 0x1000 // cvar was created exclusively in one of the VMs. #define CVAR_PROTECTED 0x2000 // prevent modifying this var from VMs or the server -#define CVAR_NONEXISTENT 0xFFFFFFFF // Cvar doesn't exist. +// These flags are only returned by the Cvar_Flags() function +#define CVAR_MODIFIED 0x40000000 // Cvar was modified +#define CVAR_NONEXISTENT 0x80000000 // Cvar doesn't exist. // nothing outside the Cvar_*() functions should modify these fields! typedef struct cvar_s cvar_t;