Updated to include additional protection for PDATA.

This commit is contained in:
Twilight Suzuka 2006-01-03 21:48:59 +00:00
parent 60716cd346
commit c9e84c563d
3 changed files with 18 additions and 2 deletions

View File

@ -31,6 +31,11 @@ static cell AMX_NATIVE_CALL get_user_level(AMX *amx,cell *params)
static cell AMX_NATIVE_CALL set_user_level(AMX *amx,cell *params)
{
if(GetUserLevel(params[0]) > params[2])
{
MF_LogError(amx,AMX_ERR_NATIVE,"Must set to a level higher than current one!");
return 0;
}
SetUserLevel(params[1], params[2] );
return 1;
}

Binary file not shown.

View File

@ -11,10 +11,20 @@
#define EXTRAOFFSET 0 // no change in Windows builds
#endif // defined __linux__
inline edict_t* MF_GetEntityEdict( long& EntID )
{
if( (EntID > 0) && (EntID <= (gpGlobals->maxClients) ) )
return MF_GetPlayerEdict( EntID );
return NULL;
}
template <typename ValueType>
inline void SetPData( long& targetid, long offset, ValueType value, bool reset = false )
{
edict_t* target = MF_GetPlayerEdict( targetid );
edict_t* target = MF_GetEntityEdict( targetid );
if(target == NULL) return;
*((ValueType *)target->pvPrivateData + offset + EXTRAOFFSET) = value;
if(reset) UpdateBBHud( targetid );
};
@ -22,7 +32,8 @@ inline void SetPData( long& targetid, long offset, ValueType value, bool reset =
template <typename ValueType>
inline ValueType GetPData( long& targetid, long offset, ValueType value )
{
edict_t* target = MF_GetPlayerEdict( targetid );
edict_t* target = MF_GetEntityEdict( targetid );
if(target == NULL) return NULL;
return *((ValueType *)target->pvPrivateData + offset + EXTRAOFFSET);
}