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_MAJOR 1
|
||||||
#define REAPI_VERISON_MINOR 0
|
#define REAPI_VERISON_MINOR 0
|
||||||
|
|
||||||
|
#define NULLENT -1
|
||||||
|
|
||||||
#include <reapi_const.inc>
|
#include <reapi_const.inc>
|
||||||
#include <reapi_engine.inc> // NOTE: only for ReHLDS
|
#include <reapi_engine.inc> // NOTE: only for ReHLDS
|
||||||
#include <reapi_gamedll.inc> // NOTE: only for gamedll Counter-Strike (ReGameDLL_CS)
|
#include <reapi_gamedll.inc> // NOTE: only for gamedll Counter-Strike (ReGameDLL_CS)
|
||||||
|
@ -262,7 +262,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\extra\amxmodx\scripting\include\reapi.inc" />
|
<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.inc" />
|
||||||
<None Include="..\extra\amxmodx\scripting\include\reapi_engine_const.inc" />
|
<None Include="..\extra\amxmodx\scripting\include\reapi_engine_const.inc" />
|
||||||
<None Include="..\extra\amxmodx\scripting\include\reapi_gamedll.inc" />
|
<None Include="..\extra\amxmodx\scripting\include\reapi_gamedll.inc" />
|
||||||
|
@ -743,9 +743,6 @@
|
|||||||
<Filter>src</Filter>
|
<Filter>src</Filter>
|
||||||
</None>
|
</None>
|
||||||
<None Include="reapi.def" />
|
<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">
|
<None Include="..\extra\amxmodx\scripting\include\reapi_gamedll.inc">
|
||||||
<Filter>amxmodx\scripting\include</Filter>
|
<Filter>amxmodx\scripting\include</Filter>
|
||||||
</None>
|
</None>
|
||||||
|
@ -66,7 +66,7 @@ cell AMX_NATIVE_CALL REU_GetProtocol(AMX *amx, cell *params)
|
|||||||
{
|
{
|
||||||
enum args_e { arg_count, arg_index };
|
enum args_e { arg_count, arg_index };
|
||||||
|
|
||||||
CHECK_ISPLAYER(params[arg_index]);
|
CHECK_ISPLAYER(arg_index);
|
||||||
|
|
||||||
return g_ReunionApi->GetClientProtocol(params[arg_index] - 1);
|
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 };
|
enum args_e { arg_count, arg_index };
|
||||||
|
|
||||||
CHECK_ISPLAYER(params[arg_index]);
|
CHECK_ISPLAYER(arg_index);
|
||||||
|
|
||||||
return g_ReunionApi->GetClientAuthtype(params[arg_index] - 1);
|
return g_ReunionApi->GetClientAuthtype(params[arg_index] - 1);
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
#pragma once
|
#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_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 (x > gpGlobals->maxEntities) { MF_LogError(amx, AMX_ERR_NATIVE, "invalid entity index %i", 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
|
class CAmxArg
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CAmxArg(AMX* amx, cell value) : m_amx(amx), m_value(value) {}
|
CAmxArg(AMX* amx, cell value) : m_amx(amx), m_value(value) {}
|
||||||
operator float&() const
|
operator float() const
|
||||||
{
|
{
|
||||||
return *(float *)m_value;
|
return *(float *)m_value;
|
||||||
}
|
}
|
||||||
@ -17,7 +17,7 @@ public:
|
|||||||
}
|
}
|
||||||
operator entvars_s*() const
|
operator entvars_s*() const
|
||||||
{
|
{
|
||||||
auto pev = PEV(m_value);
|
auto pev = PEV(m_value); // faster
|
||||||
return m_value < 0 ? nullptr : pev;
|
return m_value < 0 ? nullptr : pev;
|
||||||
}
|
}
|
||||||
operator int() const
|
operator int() const
|
||||||
@ -34,8 +34,9 @@ public:
|
|||||||
}
|
}
|
||||||
operator CBaseEntity*() const
|
operator CBaseEntity*() const
|
||||||
{
|
{
|
||||||
auto player = g_ReGameFuncs->UTIL_PlayerByIndex(m_value);
|
if (m_value < 0)
|
||||||
return m_value < 0 ? nullptr : player;
|
return nullptr;
|
||||||
|
return g_ReGameFuncs->UTIL_PlayerByIndex(m_value);
|
||||||
}
|
}
|
||||||
operator PLAYER_ANIM() const
|
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 };
|
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]);
|
ICSPlayer *pPlayer = g_ReGameFuncs->INDEX_TO_CSPLAYER(params[arg_index]);
|
||||||
if (pPlayer == nullptr || !pPlayer->IsConnected()) {
|
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 };
|
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]);
|
ICSPlayer *pPlayer = g_ReGameFuncs->INDEX_TO_CSPLAYER(params[arg_index]);
|
||||||
if (pPlayer == nullptr || !pPlayer->IsConnected()) {
|
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 };
|
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]);
|
ICSPlayer *pPlayer = g_ReGameFuncs->INDEX_TO_CSPLAYER(params[arg_index]);
|
||||||
if (pPlayer == nullptr || !pPlayer->IsConnected()) {
|
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 };
|
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]);
|
ICSPlayer *pPlayer = g_ReGameFuncs->INDEX_TO_CSPLAYER(params[arg_index]);
|
||||||
if (pPlayer == nullptr || !pPlayer->IsConnected()) {
|
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 };
|
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]);
|
ICSPlayer *pPlayer = g_ReGameFuncs->INDEX_TO_CSPLAYER(params[arg_index]);
|
||||||
if (pPlayer == nullptr || !pPlayer->IsConnected()) {
|
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 };
|
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(arg_inflictor);
|
||||||
CHECK_ISENTITY(params[arg_attacker]);
|
CHECK_ISENTITY(arg_attacker);
|
||||||
|
|
||||||
CAmxArgs args(amx, params);
|
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]);
|
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 };
|
enum args_e { arg_count, arg_inflictor, arg_attacker };
|
||||||
|
|
||||||
CHECK_ISENTITY(params[arg_inflictor]);
|
CHECK_ISENTITY(arg_inflictor);
|
||||||
CHECK_ISENTITY(params[arg_attacker]);
|
CHECK_ISENTITY(arg_attacker);
|
||||||
|
|
||||||
CAmxArgs args(amx, params);
|
CAmxArgs args(amx, params);
|
||||||
g_ReGameFuncs->ApplyMultiDamage(args[arg_inflictor], args[arg_attacker]);
|
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 };
|
enum args_e { arg_count, arg_inflictor, arg_victim, arg_damage, arg_dmg_type };
|
||||||
|
|
||||||
CHECK_ISENTITY(params[arg_inflictor]);
|
CHECK_ISENTITY(arg_inflictor);
|
||||||
CHECK_ISENTITY(params[arg_victim]);
|
CHECK_ISENTITY(arg_victim);
|
||||||
|
|
||||||
if (params[arg_victim] < 0) { // null
|
if (params[arg_victim] < 0) { // null
|
||||||
MF_LogError(amx, AMX_ERR_NATIVE, "rg_multidmg_add: victim == 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 };
|
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(arg_inflictor);
|
||||||
CHECK_ISENTITY(params[arg_attacker]);
|
CHECK_ISENTITY(arg_attacker);
|
||||||
|
|
||||||
CAmxArgs args(amx, params);
|
CAmxArgs args(amx, params);
|
||||||
ICSEntity *pInflictor = args[arg_inflictor];
|
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 };
|
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(arg_inflictor);
|
||||||
CHECK_ISENTITY(params[arg_attacker]);
|
CHECK_ISENTITY(arg_attacker);
|
||||||
|
|
||||||
CAmxArgs args(amx, params);
|
CAmxArgs args(amx, params);
|
||||||
ICSEntity *pInflictor = args[arg_inflictor];
|
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 };
|
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]);
|
const char* value = getAmxString(amx, params[arg_classname]);
|
||||||
edict_t *pOwner = edictByIndex(params[arg_onwer]);
|
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 };
|
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]);
|
ICSPlayer *pPlayer = g_ReGameFuncs->INDEX_TO_CSPLAYER(params[arg_index]);
|
||||||
if (pPlayer == nullptr || !pPlayer->IsConnected()) {
|
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 };
|
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]);
|
CBasePlayer *pPlayer = (CBasePlayer *)g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||||
|
Loading…
Reference in New Issue
Block a user