Skip to content

Commit

Permalink
Rework hookchain RG_PM_Move
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lentq committed Aug 29, 2019
1 parent 6068d4e commit bba0631
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ enum GamedllFunc

/*
* Description: -
* Params: (const ppmove, const server)
* Params: (const playerIndex)
*/
RG_PM_Move,

Expand Down
16 changes: 12 additions & 4 deletions reapi/src/hook_callback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,15 +606,23 @@ bool RoundEnd(IReGameHook_RoundEnd *chain, int winStatus, ScenarioEventEndRound
return callForward<bool>(RG_RoundEnd, original, winStatus, event, tmDelay);
}

void PM_Move(IReGameHook_PM_Move *chain, playermove_t *ppmove, int server)
void PM_Move_AMXX(Move_t *data, int playerIndex)
{
auto original = [chain](playermove_t *_ppmove, int _server)
auto original = [data](int _playerIndex)
{
chain->callNext(_ppmove, _server);
data->m_chain->callNext(data->m_args.ppmove, data->m_args.server);
};

callVoidForward(RG_PM_Move, original, playerIndex);
}

void PM_Move(IReGameHook_PM_Move *chain, playermove_t *ppmove, int server)
{
g_pMove = ppmove;
callVoidForward(RG_PM_Move, original, ppmove, server);

Move_args_t args(ppmove, server);
Move_t data(chain, args);
PM_Move_AMXX(&data, ppmove->player_index + 1);
}

void PM_AirMove(IReGameHook_PM_AirMove *chain, int playerIndex)
Expand Down
12 changes: 12 additions & 0 deletions reapi/src/hook_callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,19 @@ int GetForceCamera(IReGameHook_GetForceCamera *chain, CBasePlayer *pObserver);
void PlayerBlind(IReGameHook_PlayerBlind *chain, CBasePlayer *pPlayer, entvars_t *pevInflictor, entvars_t *pevAttacker, float fadeTime, float fadeHold, int alpha, Vector& color);
void RadiusFlash_TraceLine(IReGameHook_RadiusFlash_TraceLine *chain, CBasePlayer *pPlayer, entvars_t *pevInflictor, entvars_t *pevAttacker, Vector& vecSrc, Vector& vecSpot, TraceResult *ptr);
bool RoundEnd(IReGameHook_RoundEnd *chain, int winStatus, ScenarioEventEndRound event, float tmDelay);

struct Move_args_t
{
Move_args_t(playermove_t *_ppmove, int _server) : ppmove(_ppmove), server(_server) {}

playermove_t *ppmove;
int server;
};

using Move_t = hookdata_t<IReGameHook_PM_Move *, Move_args_t &>;
void PM_Move_AMXX(Move_t *data, int playerIndex);
void PM_Move(IReGameHook_PM_Move *chain, playermove_t *ppmove, int server);

void PM_AirMove(IReGameHook_PM_AirMove *chain, int playerIndex);
void HandleMenu_ChooseAppearance(IReGameHook_HandleMenu_ChooseAppearance *chain, CBasePlayer *pPlayer, int slot);
BOOL HandleMenu_ChooseTeam(IReGameHook_HandleMenu_ChooseTeam *chain, CBasePlayer *pPlayer, int slot);
Expand Down
4 changes: 2 additions & 2 deletions reapi/src/hook_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ hook_t hooklist_engine[] = {
ENG(SV_WriteFullClientUpdate, _AMXX)
};

#define DLL(h) { {}, {}, #h, "ReGameDLL", [](){ return api_cfg.hasReGameDLL(); }, ((!(RG_##h & (MAX_REGION_RANGE - 1)) ? regfunc::current_cell = 1, true : false) || (RG_##h & (MAX_REGION_RANGE - 1)) == regfunc::current_cell++) ? regfunc(h) : regfunc(#h), [](){ g_ReGameHookchains->h()->registerHook(&h); }, [](){ g_ReGameHookchains->h()->unregisterHook(&h); }}
#define DLL(h,...) { {}, {}, #h, "ReGameDLL", [](){ return api_cfg.hasReGameDLL(); }, ((!(RG_##h & (MAX_REGION_RANGE - 1)) ? regfunc::current_cell = 1, true : false) || (RG_##h & (MAX_REGION_RANGE - 1)) == regfunc::current_cell++) ? regfunc(h##__VA_ARGS__) : regfunc(#h#__VA_ARGS__), [](){ g_ReGameHookchains->h()->registerHook(&h); }, [](){ g_ReGameHookchains->h()->unregisterHook(&h); }}
hook_t hooklist_gamedll[] = {
DLL(GetForceCamera),
DLL(PlayerBlind),
DLL(RadiusFlash_TraceLine),
DLL(RoundEnd),
DLL(PM_Move),
DLL(PM_Move, _AMXX),
DLL(PM_AirMove),
DLL(HandleMenu_ChooseAppearance),
DLL(HandleMenu_ChooseTeam),
Expand Down

0 comments on commit bba0631

Please sign in to comment.