From 1dcc1ca3fb1680e593bf797ab310a2b335447a27 Mon Sep 17 00:00:00 2001 From: Javekson <132286351+Javekson@users.noreply.github.com> Date: Wed, 8 May 2024 12:48:03 +0400 Subject: [PATCH] Implement RG_CBasePlayer_RemoveAllItems hook (#310) * Implement RG_CBasePlayer_RemoveAllItems hook --- .../amxmodx/scripting/include/reapi_gamedll_const.inc | 6 ++++++ reapi/include/cssdk/dlls/regamedll_api.h | 10 +++++++--- reapi/src/hook_callback.cpp | 10 ++++++++++ reapi/src/hook_callback.h | 1 + reapi/src/hook_list.cpp | 1 + reapi/src/hook_list.h | 1 + reapi/version/version.h | 2 +- 7 files changed, 27 insertions(+), 4 deletions(-) diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc index 2970c5d5..b623062e 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc @@ -934,6 +934,12 @@ enum GamedllFunc_CBasePlayer * Params: (const this) */ RG_CBasePlayer_Observer_Think, + + /* + * Description: - + * Params: (const this, bool:removeSuit) + */ + RG_CBasePlayer_RemoveAllItems, }; /** diff --git a/reapi/include/cssdk/dlls/regamedll_api.h b/reapi/include/cssdk/dlls/regamedll_api.h index dbf50875..c0aa993a 100644 --- a/reapi/include/cssdk/dlls/regamedll_api.h +++ b/reapi/include/cssdk/dlls/regamedll_api.h @@ -40,7 +40,7 @@ #include #define REGAMEDLL_API_VERSION_MAJOR 5 -#define REGAMEDLL_API_VERSION_MINOR 22 +#define REGAMEDLL_API_VERSION_MINOR 27 // CBasePlayer::Spawn hook typedef IHookChainClass IReGameHook_CBasePlayer_Spawn; @@ -626,6 +626,10 @@ typedef IHookChainRegistryClass IReGameHookRegistry_CBa typedef IHookChainClass IReGameHook_CBasePlayer_Observer_Think; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Observer_Think; +// CBasePlayer::RemoveAllItems hook +typedef IHookChainClass IReGameHook_CBasePlayer_RemoveAllItems; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_RemoveAllItems; + class IReGameHookchains { public: virtual ~IReGameHookchains() {} @@ -773,7 +777,7 @@ class IReGameHookchains { virtual IReGameHookRegistry_AddMultiDamage *AddMultiDamage() = 0; virtual IReGameHookRegistry_ApplyMultiDamage *ApplyMultiDamage() = 0; virtual IReGameHookRegistry_BuyItem *BuyItem() = 0; - virtual IReGameHookRegistry_CSGameRules_Think *CSGameRules_Think() = 0; + virtual IReGameHookRegistry_CSGameRules_Think *CSGameRules_Think() = 0; virtual IReGameHookRegistry_CSGameRules_TeamFull *CSGameRules_TeamFull() = 0; virtual IReGameHookRegistry_CSGameRules_TeamStacked *CSGameRules_TeamStacked() = 0; virtual IReGameHookRegistry_CSGameRules_PlayerGotWeapon *CSGameRules_PlayerGotWeapon() = 0; @@ -787,7 +791,7 @@ class IReGameHookchains { virtual IReGameHookRegistry_CBasePlayer_PlayerDeathThink *CBasePlayer_PlayerDeathThink() = 0; virtual IReGameHookRegistry_CBasePlayer_Observer_Think *CBasePlayer_Observer_Think() = 0; - + virtual IReGameHookRegistry_CBasePlayer_RemoveAllItems *CBasePlayer_RemoveAllItems() = 0; }; struct ReGameFuncs_t { diff --git a/reapi/src/hook_callback.cpp b/reapi/src/hook_callback.cpp index 669ea8ed..217990e2 100644 --- a/reapi/src/hook_callback.cpp +++ b/reapi/src/hook_callback.cpp @@ -1730,6 +1730,16 @@ void CBasePlayer_Observer_Think(IReGameHook_CBasePlayer_Observer_Think *chain, C callVoidForward(RG_CBasePlayer_Observer_Think, original, indexOfEdict(pthis->pev)); } +void CBasePlayer_RemoveAllItems(IReGameHook_CBasePlayer_RemoveAllItems *chain, CBasePlayer *pthis, BOOL removeSuit) +{ + auto original = [chain](int _pthis, BOOL _removeSuit) + { + chain->callNext(getPrivate(_pthis), _removeSuit); + }; + + callVoidForward(RG_CBasePlayer_RemoveAllItems, original, indexOfEdict(pthis->pev), removeSuit); +} + /* * VTC functions */ diff --git a/reapi/src/hook_callback.h b/reapi/src/hook_callback.h index ede4ad76..3c640716 100644 --- a/reapi/src/hook_callback.h +++ b/reapi/src/hook_callback.h @@ -560,6 +560,7 @@ void CBasePlayerWeapon_KickBack(IReGameHook_CBasePlayerWeapon_KickBack *chain, C void CBasePlayerWeapon_SendWeaponAnim(IReGameHook_CBasePlayerWeapon_SendWeaponAnim *chain, CBasePlayerWeapon *pthis, int iAnim, int skiplocal); void CBasePlayer_PlayerDeathThink(IReGameHook_CBasePlayer_PlayerDeathThink *chain, CBasePlayer *pthis); void CBasePlayer_Observer_Think(IReGameHook_CBasePlayer_Observer_Think *chain, CBasePlayer *pthis); +void CBasePlayer_RemoveAllItems(IReGameHook_CBasePlayer_RemoveAllItems *chain, CBasePlayer *pthis, BOOL removeSuit); /* * VTC functions diff --git a/reapi/src/hook_list.cpp b/reapi/src/hook_list.cpp index 8f5bf54a..cf38ad9f 100644 --- a/reapi/src/hook_list.cpp +++ b/reapi/src/hook_list.cpp @@ -215,6 +215,7 @@ hook_t hooklist_player[] = { DLL(CBasePlayer_PlayerDeathThink), DLL(CBasePlayer_Observer_Think), + DLL(CBasePlayer_RemoveAllItems), }; hook_t hooklist_gamerules[] = { diff --git a/reapi/src/hook_list.h b/reapi/src/hook_list.h index 6e6d9da7..cbd2f7d1 100644 --- a/reapi/src/hook_list.h +++ b/reapi/src/hook_list.h @@ -238,6 +238,7 @@ enum GamedllFunc_CBasePlayer RG_CBasePlayer_PlayerDeathThink, RG_CBasePlayer_Observer_Think, + RG_CBasePlayer_RemoveAllItems, // [...] }; diff --git a/reapi/version/version.h b/reapi/version/version.h index 721f2b48..cca231b8 100644 --- a/reapi/version/version.h +++ b/reapi/version/version.h @@ -6,5 +6,5 @@ #pragma once #define VERSION_MAJOR 5 -#define VERSION_MINOR 24 +#define VERSION_MINOR 25 #define VERSION_MAINTENANCE 0