Fixed regressions in a988c42d4248:
authorNicholas Hastings <skamonkey@gmail.com>
Mon Dec 17 14:33:57 2012 -0500 (2012-12-17)
changeset 37090ba500823362
parent 3708 a988c42d4248
child 3710 5559ea22b6b5
Fixed regressions in a988c42d4248:
* Fixed crash when prop/data ent is invalid.
* Restored GetEntPropEnt/GetEntDataEnt2 functionality when logical ent support is not available.
core/smn_entities.cpp
     1.1 --- a/core/smn_entities.cpp	Sun Dec 16 19:52:31 2012 -0500
     1.2 +++ b/core/smn_entities.cpp	Mon Dec 17 14:33:57 2012 -0500
     1.3 @@ -620,14 +620,12 @@
     1.4  	}
     1.5  
     1.6  	CBaseHandle &hndl = *(CBaseHandle *)((uint8_t *)pEntity + offset);
     1.7 -	int index = hndl.GetEntryIndex();
     1.8 +	CBaseEntity *pHandleEntity = g_HL2.ReferenceToEntity(hndl.GetEntryIndex());
     1.9  
    1.10 -	CEntInfo *pInfo = g_HL2.LookupEntity(index);
    1.11 -	if (pInfo->m_SerialNumber != hndl.GetSerialNumber())
    1.12 +	if (!pHandleEntity || hndl != reinterpret_cast<IHandleEntity *>(pHandleEntity)->GetRefEHandle())
    1.13  		return -1;
    1.14  
    1.15 -	int ref = g_HL2.IndexToReference(index);
    1.16 -	return g_HL2.ReferenceToBCompatRef(ref);
    1.17 +	return g_HL2.EntityToBCompatRef(pHandleEntity);
    1.18  }
    1.19  
    1.20  /* THIS GUY IS DEPRECATED. */
    1.21 @@ -1498,14 +1496,12 @@
    1.22  	}
    1.23  
    1.24  	CBaseHandle &hndl = *(CBaseHandle *)((uint8_t *)pEntity + offset);
    1.25 -	int index = hndl.GetEntryIndex();
    1.26 +	CBaseEntity *pHandleEntity = g_HL2.ReferenceToEntity(hndl.GetEntryIndex());
    1.27  
    1.28 -	CEntInfo *pInfo = g_HL2.LookupEntity(index);
    1.29 -	if (pInfo->m_SerialNumber != hndl.GetSerialNumber())
    1.30 +	if (!pHandleEntity || hndl != reinterpret_cast<IHandleEntity *>(pHandleEntity)->GetRefEHandle())
    1.31  		return -1;
    1.32  
    1.33 -	int ref = g_HL2.IndexToReference(index);
    1.34 -	return g_HL2.ReferenceToBCompatRef(ref);
    1.35 +	return g_HL2.EntityToBCompatRef(pHandleEntity);
    1.36  }
    1.37  
    1.38  static cell_t SetEntPropEnt(IPluginContext *pContext, const cell_t *params)