Fix passing invalid ent to OnEntity forwards (bug 6119, r=KyleS).

--HG--
extra : rebase_source : f5477d7d36ef579c40b0547389e8eccaf129f69e
This commit is contained in:
Nicholas Hastings 2014-05-10 22:21:42 -04:00
parent 6b27a7fe46
commit b4ff034ac2

View File

@ -814,7 +814,9 @@ void SDKHooks::OnEntityCreated(CBaseEntity *pEntity)
// Call OnEntityCreated forward
int ref = gamehelpers->EntityToBCompatRef(pEntity);
int index = gamehelpers->ReferenceToIndex(ref);
if (m_EntityExists.IsBitSet(index) || (index > 0 && index <= playerhelpers->GetMaxClients()))
// This can be -1 for player ents before any players have connected
if (index == INVALID_EHANDLE_INDEX || m_EntityExists.IsBitSet(index) || (index > 0 && index <= playerhelpers->GetMaxClients()))
{
return;
}
@ -1587,13 +1589,16 @@ void SDKHooks::Hook_UsePost(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T
void SDKHooks::OnEntityDeleted(CBaseEntity *pEntity)
{
int entity = gamehelpers->EntityToBCompatRef(pEntity);
if (entity > 0 && entity <= playerhelpers->GetMaxClients())
int ref = gamehelpers->EntityToBCompatRef(pEntity);
int index = gamehelpers->ReferenceToIndex(ref);
// This can be -1 for player ents before any players have connected
if (index == INVALID_EHANDLE_INDEX || (index > 0 && index <= playerhelpers->GetMaxClients()))
{
return;
}
HandleEntityDeleted(pEntity, entity);
HandleEntityDeleted(pEntity, ref);
}
void SDKHooks::Hook_VPhysicsUpdate(IPhysicsObject *pPhysics)