mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 14:25:38 +03:00
Updated to include additional protection for PDATA.
This commit is contained in:
parent
60716cd346
commit
c9e84c563d
@ -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)
|
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] );
|
SetUserLevel(params[1], params[2] );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
BIN
dlls/BB/bb.ncb
BIN
dlls/BB/bb.ncb
Binary file not shown.
@ -11,10 +11,20 @@
|
|||||||
#define EXTRAOFFSET 0 // no change in Windows builds
|
#define EXTRAOFFSET 0 // no change in Windows builds
|
||||||
#endif // defined __linux__
|
#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>
|
template <typename ValueType>
|
||||||
inline void SetPData( long& targetid, long offset, ValueType value, bool reset = false )
|
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;
|
*((ValueType *)target->pvPrivateData + offset + EXTRAOFFSET) = value;
|
||||||
if(reset) UpdateBBHud( targetid );
|
if(reset) UpdateBBHud( targetid );
|
||||||
};
|
};
|
||||||
@ -22,7 +32,8 @@ inline void SetPData( long& targetid, long offset, ValueType value, bool reset =
|
|||||||
template <typename ValueType>
|
template <typename ValueType>
|
||||||
inline ValueType GetPData( long& targetid, long offset, ValueType value )
|
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);
|
return *((ValueType *)target->pvPrivateData + offset + EXTRAOFFSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user