Skip to content

Commit

Permalink
Implements Observer_Think Hook (#894)
Browse files Browse the repository at this point in the history
* Observer Think Hook
* Update CAPI_Impl.cpp
* Update CAPI_Impl.h
* Update regamedll_api.h
  • Loading branch information
overl4y authored Nov 26, 2023
1 parent fba9a33 commit 15bca2e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions regamedll/dlls/API/CAPI_Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions regamedll/dlls/API/CAPI_Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,10 @@ typedef IHookChainRegistryClassImpl<void, CBasePlayerWeapon, int, int> CReGameHo
typedef IHookChainClassImpl<void, CBasePlayer> CReGameHook_CBasePlayer_PlayerDeathThink;
typedef IHookChainRegistryClassImpl<void, CBasePlayer> CReGameHookRegistry_CBasePlayer_PlayerDeathThink;

// CBasePlayer::Observer_Think hook
typedef IHookChainClassImpl<void, CBasePlayer> CReGameHook_CBasePlayer_Observer_Think;
typedef IHookChainRegistryClassImpl<void, CBasePlayer> CReGameHookRegistry_CBasePlayer_Observer_Think;

class CReGameHookchains: public IReGameHookchains {
public:
// CBasePlayer virtual
Expand Down Expand Up @@ -900,6 +904,7 @@ class CReGameHookchains: public IReGameHookchains {
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();
Expand Down Expand Up @@ -1058,6 +1063,7 @@ class CReGameHookchains: public IReGameHookchains {
virtual IReGameHookRegistry_CSGameRules_SendDeathMessage *CSGameRules_SendDeathMessage();

virtual IReGameHookRegistry_CBasePlayer_PlayerDeathThink *CBasePlayer_PlayerDeathThink();
virtual IReGameHookRegistry_CBasePlayer_Observer_Think *CBasePlayer_Observer_Think();
};

extern CReGameHookchains g_ReGameHookchains;
Expand Down
6 changes: 4 additions & 2 deletions regamedll/dlls/observer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
3 changes: 2 additions & 1 deletion regamedll/dlls/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,8 @@ class CBasePlayer: public CBaseMonster {
void CheckTimeBasedDamage_OrigFunc();
edict_t *EntSelectSpawnPoint_OrigFunc();
void PlayerDeathThink_OrigFunc();

void Observer_Think_OrigFunc();

CCSPlayer *CSPlayer() const;
#endif // REGAMEDLL_API

Expand Down
5 changes: 5 additions & 0 deletions regamedll/public/regamedll/regamedll_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,10 @@ typedef IHookChainRegistryClass<void, CBasePlayerWeapon, int, int> IReGameHookRe
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_PlayerDeathThink;
typedef IHookChainRegistryClass<void, class CBasePlayer> IReGameHookRegistry_CBasePlayer_PlayerDeathThink;

// CBasePlayer::Observer_Think hook
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_Observer_Think;
typedef IHookChainRegistryClass<void, class CBasePlayer> IReGameHookRegistry_CBasePlayer_Observer_Think;

class IReGameHookchains {
public:
virtual ~IReGameHookchains() {}
Expand Down Expand Up @@ -780,6 +784,7 @@ class IReGameHookchains {
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 {
Expand Down

0 comments on commit 15bca2e

Please sign in to comment.