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 #963

Open
wants to merge 2 commits 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
6 changes: 6 additions & 0 deletions regamedll/dlls/API/CAPI_Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,12 @@ GAMEHOOK_REGISTRY(CBasePlayer_PlayerDeathThink);
GAMEHOOK_REGISTRY(CBasePlayer_Observer_Think);
GAMEHOOK_REGISTRY(CBasePlayer_RemoveAllItems);

GAMEHOOK_REGISTRY(CSGameRules_CheckGameOver);
GAMEHOOK_REGISTRY(CSGameRules_CheckTimeLimit);
GAMEHOOK_REGISTRY(CSGameRules_CheckFragLimit);
GAMEHOOK_REGISTRY(CSGameRules_CheckMaxRounds);
GAMEHOOK_REGISTRY(CSGameRules_CheckWinLimit);

int CReGameApi::GetMajorVersion() {
return REGAMEDLL_API_VERSION_MAJOR;
}
Expand Down
32 changes: 32 additions & 0 deletions regamedll/dlls/API/CAPI_Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,26 @@ typedef IHookChainRegistryClassImpl<void, CBasePlayer> CReGameHookRegistry_CBase
typedef IHookChainClassImpl<void, CBasePlayer, BOOL> CReGameHook_CBasePlayer_RemoveAllItems;
typedef IHookChainRegistryClassImpl<void, CBasePlayer, BOOL> CReGameHookRegistry_CBasePlayer_RemoveAllItems;

// CHalfLifeMultiplay::CheckGameOver hook
typedef IHookChainClassImpl<BOOL, class CHalfLifeMultiplay> CReGameHook_CSGameRules_CheckGameOver;
typedef IHookChainRegistryClassEmptyImpl<BOOL, class CHalfLifeMultiplay> CReGameHookRegistry_CSGameRules_CheckGameOver;

// CHalfLifeMultiplay::CheckTimeLimit hook
typedef IHookChainClassImpl<BOOL, class CHalfLifeMultiplay> CReGameHook_CSGameRules_CheckTimeLimit;
typedef IHookChainRegistryClassEmptyImpl<BOOL, class CHalfLifeMultiplay> CReGameHookRegistry_CSGameRules_CheckTimeLimit;

// CHalfLifeMultiplay::CheckFragLimit hook
typedef IHookChainClassImpl<BOOL, class CHalfLifeMultiplay> CReGameHook_CSGameRules_CheckFragLimit;
typedef IHookChainRegistryClassEmptyImpl<BOOL, class CHalfLifeMultiplay> CReGameHookRegistry_CSGameRules_CheckFragLimit;

// CHalfLifeMultiplay::CheckMaxRounds hook
typedef IHookChainClassImpl<BOOL, class CHalfLifeMultiplay> CReGameHook_CSGameRules_CheckMaxRounds;
typedef IHookChainRegistryClassEmptyImpl<BOOL, class CHalfLifeMultiplay> CReGameHookRegistry_CSGameRules_CheckMaxRounds;

// CHalfLifeMultiplay::CheckWinLimit hook
typedef IHookChainClassImpl<BOOL, class CHalfLifeMultiplay> CReGameHook_CSGameRules_CheckWinLimit;
typedef IHookChainRegistryClassEmptyImpl<BOOL, class CHalfLifeMultiplay> CReGameHookRegistry_CSGameRules_CheckWinLimit;

class CReGameHookchains: public IReGameHookchains {
public:
// CBasePlayer virtual
Expand Down Expand Up @@ -911,6 +931,12 @@ class CReGameHookchains: public IReGameHookchains {
CReGameHookRegistry_CBasePlayer_Observer_Think m_CBasePlayer_Observer_Think;
CReGameHookRegistry_CBasePlayer_RemoveAllItems m_CBasePlayer_RemoveAllItems;

CReGameHookRegistry_CSGameRules_CheckGameOver m_CSGameRules_CheckGameOver;
CReGameHookRegistry_CSGameRules_CheckTimeLimit m_CSGameRules_CheckTimeLimit;
CReGameHookRegistry_CSGameRules_CheckFragLimit m_CSGameRules_CheckFragLimit;
CReGameHookRegistry_CSGameRules_CheckMaxRounds m_CSGameRules_CheckMaxRounds;
CReGameHookRegistry_CSGameRules_CheckWinLimit m_CSGameRules_CheckWinLimit;

public:
virtual IReGameHookRegistry_CBasePlayer_Spawn *CBasePlayer_Spawn();
virtual IReGameHookRegistry_CBasePlayer_Precache *CBasePlayer_Precache();
Expand Down Expand Up @@ -1070,6 +1096,12 @@ class CReGameHookchains: public IReGameHookchains {
virtual IReGameHookRegistry_CBasePlayer_PlayerDeathThink *CBasePlayer_PlayerDeathThink();
virtual IReGameHookRegistry_CBasePlayer_Observer_Think *CBasePlayer_Observer_Think();
virtual IReGameHookRegistry_CBasePlayer_RemoveAllItems *CBasePlayer_RemoveAllItems();

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

extern CReGameHookchains g_ReGameHookchains;
Expand Down
15 changes: 10 additions & 5 deletions regamedll/dlls/gamerules.h
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,11 @@ class CHalfLifeMultiplay: public CGameRules
BOOL TeamStacked_OrigFunc(int newTeam_id, int curTeam_id);
void PlayerGotWeapon_OrigFunc(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon);
void SendDeathMessage_OrigFunc(CBaseEntity *pKiller, CBasePlayer *pVictim, CBasePlayer *pAssister, entvars_t *pevInflictor, const char *killerWeaponName, int iDeathMessageFlags, int iRarityOfKill);
BOOL CheckGameOver_OrigFunc();
BOOL CheckTimeLimit_OrigFunc();
BOOL CheckFragLimit_OrigFunc();
BOOL CheckMaxRounds_OrigFunc();
BOOL CheckWinLimit_OrigFunc();
#endif

public:
Expand Down Expand Up @@ -672,11 +677,11 @@ class CHalfLifeMultiplay: public CGameRules
bool Hostage_NotRescued(float tmDelay);

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

void CheckFreezePeriodExpired();
void CheckRoundTimeExpired();
Expand Down
20 changes: 15 additions & 5 deletions regamedll/dlls/multiplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2612,7 +2612,9 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(Think)()
}
}

bool CHalfLifeMultiplay::CheckGameOver()
LINK_HOOK_CLASS_CUSTOM_CHAIN2(BOOL, CHalfLifeMultiplay, CSGameRules, CheckGameOver)

BOOL EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CheckGameOver)()
{
// someone else quit the game already
if (m_bGameOver)
Expand Down Expand Up @@ -2649,7 +2651,9 @@ bool CHalfLifeMultiplay::CheckGameOver()
return false;
}

bool CHalfLifeMultiplay::CheckTimeLimit()
LINK_HOOK_CLASS_CUSTOM_CHAIN2(BOOL, CHalfLifeMultiplay, CSGameRules, CheckTimeLimit)

BOOL EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CheckTimeLimit)()
{
if (timelimit.value < 0)
{
Expand Down Expand Up @@ -2687,7 +2691,9 @@ bool CHalfLifeMultiplay::CheckTimeLimit()
return false;
}

bool CHalfLifeMultiplay::CheckMaxRounds()
LINK_HOOK_CLASS_CUSTOM_CHAIN2(BOOL, CHalfLifeMultiplay, CSGameRules, CheckMaxRounds)

BOOL EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CheckMaxRounds)()
{
if (m_iMaxRounds != 0 && m_iTotalRoundsPlayed >= m_iMaxRounds)
{
Expand All @@ -2699,7 +2705,9 @@ bool CHalfLifeMultiplay::CheckMaxRounds()
return false;
}

bool CHalfLifeMultiplay::CheckWinLimit()
LINK_HOOK_CLASS_CUSTOM_CHAIN2(BOOL, CHalfLifeMultiplay, CSGameRules, CheckWinLimit)

BOOL EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CheckWinLimit)()
{
// has one team won the specified number of rounds?
if (m_iMaxRoundsWon != 0 && (m_iNumCTWins >= m_iMaxRoundsWon || m_iNumTerroristWins >= m_iMaxRoundsWon))
Expand All @@ -2715,7 +2723,9 @@ bool CHalfLifeMultiplay::CheckWinLimit()
return false;
}

bool CHalfLifeMultiplay::CheckFragLimit()
LINK_HOOK_CLASS_CUSTOM_CHAIN2(BOOL, CHalfLifeMultiplay, CSGameRules, CheckFragLimit)

BOOL EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CheckFragLimit)()
{
#ifdef REGAMEDLL_ADD
int fragsRemaining = 0;
Expand Down
26 changes: 26 additions & 0 deletions regamedll/public/regamedll/regamedll_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,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 @@ -790,6 +810,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