Skip to content

Commit

Permalink
API: Implement PM_LadderMove hook (#740)
Browse files Browse the repository at this point in the history
Related to rehlds/reapi#82
  • Loading branch information
ShadowsAdi authored Jul 15, 2023
1 parent 8a8f348 commit 718f033
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions regamedll/dlls/API/CAPI_Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ GAMEHOOK_REGISTRY(CBasePlayer_DeathSound);
GAMEHOOK_REGISTRY(CBasePlayer_JoiningThink);

GAMEHOOK_REGISTRY(FreeGameRules);
GAMEHOOK_REGISTRY(PM_LadderMove);

int CReGameApi::GetMajorVersion() {
return REGAMEDLL_API_VERSION_MAJOR;
Expand Down
7 changes: 7 additions & 0 deletions regamedll/dlls/API/CAPI_Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,10 @@ typedef IHookChainRegistryImpl<void, struct playermove_s *, int> CReGameHookRegi
typedef IHookChainImpl<void, int> CReGameHook_PM_AirMove;
typedef IHookChainRegistryImpl<void, int> CReGameHookRegistry_PM_AirMove;

// PM_LadderMove hook
typedef IHookChainImpl<void, struct physent_s *> CReGameHook_PM_LadderMove;
typedef IHookChainRegistryImpl<void, struct physent_s *> CReGameHookRegistry_PM_LadderMove;

// HandleMenu_ChooseAppearance hook
typedef IHookChainImpl<void, CBasePlayer *, int> CReGameHook_HandleMenu_ChooseAppearance;
typedef IHookChainRegistryImpl<void, CBasePlayer *, int> CReGameHookRegistry_HandleMenu_ChooseAppearance;
Expand Down Expand Up @@ -777,6 +781,8 @@ class CReGameHookchains: public IReGameHookchains {
CReGameHookRegistry_CBasePlayer_Pain m_CBasePlayer_Pain;
CReGameHookRegistry_CBasePlayer_DeathSound m_CBasePlayer_DeathSound;
CReGameHookRegistry_CBasePlayer_JoiningThink m_CBasePlayer_JoiningThink;

CReGameHookRegistry_PM_LadderMove m_PM_LadderMove;

CReGameHookRegistry_FreeGameRules m_FreeGameRules;

Expand Down Expand Up @@ -912,6 +918,7 @@ class CReGameHookchains: public IReGameHookchains {
virtual IReGameHookRegistry_CBasePlayer_JoiningThink *CBasePlayer_JoiningThink();

virtual IReGameHookRegistry_FreeGameRules *FreeGameRules();
virtual IReGameHookRegistry_PM_LadderMove *PM_LadderMove();
};

extern CReGameHookchains g_ReGameHookchains;
Expand Down
4 changes: 3 additions & 1 deletion regamedll/pm_shared/pm_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1967,7 +1967,9 @@ void PM_Duck()
}
}

void PM_LadderMove(physent_t *pLadder)
LINK_HOOK_VOID_CHAIN(PM_LadderMove, (physent_t *pLadder), pLadder);

void EXT_FUNC __API_HOOK(PM_LadderMove)(physent_t *pLadder)
{
vec3_t ladderCenter;
trace_t trace;
Expand Down
2 changes: 2 additions & 0 deletions regamedll/pm_shared/pm_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@ void PM_Init(struct playermove_s *ppmove);
void PM_Move(struct playermove_s *ppmove, int server);
char PM_FindTextureType(char *name);
void PM_AirMove_internal();
void PM_LadderMove(physent_t *pLadder);

#ifdef REGAMEDLL_API
void PM_Init_OrigFunc(struct playermove_s *ppmove);
void PM_Move_OrigFunc(struct playermove_s *ppmove, int server);
void PM_AirMove_OrigFunc(int playerIndex = 0);
void PM_UpdateStepSound_OrigFunc();
void PM_LadderMove_OrigFunc(physent_t *pLadder);
#else
void PM_AirMove(int playerIndex = 0);
#endif
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 @@ -236,6 +236,10 @@ typedef IHookChainRegistry<void, struct playermove_s *, int> IReGameHookRegistry
typedef IHookChain<void, int> IReGameHook_PM_AirMove;
typedef IHookChainRegistry<void, int> IReGameHookRegistry_PM_AirMove;

// PM_LadderMove hook
typedef IHookChain<void, struct physent_s *> IReGameHook_PM_LadderMove;
typedef IHookChainRegistry<void, struct physent_s *> IReGameHookRegistry_PM_LadderMove;

// HandleMenu_ChooseAppearance hook
typedef IHookChain<void, class CBasePlayer *, int> IReGameHook_HandleMenu_ChooseAppearance;
typedef IHookChainRegistry<void, class CBasePlayer *, int> IReGameHookRegistry_HandleMenu_ChooseAppearance;
Expand Down Expand Up @@ -659,6 +663,7 @@ class IReGameHookchains {
virtual IReGameHookRegistry_CBasePlayer_JoiningThink *CBasePlayer_JoiningThink() = 0;

virtual IReGameHookRegistry_FreeGameRules *FreeGameRules() = 0;
virtual IReGameHookRegistry_PM_LadderMove *PM_LadderMove() = 0;
};

struct ReGameFuncs_t {
Expand Down

0 comments on commit 718f033

Please sign in to comment.