API: Added hook InstallGameRules

This commit is contained in:
s1lentq 2016-05-01 23:22:37 +06:00
parent 982d12176e
commit bba210b6a1
9 changed files with 35 additions and 5 deletions

View File

@ -113,7 +113,9 @@ void CGameRules::__MAKE_VHOOK(RefreshSkillData)()
gSkillData.healthkitCapacity = 15;
}
CGameRules *InstallGameRules()
LINK_HOOK_CHAIN2(CGameRules *, InstallGameRules);
CGameRules *__API_HOOK(InstallGameRules)()
{
SERVER_COMMAND("exec game.cfg\n");
SERVER_EXECUTE();

View File

@ -767,6 +767,7 @@ public:
extern CGameRules *g_pGameRules;
CGameRules *InstallGameRules();
CGameRules *InstallGameRules_();
inline CHalfLifeMultiplay *CSGameRules()
{

View File

@ -178,6 +178,10 @@ typedef IHookChainRegistryClassEmpty<bool, int, ScenarioEventEndRound, float> IR
typedef IHookChain<bool, class CBasePlayer *, int> IReGameHook_CanBuyThis;
typedef IHookChainRegistry<bool, class CBasePlayer *, int> IReGameHookRegistry_CanBuyThis;
// InstallGameRules hook
typedef IHookChain<class CGameRules *> IReGameHook_InstallGameRules;
typedef IHookChainRegistry<class CGameRules *> IReGameHookRegistry_InstallGameRules;
class IReGameHookchains {
public:
virtual ~IReGameHookchains() {}
@ -221,6 +225,7 @@ public:
virtual IReGameHookRegistry_RadiusFlash_TraceLine* RadiusFlash_TraceLine() = 0;
virtual IReGameHookRegistry_RoundEnd* RoundEnd() = 0;
virtual IReGameHookRegistry_CanBuyThis* CanBuyThis() = 0;
virtual IReGameHookRegistry_InstallGameRules* InstallGameRules() = 0;
};

View File

@ -178,6 +178,10 @@ typedef IHookChainRegistryClassEmpty<bool, int, ScenarioEventEndRound, float> IR
typedef IHookChain<bool, class CBasePlayer *, int> IReGameHook_CanBuyThis;
typedef IHookChainRegistry<bool, class CBasePlayer *, int> IReGameHookRegistry_CanBuyThis;
// InstallGameRules hook
typedef IHookChain<class CGameRules *> IReGameHook_InstallGameRules;
typedef IHookChainRegistry<class CGameRules *> IReGameHookRegistry_InstallGameRules;
class IReGameHookchains {
public:
virtual ~IReGameHookchains() {}
@ -221,6 +225,7 @@ public:
virtual IReGameHookRegistry_RadiusFlash_TraceLine* RadiusFlash_TraceLine() = 0;
virtual IReGameHookRegistry_RoundEnd* RoundEnd() = 0;
virtual IReGameHookRegistry_CanBuyThis* CanBuyThis() = 0;
virtual IReGameHookRegistry_InstallGameRules* InstallGameRules() = 0;
};

View File

@ -2076,5 +2076,5 @@ class IReGameData {
public:
virtual ~IReGameData() {}
virtual class CGameRules** GetGameRules() = 0;
virtual class CGameRules* GetGameRules() = 0;
};

View File

@ -89,6 +89,7 @@ IReGameHookRegistry_PlayerBlind* CReGameHookchains::PlayerBlind() { return &m_Pl
IReGameHookRegistry_RadiusFlash_TraceLine* CReGameHookchains::RadiusFlash_TraceLine() { return &m_RadiusFlash_TraceLine; }
IReGameHookRegistry_RoundEnd* CReGameHookchains::RoundEnd() { return &m_RoundEnd; }
IReGameHookRegistry_CanBuyThis* CReGameHookchains::CanBuyThis() { return &m_CanBuyThis; }
IReGameHookRegistry_InstallGameRules* CReGameHookchains::InstallGameRules() { return &m_InstallGameRules; }
int CReGameApi::GetMajorVersion()
{

View File

@ -172,6 +172,10 @@ typedef IHookChainRegistryClassEmptyImpl<bool, class CHalfLifeMultiplay, int, Sc
typedef IHookChainImpl<bool, class CBasePlayer *, int> CReGameHook_CanBuyThis;
typedef IHookChainRegistryImpl<bool, class CBasePlayer *, int> CReGameHookRegistry_CanBuyThis;
// InstallGameRules hook
typedef IHookChainImpl<CGameRules *> CReGameHook_InstallGameRules;
typedef IHookChainRegistryImpl<CGameRules *> CReGameHookRegistry_InstallGameRules;
class CReGameHookchains: public IReGameHookchains {
public:
// CBasePlayer virtual
@ -213,6 +217,7 @@ public:
CReGameHookRegistry_RadiusFlash_TraceLine m_RadiusFlash_TraceLine;
CReGameHookRegistry_RoundEnd m_RoundEnd;
CReGameHookRegistry_CanBuyThis m_CanBuyThis;
CReGameHookRegistry_InstallGameRules m_InstallGameRules;
public:
virtual IReGameHookRegistry_CBasePlayer_Spawn* CBasePlayer_Spawn();
@ -253,6 +258,7 @@ public:
virtual IReGameHookRegistry_RadiusFlash_TraceLine* RadiusFlash_TraceLine();
virtual IReGameHookRegistry_RoundEnd* RoundEnd();
virtual IReGameHookRegistry_CanBuyThis* CanBuyThis();
virtual IReGameHookRegistry_InstallGameRules* InstallGameRules();
};

View File

@ -135,6 +135,6 @@ ICSEntity *EXT_FUNC INDEX_TO_CSENTITY(int iEntityIndex)
return CBASE_TO_CSENTITY(pEntity);
}
CGameRules** EXT_FUNC CReGameData::GetGameRules() {
return &g_pGameRules;
CGameRules* EXT_FUNC CReGameData::GetGameRules() {
return g_pGameRules;
}

View File

@ -79,6 +79,16 @@ extern ICSEntity *INDEX_TO_CSENTITY(int iEntityIndex);
return g_ReGameHookchains.m_##functionName.callChain(functionName##_, __VA_ARGS__);\
}
#define LINK_HOOK_VOID_CHAIN2(functionName)\
void functionName() {\
g_ReGameHookchains.m_##functionName.callChain(functionName##_);\
}
#define LINK_HOOK_CHAIN2(ret, functionName)\
ret functionName() {\
return g_ReGameHookchains.m_##functionName.callChain(functionName##_);\
}
#endif
// Implementation interfaces
@ -2512,7 +2522,7 @@ public:
class CReGameData: public IReGameData {
public:
virtual CGameRules** GetGameRules();
virtual CGameRules* GetGameRules();
};
template <class T>