From dfa4ca6111e7023319c63fe9d8356bcf78ec64cc Mon Sep 17 00:00:00 2001 From: Franco Romaniello Date: Tue, 31 Aug 2021 04:36:21 -0300 Subject: [PATCH 1/2] Implement Observer_FindNextPlayer hook --- regamedll/dlls/API/CAPI_Impl.cpp | 1 + regamedll/dlls/API/CAPI_Impl.h | 6 ++++++ regamedll/dlls/observer.cpp | 4 +++- regamedll/dlls/player.h | 3 ++- regamedll/public/regamedll/regamedll_api.h | 7 ++++++- 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/regamedll/dlls/API/CAPI_Impl.cpp b/regamedll/dlls/API/CAPI_Impl.cpp index 9251fe3e9..0543433d0 100644 --- a/regamedll/dlls/API/CAPI_Impl.cpp +++ b/regamedll/dlls/API/CAPI_Impl.cpp @@ -87,6 +87,7 @@ GAMEHOOK_REGISTRY(CBasePlayer_RoundRespawn); GAMEHOOK_REGISTRY(CBasePlayer_Blind); GAMEHOOK_REGISTRY(CBasePlayer_Observer_IsValidTarget); +GAMEHOOK_REGISTRY(CBasePlayer_Observer_FindNextPlayer); GAMEHOOK_REGISTRY(CBasePlayer_SetAnimation); GAMEHOOK_REGISTRY(CBasePlayer_GiveDefaultItems); GAMEHOOK_REGISTRY(CBasePlayer_GiveNamedItem); diff --git a/regamedll/dlls/API/CAPI_Impl.h b/regamedll/dlls/API/CAPI_Impl.h index 8ff309bbe..40ad16d1a 100644 --- a/regamedll/dlls/API/CAPI_Impl.h +++ b/regamedll/dlls/API/CAPI_Impl.h @@ -253,6 +253,10 @@ typedef IHookChainRegistryClassImpl typedef IHookChainClassImpl CReGameHook_CBasePlayer_Observer_IsValidTarget; typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_Observer_IsValidTarget; +// CBasePlayer::Observer_FindNextPlayer hook +typedef IHookChainClassImpl CReGameHook_CBasePlayer_Observer_FindNextPlayer; +typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_Observer_FindNextPlayer; + // CBasePlayer::SetAnimation hook typedef IHookChainClassImpl CReGameHook_CBasePlayer_SetAnimation; typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_SetAnimation; @@ -660,6 +664,7 @@ class CReGameHookchains: public IReGameHookchains { CReGameHookRegistry_CBasePlayer_Blind m_CBasePlayer_Blind; CReGameHookRegistry_CBasePlayer_Observer_IsValidTarget m_CBasePlayer_Observer_IsValidTarget; + CReGameHookRegistry_CBasePlayer_Observer_FindNextPlayer m_CBasePlayer_Observer_FindNextPlayer; CReGameHookRegistry_CBasePlayer_SetAnimation m_CBasePlayer_SetAnimation; CReGameHookRegistry_CBasePlayer_GiveDefaultItems m_CBasePlayer_GiveDefaultItems; CReGameHookRegistry_CBasePlayer_GiveNamedItem m_CBasePlayer_GiveNamedItem; @@ -788,6 +793,7 @@ class CReGameHookchains: public IReGameHookchains { virtual IReGameHookRegistry_CBasePlayer_Blind *CBasePlayer_Blind(); virtual IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget *CBasePlayer_Observer_IsValidTarget(); + virtual IReGameHookRegistry_CBasePlayer_Observer_FindNextPlayer *CBasePlayer_Observer_FindNextPlayer(); virtual IReGameHookRegistry_CBasePlayer_SetAnimation *CBasePlayer_SetAnimation(); virtual IReGameHookRegistry_CBasePlayer_GiveDefaultItems *CBasePlayer_GiveDefaultItems(); virtual IReGameHookRegistry_CBasePlayer_GiveNamedItem *CBasePlayer_GiveNamedItem(); diff --git a/regamedll/dlls/observer.cpp b/regamedll/dlls/observer.cpp index b00aae43a..a7cdb7615 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 76a9c207e..97afaf776 100644 --- a/regamedll/dlls/player.h +++ b/regamedll/dlls/player.h @@ -414,6 +414,7 @@ class CBasePlayer: public CBaseMonster { void RoundRespawn_OrigFunc(); void Blind_OrigFunc(float flUntilTime, float flHoldTime, float flFadeTime, int iAlpha); EXT_FUNC CBasePlayer *Observer_IsValidTarget_OrigFunc(int iPlayerIndex, bool bSameTeam); + EXT_FUNC void Observer_FindNextPlayer_OrigFunc(bool bReverse, const char* name = nullptr); void Radio_OrigFunc(const char *msg_id, const char *msg_verbose = nullptr, short pitch = 100, bool showIcon = true); void AddAccount_OrigFunc(int amount, RewardType type = RT_NONE, bool bTrackChange = true); void Disappear_OrigFunc(); @@ -452,7 +453,7 @@ class CBasePlayer: public CBaseMonster { static CBasePlayer *Instance(int offset) { return Instance(ENT(offset)); } void SpawnClientSideCorpse(); - void Observer_FindNextPlayer(bool bReverse, const char *name = nullptr); + virtual void Observer_FindNextPlayer(bool bReverse, const char *name = nullptr); CBasePlayer *Observer_IsValidTarget(int iPlayerIndex, bool bSameTeam); void Disconnect(); void Observer_Think(); diff --git a/regamedll/public/regamedll/regamedll_api.h b/regamedll/public/regamedll/regamedll_api.h index 541c32faa..2d9808620 100644 --- a/regamedll/public/regamedll/regamedll_api.h +++ b/regamedll/public/regamedll/regamedll_api.h @@ -38,7 +38,7 @@ #include #define REGAMEDLL_API_VERSION_MAJOR 5 -#define REGAMEDLL_API_VERSION_MINOR 21 +#define REGAMEDLL_API_VERSION_MINOR 22 // CBasePlayer::Spawn hook typedef IHookChainClass IReGameHook_CBasePlayer_Spawn; @@ -132,6 +132,10 @@ typedef IHookChainRegistryClass IReGameHook_CBasePlayer_Observer_IsValidTarget; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget; +// CBasePlayer::Observer_FindNextPlayer hook +typedef IHookChainClass IReGameHook_CBasePlayer_Observer_FindNextPlayer; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Observer_FindNextPlayer; + // CBasePlayer::SetAnimation hook typedef IHookChainClass IReGameHook_CBasePlayer_SetAnimation; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_SetAnimation; @@ -541,6 +545,7 @@ class IReGameHookchains { virtual IReGameHookRegistry_CBasePlayer_Blind *CBasePlayer_Blind() = 0; virtual IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget *CBasePlayer_Observer_IsValidTarget() = 0; + virtual IReGameHookRegistry_CBasePlayer_Observer_FindNextPlayer *CBasePlayer_Observer_FindNextPlayer() = 0; virtual IReGameHookRegistry_CBasePlayer_SetAnimation *CBasePlayer_SetAnimation() = 0; virtual IReGameHookRegistry_CBasePlayer_GiveDefaultItems *CBasePlayer_GiveDefaultItems() = 0; virtual IReGameHookRegistry_CBasePlayer_GiveNamedItem *CBasePlayer_GiveNamedItem() = 0; From 6a6279e107daac1cc4f3d1deed09036ddedb9c21 Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Tue, 31 Aug 2021 15:32:32 +0300 Subject: [PATCH 2/2] fixes --- regamedll/dlls/player.h | 2 +- regamedll/public/regamedll/regamedll_api.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/regamedll/dlls/player.h b/regamedll/dlls/player.h index 97afaf776..9bd77cf91 100644 --- a/regamedll/dlls/player.h +++ b/regamedll/dlls/player.h @@ -453,7 +453,7 @@ class CBasePlayer: public CBaseMonster { static CBasePlayer *Instance(int offset) { return Instance(ENT(offset)); } void SpawnClientSideCorpse(); - virtual void Observer_FindNextPlayer(bool bReverse, const char *name = nullptr); + void Observer_FindNextPlayer(bool bReverse, const char *name = nullptr); CBasePlayer *Observer_IsValidTarget(int iPlayerIndex, bool bSameTeam); void Disconnect(); void Observer_Think(); diff --git a/regamedll/public/regamedll/regamedll_api.h b/regamedll/public/regamedll/regamedll_api.h index 2d9808620..aeaad2fc4 100644 --- a/regamedll/public/regamedll/regamedll_api.h +++ b/regamedll/public/regamedll/regamedll_api.h @@ -38,7 +38,7 @@ #include #define REGAMEDLL_API_VERSION_MAJOR 5 -#define REGAMEDLL_API_VERSION_MINOR 22 +#define REGAMEDLL_API_VERSION_MINOR 21 // CBasePlayer::Spawn hook typedef IHookChainClass IReGameHook_CBasePlayer_Spawn;