2005-12-06 22:47:02 +00:00
|
|
|
// prevent double include
|
|
|
|
#ifndef __PDATA_H__
|
|
|
|
#define __PDATA_H__
|
|
|
|
|
|
|
|
#include <extdll.h>
|
|
|
|
#include "amxxmodule.h"
|
|
|
|
|
|
|
|
#if defined __linux__
|
|
|
|
#define EXTRAOFFSET 5 // offsets 5 higher in Linux builds
|
|
|
|
#else
|
|
|
|
#define EXTRAOFFSET 0 // no change in Windows builds
|
|
|
|
#endif // defined __linux__
|
|
|
|
|
2006-01-03 21:48:59 +00:00
|
|
|
inline edict_t* MF_GetEntityEdict( long& EntID )
|
|
|
|
{
|
|
|
|
if( (EntID > 0) && (EntID <= (gpGlobals->maxClients) ) )
|
|
|
|
return MF_GetPlayerEdict( EntID );
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-12-06 22:47:02 +00:00
|
|
|
template <typename ValueType>
|
|
|
|
inline void SetPData( long& targetid, long offset, ValueType value, bool reset = false )
|
|
|
|
{
|
2006-01-03 21:48:59 +00:00
|
|
|
edict_t* target = MF_GetEntityEdict( targetid );
|
|
|
|
if(target == NULL) return;
|
|
|
|
|
2005-12-06 22:47:02 +00:00
|
|
|
*((ValueType *)target->pvPrivateData + offset + EXTRAOFFSET) = value;
|
|
|
|
if(reset) UpdateBBHud( targetid );
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename ValueType>
|
|
|
|
inline ValueType GetPData( long& targetid, long offset, ValueType value )
|
|
|
|
{
|
2006-01-03 21:48:59 +00:00
|
|
|
edict_t* target = MF_GetEntityEdict( targetid );
|
|
|
|
if(target == NULL) return NULL;
|
2005-12-06 22:47:02 +00:00
|
|
|
return *((ValueType *)target->pvPrivateData + offset + EXTRAOFFSET);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|