diff --git a/dlls/cbase.h b/dlls/cbase.h index e56d763..a404d39 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -87,6 +87,8 @@ typedef enum { USE_OFF = 0, USE_ON = 1, USE_SET = 2, USE_TOGGLE = 3 } USE_TYPE; EXPORT extern void FireTargets( const char *targetName, CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); +void* GET_PRIVATE(const edict_t* pent); + typedef void (CBaseEntity::*BASEPTR)(void); typedef void (CBaseEntity::*ENTITYFUNCPTR)(CBaseEntity *pOther ); typedef void (CBaseEntity::*USEPTR)( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); @@ -806,6 +808,22 @@ template T * GetClassPtr( T *a ) return allocate ? (T*)RelocateEntIdx(a) : a; } +inline void* GET_PRIVATE(const edict_t* pent) +{ + if (pent) { + CBaseEntity* bent = (CBaseEntity*)pent->pvPrivateData; + + if (bent && bent->pev != &pent->v) { + // TODO: pev was linked wrong somehow. mem corruption? + ALERT(at_error, "Entity pev not linked to edict %d pev (%s)\n", + ENTINDEX(pent), STRING(pent->v.classname)); + return NULL; + } + + return bent; + } + return NULL; +} /* bit_PUSHBRUSH_DATA | bit_TOGGLE_DATA diff --git a/dlls/enginecallback.h b/dlls/enginecallback.h index 1979268..66c2890 100644 --- a/dlls/enginecallback.h +++ b/dlls/enginecallback.h @@ -103,12 +103,6 @@ EXPORT void DEBUG_MSG(ALERT_TYPE target, const char* format, ...); #define ENGINE_FPRINTF (*g_engfuncs.pfnEngineFprintf) #define ALLOC_PRIVATE (*g_engfuncs.pfnPvAllocEntPrivateData) -inline void *GET_PRIVATE( const edict_t *pent ) -{ - if ( pent ) - return pent->pvPrivateData; - return NULL; -} #define FREE_PRIVATE (*g_engfuncs.pfnFreeEntPrivateData) //#define STRING (*g_engfuncs.pfnSzFromIndex) diff --git a/dlls/util.cpp b/dlls/util.cpp index 1b00dbc..ea400ea 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -820,7 +820,7 @@ void WRITE_BYTES(uint8_t* bytes, int count) { // tests if a player would receive a message given a send mode // and the entity which is emitting the message bool TestMsgVis(edict_t* plr, int testEntIdx, int netMsgMode) { - CBaseEntity* ent = CBaseEntity::Instance(ENT(testEntIdx)); + CBaseEntity* ent = CBaseEntity::Instance(INDEXENT(testEntIdx)); if (!ent) { return false;