From 15bca2eab9b360c7f5b2c61c079d70eeacd9c854 Mon Sep 17 00:00:00 2001 From: Ecnologia <52111952+Mythlogic@users.noreply.github.com> Date: Sun, 26 Nov 2023 04:27:09 +0000 Subject: [PATCH] Implements Observer_Think Hook (#894) * Observer Think Hook * Update CAPI_Impl.cpp * Update CAPI_Impl.h * Update regamedll_api.h --- regamedll/dlls/API/CAPI_Impl.cpp | 1 + regamedll/dlls/API/CAPI_Impl.h | 6 ++++++ regamedll/dlls/observer.cpp | 6 ++++-- regamedll/dlls/player.h | 3 ++- regamedll/public/regamedll/regamedll_api.h | 5 +++++ 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/regamedll/dlls/API/CAPI_Impl.cpp b/regamedll/dlls/API/CAPI_Impl.cpp index 55a56e31..5bb6b394 100644 --- a/regamedll/dlls/API/CAPI_Impl.cpp +++ b/regamedll/dlls/API/CAPI_Impl.cpp @@ -334,6 +334,7 @@ GAMEHOOK_REGISTRY(CBasePlayerWeapon_SendWeaponAnim); GAMEHOOK_REGISTRY(CSGameRules_SendDeathMessage); GAMEHOOK_REGISTRY(CBasePlayer_PlayerDeathThink); +GAMEHOOK_REGISTRY(CBasePlayer_Observer_Think); int CReGameApi::GetMajorVersion() { return REGAMEDLL_API_VERSION_MAJOR; diff --git a/regamedll/dlls/API/CAPI_Impl.h b/regamedll/dlls/API/CAPI_Impl.h index b64f6d81..0548a841 100644 --- a/regamedll/dlls/API/CAPI_Impl.h +++ b/regamedll/dlls/API/CAPI_Impl.h @@ -741,6 +741,10 @@ typedef IHookChainRegistryClassImpl CReGameHo typedef IHookChainClassImpl CReGameHook_CBasePlayer_PlayerDeathThink; typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_PlayerDeathThink; +// CBasePlayer::Observer_Think hook +typedef IHookChainClassImpl CReGameHook_CBasePlayer_Observer_Think; +typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_Observer_Think; + class CReGameHookchains: public IReGameHookchains { public: // CBasePlayer virtual @@ -900,6 +904,7 @@ public: CReGameHookRegistry_CSGameRules_SendDeathMessage m_CSGameRules_SendDeathMessage; CReGameHookRegistry_CBasePlayer_PlayerDeathThink m_CBasePlayer_PlayerDeathThink; + CReGameHookRegistry_CBasePlayer_Observer_Think m_CBasePlayer_Observer_Think; public: virtual IReGameHookRegistry_CBasePlayer_Spawn *CBasePlayer_Spawn(); @@ -1058,6 +1063,7 @@ public: virtual IReGameHookRegistry_CSGameRules_SendDeathMessage *CSGameRules_SendDeathMessage(); virtual IReGameHookRegistry_CBasePlayer_PlayerDeathThink *CBasePlayer_PlayerDeathThink(); + virtual IReGameHookRegistry_CBasePlayer_Observer_Think *CBasePlayer_Observer_Think(); }; extern CReGameHookchains g_ReGameHookchains; diff --git a/regamedll/dlls/observer.cpp b/regamedll/dlls/observer.cpp index e0bdc644..4b3521a6 100644 --- a/regamedll/dlls/observer.cpp +++ b/regamedll/dlls/observer.cpp @@ -541,9 +541,11 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Observer_SetMode)(int iMode) m_bWasFollowing = false; } -void CBasePlayer::Observer_Think() +LINK_HOOK_CLASS_VOID_CHAIN2(CBasePlayer, Observer_Think) + +void EXT_FUNC CBasePlayer::__API_HOOK(Observer_Think)() { Observer_HandleButtons(); Observer_CheckTarget(); Observer_CheckProperties(); -} +} \ No newline at end of file diff --git a/regamedll/dlls/player.h b/regamedll/dlls/player.h index ce201dea..bd3bf33e 100644 --- a/regamedll/dlls/player.h +++ b/regamedll/dlls/player.h @@ -447,7 +447,8 @@ public: void CheckTimeBasedDamage_OrigFunc(); edict_t *EntSelectSpawnPoint_OrigFunc(); void PlayerDeathThink_OrigFunc(); - + void Observer_Think_OrigFunc(); + CCSPlayer *CSPlayer() const; #endif // REGAMEDLL_API diff --git a/regamedll/public/regamedll/regamedll_api.h b/regamedll/public/regamedll/regamedll_api.h index e1191494..0d8fd4f1 100644 --- a/regamedll/public/regamedll/regamedll_api.h +++ b/regamedll/public/regamedll/regamedll_api.h @@ -620,6 +620,10 @@ typedef IHookChainRegistryClass IReGameHookRe typedef IHookChainClass IReGameHook_CBasePlayer_PlayerDeathThink; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_PlayerDeathThink; +// CBasePlayer::Observer_Think hook +typedef IHookChainClass IReGameHook_CBasePlayer_Observer_Think; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Observer_Think; + class IReGameHookchains { public: virtual ~IReGameHookchains() {} @@ -780,6 +784,7 @@ public: virtual IReGameHookRegistry_CSGameRules_SendDeathMessage *CSGameRules_SendDeathMessage() = 0; virtual IReGameHookRegistry_CBasePlayer_PlayerDeathThink *CBasePlayer_PlayerDeathThink() = 0; + virtual IReGameHookRegistry_CBasePlayer_Observer_Think *CBasePlayer_Observer_Think() = 0; }; struct ReGameFuncs_t {