From 7e2279f8c5ee8c5b2e5691a69e64b1e17820a7ac Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Tue, 31 Aug 2021 22:04:32 +0300 Subject: [PATCH] Implement `CBasePlayer::Observer_FindNextPlayer()` hook (#667) * Implement Observer_FindNextPlayer hook Co-authored-by: Sergey Shorokhov --- regamedll/dlls/API/CAPI_Impl.cpp | 1 + regamedll/dlls/API/CAPI_Impl.h | 6 ++++++ regamedll/dlls/observer.cpp | 4 +++- regamedll/dlls/player.h | 1 + regamedll/public/regamedll/regamedll_api.h | 5 +++++ 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/regamedll/dlls/API/CAPI_Impl.cpp b/regamedll/dlls/API/CAPI_Impl.cpp index 17bf1231..0fe10a49 100644 --- a/regamedll/dlls/API/CAPI_Impl.cpp +++ b/regamedll/dlls/API/CAPI_Impl.cpp @@ -198,6 +198,7 @@ GAMEHOOK_REGISTRY(CBaseEntity_FireBuckshots); GAMEHOOK_REGISTRY(CBaseEntity_FireBullets3); GAMEHOOK_REGISTRY(CBasePlayer_Observer_SetMode); +GAMEHOOK_REGISTRY(CBasePlayer_Observer_FindNextPlayer); GAMEHOOK_REGISTRY(CBasePlayer_Pain); GAMEHOOK_REGISTRY(CBasePlayer_DeathSound); diff --git a/regamedll/dlls/API/CAPI_Impl.h b/regamedll/dlls/API/CAPI_Impl.h index 65d0c023..1be3dd23 100644 --- a/regamedll/dlls/API/CAPI_Impl.h +++ b/regamedll/dlls/API/CAPI_Impl.h @@ -625,6 +625,10 @@ typedef IHookChainRegistryClassImpl CReGameHook_CBasePlayer_Observer_SetMode; typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_Observer_SetMode; +// CBasePlayer::Observer_FindNextPlayer hook +typedef IHookChainClassImpl CReGameHook_CBasePlayer_Observer_FindNextPlayer; +typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_Observer_FindNextPlayer; + // CBasePlayer::Pain hook typedef IHookChainClassImpl CReGameHook_CBasePlayer_Pain; typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_Pain; @@ -764,6 +768,7 @@ public: CReGameHookRegistry_CBaseEntity_FireBullets3 m_CBaseEntity_FireBullets3; CReGameHookRegistry_CBasePlayer_Observer_SetMode m_CBasePlayer_Observer_SetMode; + CReGameHookRegistry_CBasePlayer_Observer_FindNextPlayer m_CBasePlayer_Observer_FindNextPlayer; CReGameHookRegistry_CBasePlayer_Pain m_CBasePlayer_Pain; CReGameHookRegistry_CBasePlayer_DeathSound m_CBasePlayer_DeathSound; @@ -894,6 +899,7 @@ public: virtual IReGameHookRegistry_CBaseEntity_FireBullets3 *CBaseEntity_FireBullets3(); virtual IReGameHookRegistry_CBasePlayer_Observer_SetMode *CBasePlayer_Observer_SetMode(); + virtual IReGameHookRegistry_CBasePlayer_Observer_FindNextPlayer *CBasePlayer_Observer_FindNextPlayer(); virtual IReGameHookRegistry_CBasePlayer_Pain *CBasePlayer_Pain(); virtual IReGameHookRegistry_CBasePlayer_DeathSound *CBasePlayer_DeathSound(); diff --git a/regamedll/dlls/observer.cpp b/regamedll/dlls/observer.cpp index 8ecc3968..336b7b3c 100644 --- a/regamedll/dlls/observer.cpp +++ b/regamedll/dlls/observer.cpp @@ -137,8 +137,10 @@ void UpdateClientEffects(CBasePlayer *pObserver, int oldMode) } } +LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, Observer_FindNextPlayer, (bool bReverse, const char *name), bReverse, name) + // Find the next client in the game for this player to spectate -void CBasePlayer::Observer_FindNextPlayer(bool bReverse, const char *name) +void CBasePlayer::__API_HOOK(Observer_FindNextPlayer)(bool bReverse, const char *name) { int iStart; int iCurrent; diff --git a/regamedll/dlls/player.h b/regamedll/dlls/player.h index 57e012eb..adebe12a 100644 --- a/regamedll/dlls/player.h +++ b/regamedll/dlls/player.h @@ -440,6 +440,7 @@ public: void UseEmpty_OrigFunc(); void DropIdlePlayer_OrigFunc(const char *reason); void Observer_SetMode_OrigFunc(int iMode); + EXT_FUNC void Observer_FindNextPlayer_OrigFunc(bool bReverse, const char* name = nullptr); void Pain_OrigFunc(int iLastHitGroup, bool bHasArmour); void DeathSound_OrigFunc(); void JoiningThink_OrigFunc(); diff --git a/regamedll/public/regamedll/regamedll_api.h b/regamedll/public/regamedll/regamedll_api.h index 2c7eaf11..ba7a8517 100644 --- a/regamedll/public/regamedll/regamedll_api.h +++ b/regamedll/public/regamedll/regamedll_api.h @@ -504,6 +504,10 @@ typedef IHookChainRegistryClass IReGameHook_CBasePlayer_Observer_SetMode; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Observer_SetMode; +// CBasePlayer::Observer_FindNextPlayer hook +typedef IHookChainClass IReGameHook_CBasePlayer_Observer_FindNextPlayer; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Observer_FindNextPlayer; + // CBasePlayer::Pain hook typedef IHookChainClass IReGameHook_CBasePlayer_Pain; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Pain; @@ -644,6 +648,7 @@ public: virtual IReGameHookRegistry_CBaseEntity_FireBullets3 *CBaseEntity_FireBullets3() = 0; virtual IReGameHookRegistry_CBasePlayer_Observer_SetMode *CBasePlayer_Observer_SetMode() = 0; + virtual IReGameHookRegistry_CBasePlayer_Observer_FindNextPlayer *CBasePlayer_Observer_FindNextPlayer() = 0; virtual IReGameHookRegistry_CBasePlayer_Pain *CBasePlayer_Pain() = 0; virtual IReGameHookRegistry_CBasePlayer_DeathSound *CBasePlayer_DeathSound() = 0;