Destroy mod-created CVars when 'restart' is invoked

This commit is contained in:
Kyle Evans 2014-12-01 21:04:50 -06:00
parent ed5b0d902a
commit 8b88f14c96
3 changed files with 21 additions and 0 deletions

View file

@ -1515,6 +1515,22 @@ void UnlatchCVars (void)
} }
} }
void DestroyCVarsFlagged (DWORD flags)
{
FBaseCVar *cvar = CVars;
FBaseCVar *next = cvar;
while(cvar)
{
next = cvar->m_Next;
if(cvar->Flags & flags)
delete cvar;
cvar = next;
}
}
void C_SetCVarsToDefaults (void) void C_SetCVarsToDefaults (void)
{ {
FBaseCVar *cvar = CVars; FBaseCVar *cvar = CVars;

View file

@ -159,6 +159,7 @@ private:
friend FBaseCVar *FindCVar (const char *var_name, FBaseCVar **prev); friend FBaseCVar *FindCVar (const char *var_name, FBaseCVar **prev);
friend FBaseCVar *FindCVarSub (const char *var_name, int namelen); friend FBaseCVar *FindCVarSub (const char *var_name, int namelen);
friend void UnlatchCVars (void); friend void UnlatchCVars (void);
friend void DestroyCVarsFlagged (DWORD flags);
friend void C_ArchiveCVars (FConfigFile *f, uint32 filter); friend void C_ArchiveCVars (FConfigFile *f, uint32 filter);
friend void C_SetCVarsToDefaults (void); friend void C_SetCVarsToDefaults (void);
friend void FilterCompactCVars (TArray<FBaseCVar *> &cvars, uint32 filter); friend void FilterCompactCVars (TArray<FBaseCVar *> &cvars, uint32 filter);
@ -190,6 +191,9 @@ FBaseCVar *C_CreateCVar(const char *var_name, ECVarType var_type, DWORD flags);
// Called from G_InitNew() // Called from G_InitNew()
void UnlatchCVars (void); void UnlatchCVars (void);
// Destroy CVars with the matching flags; called from CCMD(restart)
void DestroyCVarsFlagged (DWORD flags);
// archive cvars to FILE f // archive cvars to FILE f
void C_ArchiveCVars (FConfigFile *f, uint32 filter); void C_ArchiveCVars (FConfigFile *f, uint32 filter);

View file

@ -2578,6 +2578,7 @@ void D_DoomMain (void)
new (&gameinfo) gameinfo_t; // Reset gameinfo new (&gameinfo) gameinfo_t; // Reset gameinfo
S_Shutdown(); // free all channels and delete playlist S_Shutdown(); // free all channels and delete playlist
C_ClearAliases(); // CCMDs won't be reinitialized so these need to be deleted here C_ClearAliases(); // CCMDs won't be reinitialized so these need to be deleted here
DestroyCVarsFlagged(CVAR_MOD); // Delete any cvar left by mods
GC::FullGC(); // perform one final garbage collection before deleting the class data GC::FullGC(); // perform one final garbage collection before deleting the class data
PClass::ClearRuntimeData(); // clear all runtime generated class data PClass::ClearRuntimeData(); // clear all runtime generated class data