mirror of
https://github.com/rehlds/reapi.git
synced 2024-12-29 08:05:36 +03:00
Added arg name for native params checks
Added NULLENT Fixed some checks
This commit is contained in:
parent
73c1151962
commit
7414e479ed
@ -17,6 +17,8 @@
|
||||
#define REAPI_VERISON_MAJOR 1
|
||||
#define REAPI_VERISON_MINOR 0
|
||||
|
||||
#define NULLENT -1
|
||||
|
||||
#include <reapi_const.inc>
|
||||
#include <reapi_engine.inc> // NOTE: only for ReHLDS
|
||||
#include <reapi_gamedll.inc> // NOTE: only for gamedll Counter-Strike (ReGameDLL_CS)
|
||||
|
@ -262,7 +262,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi.inc" />
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_const.inc" />
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_engine.inc" />
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_engine_const.inc" />
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_gamedll.inc" />
|
||||
|
@ -743,9 +743,6 @@
|
||||
<Filter>src</Filter>
|
||||
</None>
|
||||
<None Include="reapi.def" />
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_const.inc">
|
||||
<Filter>amxmodx\scripting\include</Filter>
|
||||
</None>
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_gamedll.inc">
|
||||
<Filter>amxmodx\scripting\include</Filter>
|
||||
</None>
|
||||
|
@ -66,7 +66,7 @@ cell AMX_NATIVE_CALL REU_GetProtocol(AMX *amx, cell *params)
|
||||
{
|
||||
enum args_e { arg_count, arg_index };
|
||||
|
||||
CHECK_ISPLAYER(params[arg_index]);
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
return g_ReunionApi->GetClientProtocol(params[arg_index] - 1);
|
||||
}
|
||||
@ -82,7 +82,7 @@ cell AMX_NATIVE_CALL REU_GetAuthtype(AMX *amx, cell *params)
|
||||
{
|
||||
enum args_e { arg_count, arg_index };
|
||||
|
||||
CHECK_ISPLAYER(params[arg_index]);
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
return g_ReunionApi->GetClientAuthtype(params[arg_index] - 1);
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#define CHECK_ISPLAYER(x) if (x <= 0 || x > gpGlobals->maxClients) { MF_LogError(amx, AMX_ERR_NATIVE, "invalid player index %i", x); return FALSE; }
|
||||
#define CHECK_ISENTITY(x) if (x > gpGlobals->maxEntities) { MF_LogError(amx, AMX_ERR_NATIVE, "invalid entity index %i", x); return FALSE; }
|
||||
#define CHECK_ISPLAYER(x) if (params[x] <= 0 || params[x] > gpGlobals->maxClients) { MF_LogError(amx, AMX_ERR_NATIVE, "invalid player index %i [%s]", params[x], #x); return FALSE; }
|
||||
#define CHECK_ISENTITY(x) if (params[x] > gpGlobals->maxEntities) { MF_LogError(amx, AMX_ERR_NATIVE, "invalid entity index %i [%s]", params[x], #x); return FALSE; }
|
||||
|
||||
class CAmxArg
|
||||
{
|
||||
public:
|
||||
CAmxArg(AMX* amx, cell value) : m_amx(amx), m_value(value) {}
|
||||
operator float&() const
|
||||
operator float() const
|
||||
{
|
||||
return *(float *)m_value;
|
||||
}
|
||||
@ -17,7 +17,7 @@ public:
|
||||
}
|
||||
operator entvars_s*() const
|
||||
{
|
||||
auto pev = PEV(m_value);
|
||||
auto pev = PEV(m_value); // faster
|
||||
return m_value < 0 ? nullptr : pev;
|
||||
}
|
||||
operator int() const
|
||||
@ -34,8 +34,9 @@ public:
|
||||
}
|
||||
operator CBaseEntity*() const
|
||||
{
|
||||
auto player = g_ReGameFuncs->UTIL_PlayerByIndex(m_value);
|
||||
return m_value < 0 ? nullptr : player;
|
||||
if (m_value < 0)
|
||||
return nullptr;
|
||||
return g_ReGameFuncs->UTIL_PlayerByIndex(m_value);
|
||||
}
|
||||
operator PLAYER_ANIM() const
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ cell AMX_NATIVE_CALL rg_set_animation(AMX *amx, cell *params)
|
||||
{
|
||||
enum args_e { arg_count, arg_index, arg_anim };
|
||||
|
||||
CHECK_ISPLAYER(params[arg_index]);
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
ICSPlayer *pPlayer = g_ReGameFuncs->INDEX_TO_CSPLAYER(params[arg_index]);
|
||||
if (pPlayer == nullptr || !pPlayer->IsConnected()) {
|
||||
@ -41,7 +41,7 @@ cell AMX_NATIVE_CALL rg_add_account(AMX *amx, cell *params)
|
||||
{
|
||||
enum args_e { arg_count, arg_index, arg_amount, arg_track_change };
|
||||
|
||||
CHECK_ISPLAYER(params[arg_index]);
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
ICSPlayer *pPlayer = g_ReGameFuncs->INDEX_TO_CSPLAYER(params[arg_index]);
|
||||
if (pPlayer == nullptr || !pPlayer->IsConnected()) {
|
||||
@ -67,7 +67,7 @@ cell AMX_NATIVE_CALL rg_give_item(AMX *amx, cell *params)
|
||||
{
|
||||
enum args_e { arg_count, arg_index, arg_item };
|
||||
|
||||
CHECK_ISPLAYER(params[arg_index]);
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
ICSPlayer *pPlayer = g_ReGameFuncs->INDEX_TO_CSPLAYER(params[arg_index]);
|
||||
if (pPlayer == nullptr || !pPlayer->IsConnected()) {
|
||||
@ -93,7 +93,7 @@ cell AMX_NATIVE_CALL rg_give_default_items(AMX *amx, cell *params)
|
||||
{
|
||||
enum args_e { arg_count, arg_index };
|
||||
|
||||
CHECK_ISPLAYER(params[arg_index]);
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
ICSPlayer *pPlayer = g_ReGameFuncs->INDEX_TO_CSPLAYER(params[arg_index]);
|
||||
if (pPlayer == nullptr || !pPlayer->IsConnected()) {
|
||||
@ -119,7 +119,7 @@ cell AMX_NATIVE_CALL rg_give_shield(AMX *amx, cell *params)
|
||||
{
|
||||
enum args_e { arg_count, arg_index, arg_deploy };
|
||||
|
||||
CHECK_ISPLAYER(params[arg_index]);
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
ICSPlayer *pPlayer = g_ReGameFuncs->INDEX_TO_CSPLAYER(params[arg_index]);
|
||||
if (pPlayer == nullptr || !pPlayer->IsConnected()) {
|
||||
@ -150,8 +150,8 @@ cell AMX_NATIVE_CALL rg_dmg_radius(AMX *amx, cell *params)
|
||||
{
|
||||
enum args_e { arg_count, arg_vec, arg_inflictor, arg_attacker, arg_damage, arg_radius, arg_ignore_class, arg_dmg_type };
|
||||
|
||||
CHECK_ISENTITY(params[arg_inflictor]);
|
||||
CHECK_ISENTITY(params[arg_attacker]);
|
||||
CHECK_ISENTITY(arg_inflictor);
|
||||
CHECK_ISENTITY(arg_attacker);
|
||||
|
||||
CAmxArgs args(amx, params);
|
||||
g_ReGameFuncs->RadiusDamage(args[arg_vec], args[arg_inflictor], args[arg_attacker], args[arg_damage], args[arg_radius], args[arg_ignore_class], args[arg_dmg_type]);
|
||||
@ -186,8 +186,8 @@ cell AMX_NATIVE_CALL rg_multidmg_apply(AMX *amx, cell *params)
|
||||
{
|
||||
enum args_e { arg_count, arg_inflictor, arg_attacker };
|
||||
|
||||
CHECK_ISENTITY(params[arg_inflictor]);
|
||||
CHECK_ISENTITY(params[arg_attacker]);
|
||||
CHECK_ISENTITY(arg_inflictor);
|
||||
CHECK_ISENTITY(arg_attacker);
|
||||
|
||||
CAmxArgs args(amx, params);
|
||||
g_ReGameFuncs->ApplyMultiDamage(args[arg_inflictor], args[arg_attacker]);
|
||||
@ -211,8 +211,8 @@ cell AMX_NATIVE_CALL rg_multidmg_add(AMX *amx, cell *params)
|
||||
{
|
||||
enum args_e { arg_count, arg_inflictor, arg_victim, arg_damage, arg_dmg_type };
|
||||
|
||||
CHECK_ISENTITY(params[arg_inflictor]);
|
||||
CHECK_ISENTITY(params[arg_victim]);
|
||||
CHECK_ISENTITY(arg_inflictor);
|
||||
CHECK_ISENTITY(arg_victim);
|
||||
|
||||
if (params[arg_victim] < 0) { // null
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "rg_multidmg_add: victim == null");
|
||||
@ -247,8 +247,8 @@ cell AMX_NATIVE_CALL rg_fire_bullets(AMX *amx, cell *params)
|
||||
{
|
||||
enum args_e { arg_count, arg_inflictor, arg_attacker, arg_shots, arg_vecSrc, arg_dir, arg_spread, arg_dist, arg_bullet_type, arg_tracefrq, arg_dmg };
|
||||
|
||||
CHECK_ISENTITY(params[arg_inflictor]);
|
||||
CHECK_ISENTITY(params[arg_attacker]);
|
||||
CHECK_ISENTITY(arg_inflictor);
|
||||
CHECK_ISENTITY(arg_attacker);
|
||||
|
||||
CAmxArgs args(amx, params);
|
||||
ICSEntity *pInflictor = args[arg_inflictor];
|
||||
@ -293,8 +293,8 @@ cell AMX_NATIVE_CALL rg_fire_bullets3(AMX *amx, cell *params)
|
||||
{
|
||||
enum args_e { arg_count, arg_inflictor, arg_attacker, arg_vecSrc, arg_dir, arg_spread, arg_dist, arg_penetration, arg_bullet_type, arg_dmg, arg_range_mod, arg_pistol, arg_rand, arg_out };
|
||||
|
||||
CHECK_ISENTITY(params[arg_inflictor]);
|
||||
CHECK_ISENTITY(params[arg_attacker]);
|
||||
CHECK_ISENTITY(arg_inflictor);
|
||||
CHECK_ISENTITY(arg_attacker);
|
||||
|
||||
CAmxArgs args(amx, params);
|
||||
ICSEntity *pInflictor = args[arg_inflictor];
|
||||
@ -476,7 +476,7 @@ cell AMX_NATIVE_CALL rg_find_ent_by_owner(AMX *amx, cell *params)
|
||||
{
|
||||
enum args_e { arg_count, arg_start_index, arg_classname, arg_onwer };
|
||||
|
||||
CHECK_ISENTITY(params[arg_onwer]);
|
||||
CHECK_ISENTITY(arg_onwer);
|
||||
|
||||
const char* value = getAmxString(amx, params[arg_classname]);
|
||||
edict_t *pOwner = edictByIndex(params[arg_onwer]);
|
||||
@ -564,7 +564,7 @@ cell AMX_NATIVE_CALL rg_remove_all_items(AMX *amx, cell *params)
|
||||
{
|
||||
enum args_e { arg_count, arg_index, arg_suit };
|
||||
|
||||
CHECK_ISPLAYER(params[arg_index]);
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
ICSPlayer *pPlayer = g_ReGameFuncs->INDEX_TO_CSPLAYER(params[arg_index]);
|
||||
if (pPlayer == nullptr || !pPlayer->IsConnected()) {
|
||||
@ -590,7 +590,7 @@ cell AMX_NATIVE_CALL rg_remove_item(AMX *amx, cell *params)
|
||||
{
|
||||
enum args_e { arg_count, arg_index, arg_item_name };
|
||||
|
||||
CHECK_ISPLAYER(params[arg_index]);
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = (CBasePlayer *)g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
|
Loading…
Reference in New Issue
Block a user