void ConVarManager::OnSourceModShutdown() { List<ConVarInfo *>::iterator iter = m_ConVars.begin(); HandleSecurity sec(NULL, g_pCoreIdent); /* Iterate list of ConVarInfo structures, remove every one of them */ while (iter != m_ConVars.end()) { ConVarInfo *pInfo = (*iter); iter = m_ConVars.erase(iter); handlesys->FreeHandle(pInfo->handle, &sec); if (pInfo->pChangeForward != NULL) { forwardsys->ReleaseForward(pInfo->pChangeForward); } if (pInfo->sourceMod) { /* If we created it, we won't be tracking it, therefore it is * safe to remove everything in one go. */ META_UNREGCVAR(pInfo->pVar); delete [] pInfo->pVar->GetName(); delete [] pInfo->pVar->GetHelpText(); delete [] pInfo->pVar->GetDefault(); delete pInfo->pVar; } else { /* If we didn't create it, we might be tracking it. Also, * it could be unreadable. */ UntrackConCommandBase(pInfo->pVar, this); } /* It's not safe to read the name here, so we simply delete the * the info struct and clear the lookup cache at the end. */ delete pInfo; } convar_cache.clear(); g_Players.RemoveClientListener(this); /* Remove the 'convars' option from the 'sm' console command */ rootmenu->RemoveRootConsoleCommand("cvars", this); scripts->RemovePluginsListener(this); /* Remove the 'ConVar' handle type */ handlesys->RemoveType(m_ConVarType, g_pCoreIdent); }
void ConVarManager::OnSourceModShutdown() { List<ConVarInfo *>::iterator iter = m_ConVars.begin(); HandleSecurity sec(NULL, g_pCoreIdent); /* Iterate list of ConVarInfo structures, remove every one of them */ while (iter != m_ConVars.end()) { ConVarInfo *pInfo = (*iter); iter = m_ConVars.erase(iter); g_HandleSys.FreeHandle(pInfo->handle, &sec); if (pInfo->pChangeForward != NULL) { g_Forwards.ReleaseForward(pInfo->pChangeForward); } if (pInfo->sourceMod) { /* If we created it, we won't be tracking it, therefore it is * safe to remove everything in one go. */ META_UNREGCVAR(pInfo->pVar); delete [] pInfo->pVar->GetName(); delete [] pInfo->pVar->GetHelpText(); delete [] pInfo->pVar->GetDefault(); delete pInfo->pVar; } else { /* If we didn't create it, we might be tracking it. Also, * it could be unreadable. */ UntrackConCommandBase(pInfo->pVar, this); } /* It's not safe to read the name here, so we simply delete the * the info struct and clear the lookup cache at the end. */ delete pInfo; } convar_cache.clear(); #if SOURCE_ENGINE != SE_DARKMESSIAH /* Unhook things */ if (m_bIsDLLQueryHooked) { SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, OnQueryCvarValueFinished, gamedll, this, &ConVarManager::OnQueryCvarValueFinished, false); m_bIsDLLQueryHooked = false; } else if (m_bIsVSPQueryHooked) { SH_REMOVE_HOOK_MEMFUNC(IServerPluginCallbacks, OnQueryCvarValueFinished, vsp_interface, this, &ConVarManager::OnQueryCvarValueFinished, false); m_bIsVSPQueryHooked = false; } #endif SH_REMOVE_HOOK_STATICFUNC(ICvar, CallGlobalChangeCallbacks, icvar, OnConVarChanged, false); /* Remove the 'convars' option from the 'sm' console command */ g_RootMenu.RemoveRootConsoleCommand("cvars", this); g_PluginSys.RemovePluginsListener(this); /* Remove the 'ConVar' handle type */ g_HandleSys.RemoveType(m_ConVarType, g_pCoreIdent); }