Fixed bad error checking routine
This commit is contained in:
parent
766246648d
commit
77aa0f4f8e
@ -9,7 +9,7 @@ static cell AMX_NATIVE_CALL get_user_astats(AMX *amx, cell *params) /* 6 param *
|
||||
int index = params[1];
|
||||
CHECK_PLAYER(index);
|
||||
int attacker = params[2];
|
||||
CHECK_PLAYER(attacker);
|
||||
CHECK_PLAYERRANGE(attacker);
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
if (pPlayer->attackers[attacker].hits){
|
||||
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
|
||||
@ -36,7 +36,7 @@ static cell AMX_NATIVE_CALL get_user_vstats(AMX *amx, cell *params) /* 6 param *
|
||||
int index = params[1];
|
||||
CHECK_PLAYER(index);
|
||||
int victim = params[2];
|
||||
CHECK_PLAYER(victim);
|
||||
CHECK_PLAYERRANGE(victim);
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
if (pPlayer->victims[victim].hits){
|
||||
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
|
||||
|
@ -125,6 +125,13 @@ bool isModuleActive();
|
||||
} \
|
||||
}
|
||||
|
||||
#define CHECK_PLAYERRANGE(x) \
|
||||
if (x > gpGlobals->maxClients || x < 0) \
|
||||
{ \
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
#define CHECK_NONPLAYER(x) \
|
||||
if (x < 1 || x <= gpGlobals->maxClients || x > gpGlobals->maxEntities) { \
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Non-player entity %d out of range", x); \
|
||||
|
@ -37,7 +37,7 @@ static cell AMX_NATIVE_CALL get_user_astats(AMX *amx, cell *params) /* 6 param *
|
||||
int index = params[1];
|
||||
CHECK_PLAYER(index);
|
||||
int attacker = params[2];
|
||||
CHECK_PLAYER(attacker);
|
||||
CHECK_PLAYERRANGE(attacker);
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
if (pPlayer->attackers[attacker].hits){
|
||||
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
|
||||
@ -64,7 +64,7 @@ static cell AMX_NATIVE_CALL get_user_vstats(AMX *amx, cell *params) /* 6 param *
|
||||
int index = params[1];
|
||||
CHECK_PLAYER(index);
|
||||
int victim = params[2];
|
||||
CHECK_PLAYER(victim);
|
||||
CHECK_PLAYERRANGE(victim);
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
if (pPlayer->victims[victim].hits){
|
||||
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
|
||||
|
@ -140,6 +140,13 @@ edict_t *FindEntityByClassname(edict_t *pentStart, const char *szName);
|
||||
} \
|
||||
}
|
||||
|
||||
#define CHECK_PLAYERRANGE(x) \
|
||||
if (x > gpGlobals->maxClients || x < 0) \
|
||||
{ \
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
#define CHECK_NONPLAYER(x) \
|
||||
if (x < 1 || x <= gpGlobals->maxClients || x > gpGlobals->maxEntities) { \
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Non-player entity %d out of range", x); \
|
||||
|
@ -38,7 +38,7 @@ static cell AMX_NATIVE_CALL get_user_astats(AMX *amx, cell *params) /* 6 param *
|
||||
int index = params[1];
|
||||
CHECK_PLAYER(index);
|
||||
int attacker = params[2];
|
||||
CHECK_PLAYER(attacker);
|
||||
CHECK_PLAYERRANGE(attacker);
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
if (pPlayer->attackers[attacker].hits){
|
||||
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
|
||||
@ -65,7 +65,7 @@ static cell AMX_NATIVE_CALL get_user_vstats(AMX *amx, cell *params) /* 6 param *
|
||||
int index = params[1];
|
||||
CHECK_PLAYER(index);
|
||||
int victim = params[2];
|
||||
CHECK_PLAYER(victim);
|
||||
CHECK_PLAYERRANGE(victim);
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
if (pPlayer->victims[victim].hits){
|
||||
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
|
||||
|
@ -134,6 +134,13 @@ bool util_strncmp( const char *sz1, const char *sz2, int size);
|
||||
} \
|
||||
}
|
||||
|
||||
#define CHECK_PLAYERRANGE(x) \
|
||||
if (x > gpGlobals->maxClients || x < 0) \
|
||||
{ \
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
#define CHECK_NONPLAYER(x) \
|
||||
if (x < 1 || x <= gpGlobals->maxClients || x > gpGlobals->maxEntities) { \
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Non-player entity %d out of range", x); \
|
||||
|
@ -38,7 +38,7 @@ static cell AMX_NATIVE_CALL get_user_astats(AMX *amx, cell *params) /* 6 param *
|
||||
int index = params[1];
|
||||
CHECK_PLAYER(index);
|
||||
int attacker = params[2];
|
||||
CHECK_PLAYER(attacker);
|
||||
CHECK_PLAYERRANGE(attacker);
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
if (pPlayer->attackers[attacker].hits){
|
||||
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
|
||||
@ -65,7 +65,7 @@ static cell AMX_NATIVE_CALL get_user_vstats(AMX *amx, cell *params) /* 6 param *
|
||||
int index = params[1];
|
||||
CHECK_PLAYER(index);
|
||||
int victim = params[2];
|
||||
CHECK_PLAYER(victim);
|
||||
CHECK_PLAYERRANGE(victim);
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
if (pPlayer->victims[victim].hits){
|
||||
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
|
||||
|
@ -148,6 +148,13 @@ bool ignoreBots (edict_t *pEnt, edict_t *pOther = NULL);
|
||||
} \
|
||||
}
|
||||
|
||||
#define CHECK_PLAYERRANGE(x) \
|
||||
if (x > gpGlobals->maxClients || x < 0) \
|
||||
{ \
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
#define GETEDICT(n) \
|
||||
((n >= 1 && n <= gpGlobals->maxClients) ? MF_GetPlayerEdict(n) : INDEXENT(n))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user