fixed a bug where the TE natives could double-free on exit and crash

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401463
This commit is contained in:
David Anderson 2007-09-23 06:51:44 +00:00
parent 0059d92b61
commit 3ca013d7f0

View File

@ -38,6 +38,7 @@ SH_DECL_HOOK5_void(IVEngineServer, PlaybackTempEntity, SH_NOATTRIB, 0, IRecipien
CellRecipientFilter g_TERecFilter; CellRecipientFilter g_TERecFilter;
TempEntityInfo *g_CurrentTE = NULL; TempEntityInfo *g_CurrentTE = NULL;
int g_TEPlayers[256]; int g_TEPlayers[256];
bool tenatives_initialized = false;
/************************* /*************************
* * * *
@ -49,10 +50,16 @@ void TempEntHooks::Initialize()
{ {
m_TEHooks = adtfactory->CreateBasicTrie(); m_TEHooks = adtfactory->CreateBasicTrie();
plsys->AddPluginsListener(this); plsys->AddPluginsListener(this);
tenatives_initialized = true;
} }
void TempEntHooks::Shutdown() void TempEntHooks::Shutdown()
{ {
if (!tenatives_initialized)
{
return;
}
plsys->RemovePluginsListener(this); plsys->RemovePluginsListener(this);
List<TEHookInfo *>::iterator iter; List<TEHookInfo *>::iterator iter;
for (iter=m_HookInfo.begin(); iter!=m_HookInfo.end(); iter++) for (iter=m_HookInfo.begin(); iter!=m_HookInfo.end(); iter++)
@ -65,6 +72,7 @@ void TempEntHooks::Shutdown()
_DecRefCounter(); _DecRefCounter();
} }
m_TEHooks->Destroy(); m_TEHooks->Destroy();
tenatives_initialized = false;
} }
void TempEntHooks::OnPluginUnloaded(IPlugin *plugin) void TempEntHooks::OnPluginUnloaded(IPlugin *plugin)