From bba210b6a1645944f73c473dc7358ab417abdce0 Mon Sep 17 00:00:00 2001 From: s1lentq Date: Sun, 1 May 2016 23:22:37 +0600 Subject: [PATCH] API: Added hook InstallGameRules --- regamedll/dlls/gamerules.cpp | 4 +++- regamedll/dlls/gamerules.h | 1 + regamedll/extra/cssdk/dlls/regamedll_api.h | 5 +++++ regamedll/public/regamedll/regamedll_api.h | 5 +++++ regamedll/public/regamedll/regamedll_interfaces.h | 2 +- regamedll/regamedll/regamedll_api_impl.cpp | 1 + regamedll/regamedll/regamedll_api_impl.h | 6 ++++++ regamedll/regamedll/regamedll_interfaces_impl.cpp | 4 ++-- regamedll/regamedll/regamedll_interfaces_impl.h | 12 +++++++++++- 9 files changed, 35 insertions(+), 5 deletions(-) diff --git a/regamedll/dlls/gamerules.cpp b/regamedll/dlls/gamerules.cpp index 4fb2cb54..599848aa 100644 --- a/regamedll/dlls/gamerules.cpp +++ b/regamedll/dlls/gamerules.cpp @@ -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(); diff --git a/regamedll/dlls/gamerules.h b/regamedll/dlls/gamerules.h index 0cea73cf..856dde76 100644 --- a/regamedll/dlls/gamerules.h +++ b/regamedll/dlls/gamerules.h @@ -767,6 +767,7 @@ public: extern CGameRules *g_pGameRules; CGameRules *InstallGameRules(); +CGameRules *InstallGameRules_(); inline CHalfLifeMultiplay *CSGameRules() { diff --git a/regamedll/extra/cssdk/dlls/regamedll_api.h b/regamedll/extra/cssdk/dlls/regamedll_api.h index 8e7e72a7..dda1fc29 100644 --- a/regamedll/extra/cssdk/dlls/regamedll_api.h +++ b/regamedll/extra/cssdk/dlls/regamedll_api.h @@ -178,6 +178,10 @@ typedef IHookChainRegistryClassEmpty IR typedef IHookChain IReGameHook_CanBuyThis; typedef IHookChainRegistry IReGameHookRegistry_CanBuyThis; +// InstallGameRules hook +typedef IHookChain IReGameHook_InstallGameRules; +typedef IHookChainRegistry 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; }; diff --git a/regamedll/public/regamedll/regamedll_api.h b/regamedll/public/regamedll/regamedll_api.h index 8e7e72a7..dda1fc29 100644 --- a/regamedll/public/regamedll/regamedll_api.h +++ b/regamedll/public/regamedll/regamedll_api.h @@ -178,6 +178,10 @@ typedef IHookChainRegistryClassEmpty IR typedef IHookChain IReGameHook_CanBuyThis; typedef IHookChainRegistry IReGameHookRegistry_CanBuyThis; +// InstallGameRules hook +typedef IHookChain IReGameHook_InstallGameRules; +typedef IHookChainRegistry 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; }; diff --git a/regamedll/public/regamedll/regamedll_interfaces.h b/regamedll/public/regamedll/regamedll_interfaces.h index 8abddd42..f0c1a71e 100644 --- a/regamedll/public/regamedll/regamedll_interfaces.h +++ b/regamedll/public/regamedll/regamedll_interfaces.h @@ -2076,5 +2076,5 @@ class IReGameData { public: virtual ~IReGameData() {} - virtual class CGameRules** GetGameRules() = 0; + virtual class CGameRules* GetGameRules() = 0; }; diff --git a/regamedll/regamedll/regamedll_api_impl.cpp b/regamedll/regamedll/regamedll_api_impl.cpp index 171cb0d5..b3c5271d 100644 --- a/regamedll/regamedll/regamedll_api_impl.cpp +++ b/regamedll/regamedll/regamedll_api_impl.cpp @@ -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() { diff --git a/regamedll/regamedll/regamedll_api_impl.h b/regamedll/regamedll/regamedll_api_impl.h index b267a935..7279c491 100644 --- a/regamedll/regamedll/regamedll_api_impl.h +++ b/regamedll/regamedll/regamedll_api_impl.h @@ -172,6 +172,10 @@ typedef IHookChainRegistryClassEmptyImpl CReGameHook_CanBuyThis; typedef IHookChainRegistryImpl CReGameHookRegistry_CanBuyThis; +// InstallGameRules hook +typedef IHookChainImpl CReGameHook_InstallGameRules; +typedef IHookChainRegistryImpl 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(); }; diff --git a/regamedll/regamedll/regamedll_interfaces_impl.cpp b/regamedll/regamedll/regamedll_interfaces_impl.cpp index ac35c630..c0f3d316 100644 --- a/regamedll/regamedll/regamedll_interfaces_impl.cpp +++ b/regamedll/regamedll/regamedll_interfaces_impl.cpp @@ -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; } diff --git a/regamedll/regamedll/regamedll_interfaces_impl.h b/regamedll/regamedll/regamedll_interfaces_impl.h index 972c3cbc..395a0c5d 100644 --- a/regamedll/regamedll/regamedll_interfaces_impl.h +++ b/regamedll/regamedll/regamedll_interfaces_impl.h @@ -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