diff --git a/reapi/extra/amxmodx/scripting/include/reapi.inc b/reapi/extra/amxmodx/scripting/include/reapi.inc index 2770ef3..8adefb3 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi.inc @@ -13,10 +13,14 @@ #pragma library reapi #endif +// reapi version +#define REAPI_VERISON_MAJOR 1 +#define REAPI_VERISON_MINOR 0 + #include #include // NOTE: only for ReHLDS #include // NOTE: only for gamedll Counter-Strike (ReGameDLL_CS) -#include // NOTE: Common set of natives and forwards. +#include // NOTE: 3-rd party addons // hookchain return type enum diff --git a/reapi/extra/amxmodx/scripting/include/reapi_misc.inc b/reapi/extra/amxmodx/scripting/include/reapi_addons.inc similarity index 60% rename from reapi/extra/amxmodx/scripting/include/reapi_misc.inc rename to reapi/extra/amxmodx/scripting/include/reapi_addons.inc index 7b6a559..e18d990 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_misc.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_addons.inc @@ -1,31 +1,7 @@ -#if defined _reapi_misc_included +#if defined _reapi_addons_included #endinput #endif -#define _reapi_misc_included - -enum client_auth -{ - /** - * Description: - - * Return type: int - * Params: get_client_data(const index, CA_PROTOCOL) - */ - CA_PROTOCOL, - - /** - * Description: - - * Return type: client_auth_type - * Params: get_client_data(const index, CA_TYPE) - */ - CA_TYPE, - - /** - * Description: - - * Return type: - - * Params: get_client_data(const index, CA_STRING, output[], maxlength) - */ - CA_STRING, -}; +#define _reapi_addons_included enum client_auth_type { @@ -85,9 +61,17 @@ forward VTC_OnClientStartSpeak(index); forward VTC_OnClientStopSpeak(index); /* -* Get out information of the client +* Get client protocol * * @param index Client index -* @type to look enum client_auth +* @noreturn */ -native get_client_data(const index, client_auth:type, any:...); +native REU_GetProtocol(const index); + +/* +* Get client auth type +* +* @param index Client index +* @noreturn +*/ +native REU_GetAuthtype(const index); diff --git a/reapi/extra/amxmodx/scripting/include/reapi_const.inc b/reapi/extra/amxmodx/scripting/include/reapi_const.inc deleted file mode 100644 index 16c7a3b..0000000 --- a/reapi/extra/amxmodx/scripting/include/reapi_const.inc +++ /dev/null @@ -1,8 +0,0 @@ -#if defined _reapi_const_included - #endinput -#endif -#define _reapi_const_included - -// reapi version -#define REAPI_VERISON_MAJOR 1 -#define REAPI_VERISON_MINOR 0 diff --git a/reapi/extra/amxmodx/scripting/include/reapi_engine.inc b/reapi/extra/amxmodx/scripting/include/reapi_engine.inc index 79c0e27..cf8391e 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_engine.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_engine.inc @@ -4,32 +4,4 @@ #define _reapi_engine_included -enum EngineFunc -{ - /** - * Description: - - * Params: (const recipients, const entity, const channel, const sample[], const volume, Float:attenuation, const fFlags, const pitch) - */ - RH_SV_StartSound = 0, - - /** - * Description: - - * Params: (const client, bool:crash, const fmt[]) - */ - RH_SV_DropClient, - - /** - * Description: - - * Params: (const runPhysics) - */ - RH_SV_ActivateServer, - - /** - * Description: - - * Params: (pcvar, const value[]) - */ - RH_Cvar_DirectSet, - - // [...] - RH_EngineFunc_End -}; +#include diff --git a/reapi/extra/amxmodx/scripting/include/reapi_engine_const.inc b/reapi/extra/amxmodx/scripting/include/reapi_engine_const.inc new file mode 100644 index 0000000..0a5b425 --- /dev/null +++ b/reapi/extra/amxmodx/scripting/include/reapi_engine_const.inc @@ -0,0 +1,35 @@ +#if defined _reapi_engine_const_included + #endinput +#endif + +#define _reapi_engine_const_included + +enum EngineFunc +{ + /** + * Description: - + * Params: (const recipients, const entity, const channel, const sample[], const volume, Float:attenuation, const fFlags, const pitch) + */ + RH_SV_StartSound = 0, + + /** + * Description: - + * Params: (const client, bool:crash, const fmt[]) + */ + RH_SV_DropClient, + + /** + * Description: - + * Params: (const runPhysics) + */ + RH_SV_ActivateServer, + + /** + * Description: - + * Params: (pcvar, const value[]) + */ + RH_Cvar_DirectSet, + + // [...] + RH_EngineFunc_End +}; diff --git a/reapi/msvc/reapi.vcxproj b/reapi/msvc/reapi.vcxproj index 21d4318..641825d 100644 --- a/reapi/msvc/reapi.vcxproj +++ b/reapi/msvc/reapi.vcxproj @@ -210,7 +210,7 @@ - + @@ -249,7 +249,7 @@ - + Create Create @@ -264,9 +264,10 @@ + - + diff --git a/reapi/msvc/reapi.vcxproj.filters b/reapi/msvc/reapi.vcxproj.filters index 8b17e67..4cc46c6 100644 --- a/reapi/msvc/reapi.vcxproj.filters +++ b/reapi/msvc/reapi.vcxproj.filters @@ -636,9 +636,6 @@ src\natives - - src\natives - include @@ -651,6 +648,9 @@ src\mods + + src\natives + @@ -725,12 +725,12 @@ src\natives - - src\natives - src\mods + + src\natives + @@ -746,16 +746,19 @@ amxmodx\scripting\include - - amxmodx\scripting\include - amxmodx\scripting\include amxmodx\scripting\include - + + amxmodx\scripting\include + + + amxmodx\scripting\include + + amxmodx\scripting\include diff --git a/reapi/src/amxxmodule.cpp b/reapi/src/amxxmodule.cpp index ba2b93b..282d154 100644 --- a/reapi/src/amxxmodule.cpp +++ b/reapi/src/amxxmodule.cpp @@ -164,7 +164,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc) RegisterNatives_HookChains(); RegisterNatives_Members(); RegisterNatives_Misc(); - RegisterNatives_Vtc(); + RegisterNatives_Addons(); return AMXX_OK; } diff --git a/reapi/src/natives/natives_vtc.cpp b/reapi/src/natives/natives_addons.cpp similarity index 58% rename from reapi/src/natives/natives_vtc.cpp rename to reapi/src/natives/natives_addons.cpp index 4b018bf..0b513f5 100644 --- a/reapi/src/natives/natives_vtc.cpp +++ b/reapi/src/natives/natives_addons.cpp @@ -55,8 +55,50 @@ AMX_NATIVE_INFO Vtc_Natives[] = { nullptr, nullptr } }; -void RegisterNatives_Vtc() +/* +* Get client protocol +* +* @param index Client index +* +* native REU_GetProtocol(const index); +*/ +cell AMX_NATIVE_CALL REU_GetProtocol(AMX *amx, cell *params) +{ + enum args_e { arg_count, arg_index }; + + CHECK_ISPLAYER(params[arg_index]); + + return g_ReunionApi->GetClientProtocol(params[arg_index] - 1); +} + +/* +* Get client auth type +* +* @param index Client index +* +* native REU_GetAuthtype(const index); +*/ +cell AMX_NATIVE_CALL REU_GetAuthtype(AMX *amx, cell *params) +{ + enum args_e { arg_count, arg_index }; + + CHECK_ISPLAYER(params[arg_index]); + + return g_ReunionApi->GetClientAuthtype(params[arg_index] - 1); +} + +AMX_NATIVE_INFO Reunion_Natives[] = +{ + { "REU_GetProtocol", REU_GetProtocol }, + { "REU_GetAuthtype", REU_GetAuthtype }, + + { nullptr, nullptr } +}; + +void RegisterNatives_Addons() { if (api_cfg.hasVTC()) g_amxxapi.AddNatives(Vtc_Natives); + if (api_cfg.hasReunion()) + g_amxxapi.AddNatives(Reunion_Natives); } diff --git a/reapi/src/natives/natives_addons.h b/reapi/src/natives/natives_addons.h new file mode 100644 index 0000000..a4093f7 --- /dev/null +++ b/reapi/src/natives/natives_addons.h @@ -0,0 +1,3 @@ +#pragma once + +void RegisterNatives_Addons(); diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index 1b14acf..418735e 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -310,7 +310,7 @@ cell AMX_NATIVE_CALL rg_fire_bullets3(AMX *amx, cell *params) args[arg_bullet_type], args[arg_dmg], args[arg_range_mod], - pAttacker, + pAttacker, // icc fix args[arg_pistol], args[arg_rand] ); @@ -428,7 +428,7 @@ cell AMX_NATIVE_CALL rg_create_entity(AMX *amx, cell *params) string_t iClass = g_engfuncs.pfnAllocString(getAmxString(amx, params[arg_classname])); edict_t *pEnt = g_ReGameFuncs->CREATE_NAMED_ENTITY2(iClass); - if (!FNullEnt(pEnt)) + if (pEnt != nullptr) { return ENTINDEX(pEnt); } @@ -452,10 +452,9 @@ cell AMX_NATIVE_CALL rg_find_ent_by_class(AMX *amx, cell *params) CBaseEntity *pStartEntity = getPrivate(params[arg_start_index]); const char* value = getAmxString(amx, params[arg_classname]); - CBaseEntity *pEntity = g_ReGameFuncs->UTIL_FindEntityByString(pStartEntity, "classname", value); - if (pEntity != nullptr && !FNullEnt(pEntity->edict())) + if (pEntity != nullptr) { return indexOfEdict(pEntity->pev); } @@ -479,16 +478,14 @@ cell AMX_NATIVE_CALL rg_find_ent_by_owner(AMX *amx, cell *params) CHECK_ISENTITY(params[arg_onwer]); - CBaseEntity *pEntity = getPrivate(params[arg_start_index]); const char* value = getAmxString(amx, params[arg_classname]); - edict_t *pOwner = edictByIndex(params[arg_onwer]); - while ((pEntity = g_ReGameFuncs->UTIL_FindEntityByString(pEntity, "classname", value)) != nullptr) + edict_t *pEntity = g_pEdicts; + + for (int i = 0; i < gpGlobals->maxEntities; i++, pEntity++) { - if (pEntity != nullptr && !FNullEnt(pEntity->edict()) && pEntity->pev->owner == pOwner) - { - return indexOfEdict(pEntity->pev); - } + if (pEntity->v.owner == pOwner && !strcmp(STRING(pEntity->v.classname), value)) + return i; } return 0; @@ -602,9 +599,8 @@ cell AMX_NATIVE_CALL rg_remove_item(AMX *amx, cell *params) } const char* szItemName = getAmxString(amx, params[arg_item_name]); - for (auto& item : pPlayer->m_rgpPlayerItems) + for (auto pItem : pPlayer->m_rgpPlayerItems) { - CBasePlayerItem *pItem = item; while (pItem != nullptr) { if (FClassnameIs(pItem->pev, szItemName)) @@ -655,94 +651,8 @@ AMX_NATIVE_INFO Misc_Natives_RG[] = { nullptr, nullptr } }; -enum client_auth -{ - /** - * Description: - - * Return type: int - * Params: get_client_data(const index, CA_PROTOCOL) - */ - CA_PROTOCOL, - - /** - * Description: - - * Return type: client_auth_type - * Params: get_client_data(const index, CA_TYPE) - */ - CA_TYPE, - - /** - * Description: - - * Return type: - - * Params: get_client_data(const index, CA_STRING, output[], maxlength) - */ - CA_STRING, -}; - -/* -* Get out information of the client -* -* @param index Client index -* @type to look enum client_auth -* -* native get_client_data(const index, client_auth:type, any:...); -*/ -cell AMX_NATIVE_CALL get_client_data(AMX *amx, cell *params) -{ - enum args_e { arg_count, arg_index, arg_type, arg_3, arg_4 }; - - CHECK_ISPLAYER(params[arg_index]); - - client_auth type = static_cast(params[arg_type]); - switch (type) - { - case CA_PROTOCOL: - { - // native get_client_data(id, CA_PROTOCOL); - return g_ReunionApi->GetClientProtocol(params[arg_index] - 1); - } - case CA_TYPE: - { - // native client_auth_type:get_client_data(id, CA_TYPE); - return g_ReunionApi->GetClientAuthtype(params[arg_index] - 1); - } - case CA_STRING: - { - if (PARAMS_COUNT != arg_4) { - MF_LogError(amx, AMX_ERR_NATIVE, "get_client_data: bad parameter count, got %i, expected %i", PARAMS_COUNT, arg_4); - return -1; - } - - // native get_client_data(id, CA_STRING, output[], maxlength); - cell* dest = getAmxAddr(amx, params[arg_3]); - size_t length = *getAmxAddr(amx, params[arg_4]); - - char data[128]; - g_ReunionApi->GetClientAuthdataString(params[arg_index] - 1, data, sizeof data); - setAmxString(dest, data, length); - - return 1; - } - default: - { - MF_LogError(amx, AMX_ERR_NATIVE, "get_client_data: unknown type statement %i, params count %i", type, PARAMS_COUNT); - return -1; - } - } -} - -AMX_NATIVE_INFO Misc_Natives_Reunion[] = -{ - { "get_client_data", get_client_data }, - - { nullptr, nullptr } -}; - void RegisterNatives_Misc() { if (api_cfg.hasReGameDLL()) g_amxxapi.AddNatives(Misc_Natives_RG); - - if (api_cfg.hasReunion()) - g_amxxapi.AddNatives(Misc_Natives_Reunion); } diff --git a/reapi/src/natives/natives_vtc.h b/reapi/src/natives/natives_vtc.h deleted file mode 100644 index d77db48..0000000 --- a/reapi/src/natives/natives_vtc.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -void RegisterNatives_Vtc(); diff --git a/reapi/src/precompiled.h b/reapi/src/precompiled.h index 99b87d8..879c965 100644 --- a/reapi/src/precompiled.h +++ b/reapi/src/precompiled.h @@ -48,7 +48,7 @@ #include "natives_hookchains.h" #include "natives_members.h" #include "natives_misc.h" -#include "natives_vtc.h" +#include "natives_addons.h" #include "natives_helper.h" #undef DLLEXPORT