diff --git a/publish.gradle b/publish.gradle index ee206ff..504e7dd 100644 --- a/publish.gradle +++ b/publish.gradle @@ -31,6 +31,10 @@ task publishPrepareFiles << { from 'reapi/extra' into 'publish/publishRoot/reapi/addons' } + copy { + from 'reapi/src/reapi_version.inc' + into 'publish/publishRoot/reapi/addons/amxmodx/scripting/include' + } } task publishPackage(type: Zip, dependsOn: 'publishPrepareFiles') { diff --git a/reapi/extra/amxmodx/scripting/include/reapi.inc b/reapi/extra/amxmodx/scripting/include/reapi.inc index 7389491..7021721 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi.inc @@ -13,16 +13,12 @@ #pragma library reapi #endif -// reapi version -#define REAPI_VERSION_MAJOR 1 -#define REAPI_VERSION_MINOR 0 - #define NULLENT -1 -#include #include // NOTE: only for ReHLDS #include // NOTE: only for gamedll Counter-Strike (ReGameDLL_CS) #include // NOTE: 3-rd party addons +#include // hookchain return type enum diff --git a/reapi/extra/amxmodx/scripting/include/reapi_addons.inc b/reapi/extra/amxmodx/scripting/include/reapi_addons.inc index e18d990..9c18f4b 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_addons.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_addons.inc @@ -26,7 +26,7 @@ enum client_auth_type * @return 1 if client is speaking, 0 otherwise * */ -native VTC_IsClientSpeaking(index); +native VTC_IsClientSpeaking(const index); /* * Mutes this player @@ -34,7 +34,7 @@ native VTC_IsClientSpeaking(index); * @param index Client index * @noreturn */ -native VTC_MuteClient(index); +native VTC_MuteClient(const index); /* * Unmutes this player @@ -42,7 +42,7 @@ native VTC_MuteClient(index); * @param index Client index * @noreturn */ -native VTC_UnmuteClient(index); +native VTC_UnmuteClient(const index); /* * Called when player started talking @@ -50,7 +50,7 @@ native VTC_UnmuteClient(index); * @param index Client index * @noreturn */ -forward VTC_OnClientStartSpeak(index); +forward VTC_OnClientStartSpeak(const index); /* * Called when player stopped talking @@ -58,13 +58,13 @@ forward VTC_OnClientStartSpeak(index); * @param index Client index * @noreturn */ -forward VTC_OnClientStopSpeak(index); +forward VTC_OnClientStopSpeak(const index); /* * Get client protocol * * @param index Client index -* @noreturn +* @return client protocol */ native REU_GetProtocol(const index); @@ -72,6 +72,6 @@ native REU_GetProtocol(const index); * Get client auth type * * @param index Client index -* @noreturn +* @return client auth type */ -native REU_GetAuthtype(const index); +native client_auth_type:REU_GetAuthtype(const index); diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc index 425e399..ce1e3dc 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc @@ -173,7 +173,6 @@ enum GamedllFunc_CBasePlayer */ RG_CBasePlayer_ObjectCaps, - /** * Description: - * Return type: int @@ -571,7 +570,7 @@ enum CSGameRules_Members m_bMapHasEscapeZone, /** - * Description: 0 = uninitialized, 1 = has VIP safety zone, 2 = DOES not have VIP safetyzone + * Description: 0 = uninitialized, 1 = has VIP safety zone, 2 = DOES not have VIP safetyzone * Member type: int * Get params: get_member_game(member); * Set params: set_member_game(member, value); diff --git a/reapi/extra/amxmodx/scripting/reapi_test.sma b/reapi/extra/amxmodx/scripting/reapi_test.sma index 650e0d7..05db926 100644 --- a/reapi/extra/amxmodx/scripting/reapi_test.sma +++ b/reapi/extra/amxmodx/scripting/reapi_test.sma @@ -4,7 +4,7 @@ public plugin_init() { register_plugin("ReAPI Test", "1.0", "s1lent"); - RegisterHookChain(RH_CBasePlayer_GiveAmmo, "CBasePlayer_GiveAmmo"); + RegisterHookChain(RG_CBasePlayer_GiveAmmo, "CBasePlayer_GiveAmmo"); } public CBasePlayer_GiveAmmo(const this, iAmount, szName[], iMax) diff --git a/reapi/msvc/reapi.vcxproj b/reapi/msvc/reapi.vcxproj index 713f35f..2ee6175 100644 --- a/reapi/msvc/reapi.vcxproj +++ b/reapi/msvc/reapi.vcxproj @@ -268,7 +268,7 @@ - + diff --git a/reapi/msvc/reapi.vcxproj.filters b/reapi/msvc/reapi.vcxproj.filters index 3c4e06b..7ca71ec 100644 --- a/reapi/msvc/reapi.vcxproj.filters +++ b/reapi/msvc/reapi.vcxproj.filters @@ -739,9 +739,6 @@ amxmodx\scripting - - src - amxmodx\scripting\include @@ -758,6 +755,9 @@ amxmodx\scripting\include + + src + diff --git a/reapi/src/amxxmodule.cpp b/reapi/src/amxxmodule.cpp index 282d154..a06c7aa 100644 --- a/reapi/src/amxxmodule.cpp +++ b/reapi/src/amxxmodule.cpp @@ -177,7 +177,7 @@ C_DLLEXPORT int AMXX_Detach() C_DLLEXPORT int AMXX_PluginsLoaded() { int iFwd = g_amxxapi.RegisterForward("__reapi_version_check", ET_IGNORE, FP_CELL, FP_CELL, FP_DONE); - g_amxxapi.ExecuteForward(iFwd, REAPI_VERISON_MAJOR, REAPI_VERISON_MINOR); + g_amxxapi.ExecuteForward(iFwd, REAPI_VERSION_MAJOR, REAPI_VERSION_MINOR); if (api_cfg.hasVTC()) { diff --git a/reapi/src/api_config.h b/reapi/src/api_config.h index 488cd73..531bc9c 100644 --- a/reapi/src/api_config.h +++ b/reapi/src/api_config.h @@ -1,7 +1,7 @@ #pragma once // reapi version -#include "reapi_const.inc" +#include "reapi_version.inc" class CAPI_Config { public: diff --git a/reapi/src/natives/natives_addons.cpp b/reapi/src/natives/natives_addons.cpp index e12d6a8..d28986a 100644 --- a/reapi/src/natives/natives_addons.cpp +++ b/reapi/src/natives/natives_addons.cpp @@ -6,7 +6,7 @@ * @param index Client index * @return 1 if client is speaking, 0 otherwise * -* native VTC_IsClientSpeaking(index); +* native VTC_IsClientSpeaking(const index); */ cell AMX_NATIVE_CALL VTC_IsClientSpeaking(AMX *amx, cell *params) { @@ -23,7 +23,7 @@ cell AMX_NATIVE_CALL VTC_IsClientSpeaking(AMX *amx, cell *params) * @param index Client index * @noreturn * -* native VTC_MuteClient(index); +* native VTC_MuteClient(const index); */ cell AMX_NATIVE_CALL VTC_MuteClient(AMX *amx, cell *params) { @@ -42,7 +42,7 @@ cell AMX_NATIVE_CALL VTC_MuteClient(AMX *amx, cell *params) * @param index Client index * @noreturn * -* native VTC_UnmuteClient(index); +* native VTC_UnmuteClient(const index); */ cell AMX_NATIVE_CALL VTC_UnmuteClient(AMX *amx, cell *params) { @@ -68,6 +68,7 @@ AMX_NATIVE_INFO Vtc_Natives[] = * Get client protocol * * @param index Client index +* @return client protocol * * native REU_GetProtocol(const index); */ @@ -84,6 +85,7 @@ cell AMX_NATIVE_CALL REU_GetProtocol(AMX *amx, cell *params) * Get client auth type * * @param index Client index +* @return client auth type * * native REU_GetAuthtype(const index); */ diff --git a/reapi/src/natives/natives_helper.h b/reapi/src/natives/natives_helper.h index ee406de..7666cc7 100644 --- a/reapi/src/natives/natives_helper.h +++ b/reapi/src/natives/natives_helper.h @@ -36,7 +36,13 @@ public: { if (m_value < 0) return nullptr; - return g_ReGameFuncs->UTIL_PlayerByIndex(m_value); + return getPrivate(m_value); + } + operator CBasePlayer*() const + { + if (m_value < 0) + return nullptr; + return static_cast(g_ReGameFuncs->UTIL_PlayerByIndex(m_value)); } operator PLAYER_ANIM() const { diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index ffa56c2..b9216a5 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -221,7 +221,7 @@ cell AMX_NATIVE_CALL rg_multidmg_add(AMX *amx, cell *params) CAmxArgs args(amx, params); g_ReGameFuncs->AddMultiDamage(args[arg_inflictor], args[arg_victim], args[arg_damage], args[arg_dmg_type]); - + return TRUE; } @@ -481,7 +481,7 @@ cell AMX_NATIVE_CALL rg_find_ent_by_owner(AMX *amx, cell *params) const char* value = getAmxString(amx, params[arg_classname]); edict_t *pOwner = edictByIndex(params[arg_onwer]); edict_t *pEntity = g_pEdicts; - + for (int i = 0; i < gpGlobals->maxEntities; i++, pEntity++) { if (pEntity->v.owner == pOwner && !strcmp(STRING(pEntity->v.classname), value)) diff --git a/reapi/src/reapi_const.inc b/reapi/src/reapi_const.inc deleted file mode 100644 index 16c7a3b..0000000 --- a/reapi/src/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/src/reapi_utils.h b/reapi/src/reapi_utils.h index 5dd0c41..d70b548 100644 --- a/reapi/src/reapi_utils.h +++ b/reapi/src/reapi_utils.h @@ -27,7 +27,11 @@ inline edict_t* edictByIndex(size_t index) template T* getPrivate(int index) { - return (T *)edictByIndex(index)->pvPrivateData; + edict_t* pent = edictByIndex(index); + if (pent) + return (T *)pent->pvPrivateData; + + return nullptr; } inline entvars_t* PEV(int index) diff --git a/reapi/src/reapi_version.inc b/reapi/src/reapi_version.inc new file mode 100644 index 0000000..1183145 --- /dev/null +++ b/reapi/src/reapi_version.inc @@ -0,0 +1,8 @@ +#if defined _reapi_version_included + #endinput +#endif +#define _reapi_version_included + +// reapi version +#define REAPI_VERSION_MAJOR 1 +#define REAPI_VERSION_MINOR 0