Compare commits

..
Author SHA1 Message Date
BotoX 7fb35c5f6a fix rare crash bug in SDKTools GetGameRulesProxyEnt 2019-09-10 20:46:55 +02:00
3 changed files with 36 additions and 13 deletions
+4
View File
@@ -53,6 +53,10 @@ static CBaseEntity *FindEntityByNetClass(int start, const char *classname)
if (network == NULL)
continue;
IHandleEntity *pHandleEnt = network->GetEntityHandle();
if (pHandleEnt == NULL)
continue;
ServerClass *sClass = network->GetServerClass();
const char *name = sClass->GetName();
+30 -13
View File
@@ -52,6 +52,7 @@ void EntityOutputManager::Shutdown()
return;
}
EntityOutputs->Destroy();
ClassNames->Destroy();
fireOutputDetour->Destroy();
}
@@ -65,6 +66,7 @@ void EntityOutputManager::Init()
return;
}
EntityOutputs = adtfactory->CreateBasicTrie();
ClassNames = adtfactory->CreateBasicTrie();
}
@@ -118,30 +120,45 @@ bool EntityOutputManager::FireEventDetour(void *pOutput, CBaseEntity *pActivator
return true;
}
char sOutput[20];
ke::SafeSprintf(sOutput, sizeof(sOutput), "%p", pOutput);
// attempt to directly lookup a hook using the pOutput pointer
OutputNameStruct *pOutputName = NULL;
const char *classname = gamehelpers->GetEntityClassname(pCaller);
if (!classname)
bool fastLookup = false;
// Fast lookup failed - check the slow way for hooks that haven't fired yet
if ((fastLookup = EntityOutputs->Retrieve(sOutput, (void **)&pOutputName)) == false)
{
return true;
}
const char *classname = gamehelpers->GetEntityClassname(pCaller);
if (!classname)
{
return true;
}
const char *outputname = FindOutputName(pOutput, pCaller);
if (!outputname)
{
return true;
}
const char *outputname = FindOutputName(pOutput, pCaller);
if (!outputname)
{
return true;
}
pOutputName = FindOutputPointer(classname, outputname, false);
pOutputName = FindOutputPointer(classname, outputname, false);
if (!pOutputName)
{
return true;
if (!pOutputName)
{
return true;
}
}
if (!pOutputName->hooks.empty())
{
if (!fastLookup)
{
// hook exists on this classname and output - map it into our quick find trie
EntityOutputs->Insert(sOutput, pOutputName);
}
SourceHook::List<omg_hooks *>::iterator _iter;
omg_hooks *hook;
+2
View File
@@ -121,6 +121,8 @@ private:
const char *FindOutputName(void *pOutput, CBaseEntity *pCaller);
//Maps CEntityOutput * to a OutputNameStruct
IBasicTrie *EntityOutputs;
// Maps classname to a ClassNameStruct
IBasicTrie *ClassNames;