diff --git a/core/smn_entities.cpp b/core/smn_entities.cpp index fd6eafda..e957ed38 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. */ @@ -1498,14 +1496,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)