From e77bb0ffcefec59604eb713861c1fd20b99eb0b1 Mon Sep 17 00:00:00 2001 From: szGabu Date: Mon, 20 Apr 2026 15:22:38 -0400 Subject: [PATCH 1/2] feat: implements SV_TestEntityPosition hook to ReAPI --- .../amxmodx/scripting/include/reapi_engine_const.inc | 7 +++++++ reapi/include/cssdk/engine/rehlds_api.h | 5 +++++ reapi/src/hook_callback.cpp | 10 ++++++++++ reapi/src/hook_callback.h | 1 + reapi/src/hook_list.cpp | 1 + reapi/src/hook_list.h | 1 + 6 files changed, 25 insertions(+) diff --git a/reapi/extra/amxmodx/scripting/include/reapi_engine_const.inc b/reapi/extra/amxmodx/scripting/include/reapi_engine_const.inc index eee1f366..a5d7d12a 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_engine_const.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_engine_const.inc @@ -191,6 +191,13 @@ enum EngineFunc */ RH_SV_SendResources, + /* + * Description: Called when a BSP entity checks collision with another entity. + * Return type: bool + * Params: (const entity, const client) + */ + RH_SV_TestEntityPosition, + }; /** diff --git a/reapi/include/cssdk/engine/rehlds_api.h b/reapi/include/cssdk/engine/rehlds_api.h index ac415374..ea3a1309 100644 --- a/reapi/include/cssdk/engine/rehlds_api.h +++ b/reapi/include/cssdk/engine/rehlds_api.h @@ -264,6 +264,10 @@ typedef IHookChainRegistry IRehldsHookRegistry_SV_Allo typedef IVoidHookChain IRehldsHook_SV_SendResources; typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_SendResources; +// SV_TestEntityPosition hook +typedef IHookChain IRehldsHook_SV_TestEntityPosition; +typedef IHookChainRegistry IRehldsHookRegistry_SV_TestEntityPosition; + class IRehldsHookchains { public: virtual ~IRehldsHookchains() { } @@ -324,6 +328,7 @@ class IRehldsHookchains { virtual IRehldsHookRegistry_SV_ClientPrintf* SV_ClientPrintf() = 0; virtual IRehldsHookRegistry_SV_AllowPhysent* SV_AllowPhysent() = 0; virtual IRehldsHookRegistry_SV_SendResources* SV_SendResources() = 0; + virtual IRehldsHookRegistry_SV_TestEntityPosition* SV_TestEntityPosition() = 0; }; struct RehldsFuncs_t { diff --git a/reapi/src/hook_callback.cpp b/reapi/src/hook_callback.cpp index 7d03f922..d0a0c450 100644 --- a/reapi/src/hook_callback.cpp +++ b/reapi/src/hook_callback.cpp @@ -258,6 +258,16 @@ void SV_SendResources(IRehldsHook_SV_SendResources *chain, sizebuf_t *msg) SV_SendResources_AMXX(&data, g_RehldsFuncs->GetHostClient()); } +edict_t *SV_TestEntityPosition(IRehldsHook_SV_TestEntityPosition* chain, edict_t* ent) +{ + auto original = [chain](int _ent) + { + return indexOfEdict(chain->callNext(edictByIndexAmx(_ent))); + }; + + return edictByIndexAmx(callForward(RH_SV_TestEntityPosition, original, indexOfEdict(ent))); +} + /* * ReGameDLL functions */ diff --git a/reapi/src/hook_callback.h b/reapi/src/hook_callback.h index 1065997a..b45a96f6 100644 --- a/reapi/src/hook_callback.h +++ b/reapi/src/hook_callback.h @@ -397,6 +397,7 @@ edict_t *ED_Alloc(IRehldsHook_ED_Alloc* chain); void ED_Free(IRehldsHook_ED_Free* chain, edict_t *entity); void SV_ClientPrintf(IRehldsHook_SV_ClientPrintf* chain, const char *string); bool SV_AllowPhysent(IRehldsHook_SV_AllowPhysent* chain, edict_t* check, edict_t* sv_player); +edict_t *SV_TestEntityPosition(IRehldsHook_SV_TestEntityPosition* chain, edict_t* ent); /* * ReGameDLL functions diff --git a/reapi/src/hook_list.cpp b/reapi/src/hook_list.cpp index cb8bd17e..25075514 100644 --- a/reapi/src/hook_list.cpp +++ b/reapi/src/hook_list.cpp @@ -109,6 +109,7 @@ hook_t hooklist_engine[] = { ENG(SV_AllowPhysent), ENG(ExecuteServerStringCmd), ENG(SV_SendResources, _AMXX), + ENG(SV_TestEntityPosition), }; #define DLL(h,...) { {}, {}, #h, "ReGameDLL", [](){ return api_cfg.hasReGameDLL(); }, ((!(RG_##h & (MAX_REGION_RANGE - 1)) ? regfunc::current_cell = 1, true : false) || (RG_##h & (MAX_REGION_RANGE - 1)) == regfunc::current_cell++) ? regfunc(h##__VA_ARGS__) : regfunc(#h#__VA_ARGS__), [](){ g_ReGameHookchains->h()->registerHook(&h); }, [](){ g_ReGameHookchains->h()->unregisterHook(&h); }, false} diff --git a/reapi/src/hook_list.h b/reapi/src/hook_list.h index 1cdb7bb4..9ac17e65 100644 --- a/reapi/src/hook_list.h +++ b/reapi/src/hook_list.h @@ -118,6 +118,7 @@ enum EngineFunc RH_SV_AllowPhysent, RH_ExecuteServerStringCmd, RH_SV_SendResources, + RH_SV_TestEntityPosition, // [...] }; From a91034251cee0bfdce5001bd427c8f8c160e4c44 Mon Sep 17 00:00:00 2001 From: szGabu Date: Mon, 20 Apr 2026 19:12:35 -0400 Subject: [PATCH 2/2] change: better description for API function in AMXX --- .../extra/amxmodx/scripting/include/reapi_engine_const.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reapi/extra/amxmodx/scripting/include/reapi_engine_const.inc b/reapi/extra/amxmodx/scripting/include/reapi_engine_const.inc index a5d7d12a..80a3ea13 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_engine_const.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_engine_const.inc @@ -192,9 +192,9 @@ enum EngineFunc RH_SV_SendResources, /* - * Description: Called when a BSP entity checks collision with another entity. - * Return type: bool - * Params: (const entity, const client) + * Description: Called when an entity checks collision with another entity. + * Return type: int + * Params: (const entity) */ RH_SV_TestEntityPosition,