Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Check* Hooks #313

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,41 @@ enum GamedllFunc_CSGameRules
* Params: (const pKiller, const pVictim, const pAssister, const pevInflictor, const killerWeaponName[], const DeathMessageFlags:iDeathMessageFlags, const KillRarity:iRarityOfKill)
*/
RG_CSGameRules_SendDeathMessage,

/*
* Description: Called when the game over condition is being checked.
* Return type: bool
* Params: ()
*/
RG_CSGameRules_CheckGameOver,

/*
* Description: Called when the time limit condition is being checked.
* Return type: bool
* Params: ()
*/
RG_CSGameRules_CheckTimeLimit,

/*
* Description: Called when the frag limit condition is being checked.
* Return type: bool
* Params: ()
*/
RG_CSGameRules_CheckFragLimit,

/*
* Description: Called when the max rounds condition is being checked.
* Return type: bool
* Params: ()
*/
RG_CSGameRules_CheckMaxRounds,

/*
* Description: Called when the win limit condition is being checked.
* Return type: bool
* Params: ()
*/
RG_CSGameRules_CheckWinLimit,
};

/**
Expand Down
7 changes: 7 additions & 0 deletions reapi/include/cssdk/dlls/gamerules.h
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,13 @@ class CHalfLifeMultiplay: public CGameRules

virtual void SendDeathMessage(CBaseEntity *pKiller, CBasePlayer *pVictim, CBasePlayer *pAssister, entvars_t *pevInflictor, const char *killerWeaponName, int iDeathMessageFlags, int iRarityOfKill) = 0;

// Check various conditions to end the map.
virtual BOOL CheckGameOver() = 0;
virtual BOOL CheckTimeLimit() = 0;
virtual BOOL CheckFragLimit() = 0;
virtual BOOL CheckMaxRounds() = 0;
virtual BOOL CheckWinLimit() = 0;

public:
bool ShouldSkipShowMenu() const { return m_bSkipShowMenu; }
void MarkShowMenuSkipped() { m_bSkipShowMenu = false; }
Expand Down
26 changes: 26 additions & 0 deletions reapi/include/cssdk/dlls/regamedll_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,26 @@ typedef IHookChainRegistryClass<void, class CBasePlayer> IReGameHookRegistry_CBa
typedef IHookChainClass<void, class CBasePlayer, BOOL> IReGameHook_CBasePlayer_RemoveAllItems;
typedef IHookChainRegistryClass<void, class CBasePlayer, BOOL> IReGameHookRegistry_CBasePlayer_RemoveAllItems;

// CHalfLifeMultiplay::CheckGameOver hook
typedef IHookChain<BOOL> IReGameHook_CSGameRules_CheckGameOver;
typedef IHookChainRegistry<BOOL> IReGameHookRegistry_CSGameRules_CheckGameOver;

// CHalfLifeMultiplay::CheckTimeLimit hook
typedef IHookChain<BOOL> IReGameHook_CSGameRules_CheckTimeLimit;
typedef IHookChainRegistry<BOOL> IReGameHookRegistry_CSGameRules_CheckTimeLimit;

// CHalfLifeMultiplay::CheckFragLimit hook
typedef IHookChain<BOOL> IReGameHook_CSGameRules_CheckFragLimit;
typedef IHookChainRegistry<BOOL> IReGameHookRegistry_CSGameRules_CheckFragLimit;

// CHalfLifeMultiplay::CheckMaxRounds hook
typedef IHookChain<BOOL> IReGameHook_CSGameRules_CheckMaxRounds;
typedef IHookChainRegistry<BOOL> IReGameHookRegistry_CSGameRules_CheckMaxRounds;

// CHalfLifeMultiplay::CheckWinLimit hook
typedef IHookChain<BOOL> IReGameHook_CSGameRules_CheckWinLimit;
typedef IHookChainRegistry<BOOL> IReGameHookRegistry_CSGameRules_CheckWinLimit;

class IReGameHookchains {
public:
virtual ~IReGameHookchains() {}
Expand Down Expand Up @@ -792,6 +812,12 @@ class IReGameHookchains {
virtual IReGameHookRegistry_CBasePlayer_PlayerDeathThink *CBasePlayer_PlayerDeathThink() = 0;
virtual IReGameHookRegistry_CBasePlayer_Observer_Think *CBasePlayer_Observer_Think() = 0;
virtual IReGameHookRegistry_CBasePlayer_RemoveAllItems *CBasePlayer_RemoveAllItems() = 0;

virtual IReGameHookRegistry_CSGameRules_CheckGameOver *CSGameRules_CheckGameOver() = 0;
virtual IReGameHookRegistry_CSGameRules_CheckTimeLimit *CSGameRules_CheckTimeLimit() = 0;
virtual IReGameHookRegistry_CSGameRules_CheckFragLimit *CSGameRules_CheckFragLimit() = 0;
virtual IReGameHookRegistry_CSGameRules_CheckMaxRounds *CSGameRules_CheckMaxRounds() = 0;
virtual IReGameHookRegistry_CSGameRules_CheckWinLimit *CSGameRules_CheckWinLimit() = 0;
};

struct ReGameFuncs_t {
Expand Down
50 changes: 50 additions & 0 deletions reapi/src/hook_callback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1766,6 +1766,56 @@ void CSGameRules_SendDeathMessage(IReGameHook_CSGameRules_SendDeathMessage *chai
callVoidForward(RG_CSGameRules_SendDeathMessage, original, indexOfPDataAmx(pKiller), indexOfEdict(pVictim->pev), indexOfPDataAmx(pAssister), indexOfEdictAmx(pevInflictor), killerWeaponName, iDeathMessageFlags, iRarityOfKill);
}

BOOL CSGameRules_CheckGameOver(IReGameHook_CSGameRules_CheckGameOver *chain)
{
auto original = [chain]()
{
return chain->callNext();
};

return callForward<BOOL>(RG_CSGameRules_CheckGameOver, original);
}

BOOL CSGameRules_CheckTimeLimit(IReGameHook_CSGameRules_CheckTimeLimit *chain)
{
auto original = [chain]()
{
return chain->callNext();
};

return callForward<BOOL>(RG_CSGameRules_CheckTimeLimit, original);
}

BOOL CSGameRules_CheckFragLimit(IReGameHook_CSGameRules_CheckFragLimit *chain)
{
auto original = [chain]()
{
return chain->callNext();
};

return callForward<BOOL>(RG_CSGameRules_CheckFragLimit, original);
}

BOOL CSGameRules_CheckMaxRounds(IReGameHook_CSGameRules_CheckMaxRounds *chain)
{
auto original = [chain]()
{
return chain->callNext();
};

return callForward<BOOL>(RG_CSGameRules_CheckMaxRounds, original);
}

BOOL CSGameRules_CheckWinLimit(IReGameHook_CSGameRules_CheckWinLimit *chain)
{
auto original = [chain]()
{
return chain->callNext();
};

return callForward<BOOL>(RG_CSGameRules_CheckWinLimit, original);
}

/*
* VTC functions
*/
Expand Down
6 changes: 6 additions & 0 deletions reapi/src/hook_callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,12 @@ void CBasePlayer_Observer_Think(IReGameHook_CBasePlayer_Observer_Think *chain, C
void CBasePlayer_RemoveAllItems(IReGameHook_CBasePlayer_RemoveAllItems *chain, CBasePlayer *pthis, BOOL removeSuit);
void CSGameRules_SendDeathMessage(IReGameHook_CSGameRules_SendDeathMessage *chain, CBaseEntity *pKiller, CBasePlayer *pVictim, CBasePlayer *pAssister, entvars_t *pevInflictor, const char *killerWeaponName, int iDeathMessageFlags, int iRarityOfKill);

BOOL CSGameRules_CheckGameOver(IReGameHook_CSGameRules_CheckGameOver *chain);
BOOL CSGameRules_CheckTimeLimit(IReGameHook_CSGameRules_CheckTimeLimit *chain);
BOOL CSGameRules_CheckFragLimit(IReGameHook_CSGameRules_CheckFragLimit *chain);
BOOL CSGameRules_CheckMaxRounds(IReGameHook_CSGameRules_CheckMaxRounds *chain);
BOOL CSGameRules_CheckWinLimit(IReGameHook_CSGameRules_CheckWinLimit *chain);

/*
* VTC functions
*/
Expand Down
5 changes: 5 additions & 0 deletions reapi/src/hook_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@ hook_t hooklist_gamerules[] = {
DLL(CSGameRules_TeamStacked),
DLL(CSGameRules_PlayerGotWeapon),
DLL(CSGameRules_SendDeathMessage),
DLL(CSGameRules_CheckGameOver),
DLL(CSGameRules_CheckTimeLimit),
DLL(CSGameRules_CheckFragLimit),
DLL(CSGameRules_CheckMaxRounds),
DLL(CSGameRules_CheckWinLimit),
};

hook_t hooklist_grenade[] = {
Expand Down
5 changes: 5 additions & 0 deletions reapi/src/hook_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,11 @@ enum GamedllFunc_CSGameRules
RG_CSGameRules_TeamStacked,
RG_CSGameRules_PlayerGotWeapon,
RG_CSGameRules_SendDeathMessage,
RG_CSGameRules_CheckGameOver,
RG_CSGameRules_CheckTimeLimit,
RG_CSGameRules_CheckFragLimit,
RG_CSGameRules_CheckMaxRounds,
RG_CSGameRules_CheckWinLimit,

// [...]
};
Expand Down
Loading