From af0d46fcc16f55265499f982177727e247b51d97 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Mon, 17 Dec 2012 14:33:57 -0500 Subject: [PATCH] Fixed regressions in 3d66ab8565c1: * Fixed crash when prop/data ent is invalid. * Restored GetEntPropEnt/GetEntDataEnt2 functionality when logical ent support is not available. --- core/smn_entities.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/core/smn_entities.cpp b/core/smn_entities.cpp index da9c0a72..b0cf0bd7 100644 --- a/core/smn_entities.cpp +++ b/core/smn_entities.cpp @@ -620,14 +620,12 @@ static cell_t GetEntDataEnt2(IPluginContext *pContext, const cell_t *params) } CBaseHandle &hndl = *(CBaseHandle *)((uint8_t *)pEntity + offset); - int index = hndl.GetEntryIndex(); + CBaseEntity *pHandleEntity = g_HL2.ReferenceToEntity(hndl.GetEntryIndex()); - CEntInfo *pInfo = g_HL2.LookupEntity(index); - if (pInfo->m_SerialNumber != hndl.GetSerialNumber()) + if (!pHandleEntity || hndl != reinterpret_cast(pHandleEntity)->GetRefEHandle()) return -1; - int ref = g_HL2.IndexToReference(index); - return g_HL2.ReferenceToBCompatRef(ref); + return g_HL2.EntityToBCompatRef(pHandleEntity); } /* THIS GUY IS DEPRECATED. */ @@ -1511,14 +1509,12 @@ static cell_t GetEntPropEnt(IPluginContext *pContext, const cell_t *params) } CBaseHandle &hndl = *(CBaseHandle *)((uint8_t *)pEntity + offset); - int index = hndl.GetEntryIndex(); + CBaseEntity *pHandleEntity = g_HL2.ReferenceToEntity(hndl.GetEntryIndex()); - CEntInfo *pInfo = g_HL2.LookupEntity(index); - if (pInfo->m_SerialNumber != hndl.GetSerialNumber()) + if (!pHandleEntity || hndl != reinterpret_cast(pHandleEntity)->GetRefEHandle()) return -1; - int ref = g_HL2.IndexToReference(index); - return g_HL2.ReferenceToBCompatRef(ref); + return g_HL2.EntityToBCompatRef(pHandleEntity); } static cell_t SetEntPropEnt(IPluginContext *pContext, const cell_t *params)