now fixing up the CVar hash table in Cvar_Nuke

This commit is contained in:
myT 2020-03-30 03:09:25 +02:00
parent ae30c5a311
commit 89aca4069e
2 changed files with 21 additions and 0 deletions

View file

@ -138,6 +138,8 @@ chg: r_fullbright is now latched again
chg: negative r_swapInterval values will request adaptive V-Sync when using an OpenGL back-end
fix: removing CVars through unset/cvar_trim/cvar_restart could leave data in an invalid state
fix: r_detailTextures 0 would mess up shaders where "detail" was used in a stage that isn't the last one
fix: dynamic lights could incorrectly stop applying to moving entities (e.g. cpm25 elevator)

View file

@ -881,6 +881,25 @@ static void Cvar_Toggle_f( void )
static void Cvar_Nuke( cvar_t* var )
{
// remove this cvar from the hash table so that
// a) it doesn't show up as existing, and
// b) it doesn't make other registered cvars not show up as existing
// (a zeroed cvar_t struct would cause an early exit in Cvar_FindVar)
const long hash = Cvar_Hash( var->name );
cvar_t** hashVarIter = &hashTable[hash];
for ( ;; ) {
cvar_t* const hashVar = *hashVarIter;
if ( hashVar == NULL ) {
Com_Printf( "ERROR: CVar '%s' not found in hash map\n", var->name );
break;
}
if ( hashVar == var ) {
*hashVarIter = var->hashNext;
break;
}
hashVarIter = &hashVar->hashNext;
}
if ( var->name )
Z_Free( var->name );