From 2d69db123260c77fd6005fab0cc9223f3466ad98 Mon Sep 17 00:00:00 2001 From: s1lentq Date: Mon, 20 Jun 2016 17:50:59 +0700 Subject: [PATCH] Added api hook CWeaponBox::Touch, CArmoury::Touch --- regamedll/dlls/weapons.cpp | 8 ++++-- regamedll/dlls/weapons.h | 3 ++- regamedll/extra/cssdk/dlls/regamedll_api.h | 26 +++++++++++++------ regamedll/public/regamedll/regamedll_api.h | 26 +++++++++++++------ regamedll/regamedll/regamedll_api_impl.cpp | 8 +++--- regamedll/regamedll/regamedll_api_impl.h | 29 +++++++++++++++------- 6 files changed, 69 insertions(+), 31 deletions(-) diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index 3b68260c..b7219dfc 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -1637,9 +1637,11 @@ void CWeaponBox::Kill() UTIL_Remove(this); } +LINK_HOOK_CLASS_VOID_CHAIN(CWeaponBox, Touch, (CBaseEntity *pOther), pOther); + // CWeaponBox - Touch: try to add my contents to the toucher // if the toucher is a player. -void CWeaponBox::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) +void CWeaponBox::__API_VHOOK(Touch)(CBaseEntity *pOther) { if (!(pev->flags & FL_ONGROUND)) { @@ -2143,7 +2145,9 @@ struct ArmouryItemStruct { "weapon_m249", "556NatoBox", 60, MAX_AMMO_556NATOBOX }, // ARMOURY_M249 }; -void CArmoury::ArmouryTouch(CBaseEntity *pOther) +LINK_HOOK_CLASS_VOID_CHAIN(CArmoury, ArmouryTouch, (CBaseEntity *pOther), pOther); + +void CArmoury::__API_HOOK(ArmouryTouch)(CBaseEntity *pOther) { if (!pOther->IsPlayer()) return; diff --git a/regamedll/dlls/weapons.h b/regamedll/dlls/weapons.h index fc785698..bbc2ff98 100644 --- a/regamedll/dlls/weapons.h +++ b/regamedll/dlls/weapons.h @@ -148,6 +148,7 @@ public: public: void EXPORT ArmouryTouch(CBaseEntity *pOther); + void ArmouryTouch_(CBaseEntity *pOther); public: int m_iItem; @@ -472,7 +473,7 @@ public: virtual void SetObjectCollisionBox(); virtual void Touch(CBaseEntity *pOther); -#ifdef HOOK_GAMEDLL +#if defined(REGAMEDLL_API) || defined(HOOK_GAMEDLL) void Spawn_(); void Precache_(); diff --git a/regamedll/extra/cssdk/dlls/regamedll_api.h b/regamedll/extra/cssdk/dlls/regamedll_api.h index 1c76c5e9..e6610db8 100644 --- a/regamedll/extra/cssdk/dlls/regamedll_api.h +++ b/regamedll/extra/cssdk/dlls/regamedll_api.h @@ -157,10 +157,22 @@ typedef IVoidHookChainRegistryClass IReGameHo typedef IVoidHookChainClass IReGameHook_CBasePlayer_SetClientUserInfoName; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_SetClientUserInfoName; +// CBasePlayer::DropPlayerItem hook +typedef IVoidHookChainClass IReGameHook_CBasePlayer_DropPlayerItem; +typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_DropPlayerItem; + // CBaseAnimating::ResetSequenceInfo hook typedef IVoidHookChainClass IReGameHook_CBaseAnimating_ResetSequenceInfo; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo; +// CWeaponBox::Touch hook +typedef IVoidHookChainClass IReGameHook_CWeaponBox_Touch; +typedef IVoidHookChainRegistryClass IReGameHookRegistry_CWeaponBox_Touch; + +// CArmoury::Touch hook +typedef IVoidHookChainClass IReGameHook_CArmoury_Touch; +typedef IVoidHookChainRegistryClass IReGameHookRegistry_CArmoury_Touch; + // GetForceCamera hook typedef IHookChain IReGameHook_GetForceCamera; typedef IHookChainRegistry IReGameHookRegistry_GetForceCamera; @@ -181,6 +193,10 @@ typedef IHookChainRegistry IReGameHookR typedef IHookChain IReGameHook_CanBuyThis; typedef IHookChainRegistry IReGameHookRegistry_CanBuyThis; +// CanBuyThisItem hook +typedef IHookChain IReGameHook_CanBuyThisItem; +typedef IHookChainRegistry IReGameHookRegistry_CanBuyThisItem; + // InstallGameRules hook typedef IHookChain IReGameHook_InstallGameRules; typedef IHookChainRegistry IReGameHookRegistry_InstallGameRules; @@ -301,14 +317,6 @@ typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_GoToIntermissio typedef IVoidHookChain<> IReGameHook_CSGameRules_BalanceTeams; typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_BalanceTeams; -// CanBuyThisItem hook -typedef IHookChain IReGameHook_CanBuyThisItem; -typedef IHookChainRegistry IReGameHookRegistry_CanBuyThisItem; - -// CBasePlayer::DropPlayerItem hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_DropPlayerItem; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_DropPlayerItem; - class IReGameHookchains { public: virtual ~IReGameHookchains() {} @@ -385,6 +393,8 @@ public: virtual IReGameHookRegistry_CanBuyThisItem* CanBuyThisItem() = 0; virtual IReGameHookRegistry_CBasePlayer_DropPlayerItem* CBasePlayer_DropPlayerItem() = 0; + virtual IReGameHookRegistry_CWeaponBox_Touch* CWeaponBox_Touch() = 0; + virtual IReGameHookRegistry_CArmoury_Touch* CArmoury_Touch() = 0; }; struct ReGameFuncs_t { diff --git a/regamedll/public/regamedll/regamedll_api.h b/regamedll/public/regamedll/regamedll_api.h index 1c76c5e9..e6610db8 100644 --- a/regamedll/public/regamedll/regamedll_api.h +++ b/regamedll/public/regamedll/regamedll_api.h @@ -157,10 +157,22 @@ typedef IVoidHookChainRegistryClass IReGameHo typedef IVoidHookChainClass IReGameHook_CBasePlayer_SetClientUserInfoName; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_SetClientUserInfoName; +// CBasePlayer::DropPlayerItem hook +typedef IVoidHookChainClass IReGameHook_CBasePlayer_DropPlayerItem; +typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_DropPlayerItem; + // CBaseAnimating::ResetSequenceInfo hook typedef IVoidHookChainClass IReGameHook_CBaseAnimating_ResetSequenceInfo; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo; +// CWeaponBox::Touch hook +typedef IVoidHookChainClass IReGameHook_CWeaponBox_Touch; +typedef IVoidHookChainRegistryClass IReGameHookRegistry_CWeaponBox_Touch; + +// CArmoury::Touch hook +typedef IVoidHookChainClass IReGameHook_CArmoury_Touch; +typedef IVoidHookChainRegistryClass IReGameHookRegistry_CArmoury_Touch; + // GetForceCamera hook typedef IHookChain IReGameHook_GetForceCamera; typedef IHookChainRegistry IReGameHookRegistry_GetForceCamera; @@ -181,6 +193,10 @@ typedef IHookChainRegistry IReGameHookR typedef IHookChain IReGameHook_CanBuyThis; typedef IHookChainRegistry IReGameHookRegistry_CanBuyThis; +// CanBuyThisItem hook +typedef IHookChain IReGameHook_CanBuyThisItem; +typedef IHookChainRegistry IReGameHookRegistry_CanBuyThisItem; + // InstallGameRules hook typedef IHookChain IReGameHook_InstallGameRules; typedef IHookChainRegistry IReGameHookRegistry_InstallGameRules; @@ -301,14 +317,6 @@ typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_GoToIntermissio typedef IVoidHookChain<> IReGameHook_CSGameRules_BalanceTeams; typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_BalanceTeams; -// CanBuyThisItem hook -typedef IHookChain IReGameHook_CanBuyThisItem; -typedef IHookChainRegistry IReGameHookRegistry_CanBuyThisItem; - -// CBasePlayer::DropPlayerItem hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_DropPlayerItem; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_DropPlayerItem; - class IReGameHookchains { public: virtual ~IReGameHookchains() {} @@ -385,6 +393,8 @@ public: virtual IReGameHookRegistry_CanBuyThisItem* CanBuyThisItem() = 0; virtual IReGameHookRegistry_CBasePlayer_DropPlayerItem* CBasePlayer_DropPlayerItem() = 0; + virtual IReGameHookRegistry_CWeaponBox_Touch* CWeaponBox_Touch() = 0; + virtual IReGameHookRegistry_CArmoury_Touch* CArmoury_Touch() = 0; }; struct ReGameFuncs_t { diff --git a/regamedll/regamedll/regamedll_api_impl.cpp b/regamedll/regamedll/regamedll_api_impl.cpp index b1c0c3d8..6840f367 100644 --- a/regamedll/regamedll/regamedll_api_impl.cpp +++ b/regamedll/regamedll/regamedll_api_impl.cpp @@ -75,13 +75,18 @@ IReGameHookRegistry_CBasePlayer_AddAccount* CReGameHookchains::CBasePlayer_AddAc IReGameHookRegistry_CBasePlayer_GiveShield* CReGameHookchains::CBasePlayer_GiveShield() { return &m_CBasePlayer_GiveShield; } IReGameHookRegistry_CBasePlayer_SetClientUserInfoModel* CReGameHookchains::CBasePlayer_SetClientUserInfoModel() { return &m_CBasePlayer_SetClientUserInfoModel; } IReGameHookRegistry_CBasePlayer_SetClientUserInfoName* CReGameHookchains::CBasePlayer_SetClientUserInfoName() { return &m_CBasePlayer_SetClientUserInfoName; } +IReGameHookRegistry_CBasePlayer_DropPlayerItem* CReGameHookchains::CBasePlayer_DropPlayerItem() { return &m_CBasePlayer_DropPlayerItem; } IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo* CReGameHookchains::CBaseAnimating_ResetSequenceInfo() { return &m_CBaseAnimating_ResetSequenceInfo; } +IReGameHookRegistry_CWeaponBox_Touch* CReGameHookchains::CWeaponBox_Touch() { return &m_CWeaponBox_Touch; } +IReGameHookRegistry_CArmoury_Touch* CReGameHookchains::CArmoury_Touch() { return &m_CArmoury_ArmouryTouch; } + IReGameHookRegistry_GetForceCamera* CReGameHookchains::GetForceCamera() { return &m_GetForceCamera; } IReGameHookRegistry_PlayerBlind* CReGameHookchains::PlayerBlind() { return &m_PlayerBlind; } 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_CanBuyThisItem* CReGameHookchains::CanBuyThisItem() { return &m_CanBuyThisItem; } IReGameHookRegistry_InstallGameRules* CReGameHookchains::InstallGameRules() { return &m_InstallGameRules; } IReGameHookRegistry_PM_Init* CReGameHookchains::PM_Init() { return &m_PM_Init; } IReGameHookRegistry_PM_Move* CReGameHookchains::PM_Move() { return &m_PM_Move; } @@ -114,9 +119,6 @@ IReGameHookRegistry_CSGameRules_ChangeLevel* CReGameHookchains::CSGameRules_Chan IReGameHookRegistry_CSGameRules_GoToIntermission* CReGameHookchains::CSGameRules_GoToIntermission() { return &m_CSGameRules_GoToIntermission; } IReGameHookRegistry_CSGameRules_BalanceTeams* CReGameHookchains::CSGameRules_BalanceTeams() { return &m_CSGameRules_BalanceTeams; } -IReGameHookRegistry_CanBuyThisItem* CReGameHookchains::CanBuyThisItem() { return &m_CanBuyThisItem; } -IReGameHookRegistry_CBasePlayer_DropPlayerItem* CReGameHookchains::CBasePlayer_DropPlayerItem() { return &m_CBasePlayer_DropPlayerItem; } - int CReGameApi::GetMajorVersion() { return REGAMEDLL_API_VERSION_MAJOR; diff --git a/regamedll/regamedll/regamedll_api_impl.h b/regamedll/regamedll/regamedll_api_impl.h index 642159cb..727a046c 100644 --- a/regamedll/regamedll/regamedll_api_impl.h +++ b/regamedll/regamedll/regamedll_api_impl.h @@ -119,7 +119,6 @@ typedef IVoidHookChainRegistryClassImpl CReGameHookRegistry_CBasePl typedef IVoidHookChainClassImpl CReGameHook_CBasePlayer_Blind; typedef IVoidHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_Blind; - // CBasePlayer::Observer_IsValidTarget hook typedef IHookChainClassImpl CReGameHook_CBasePlayer_Observer_IsValidTarget; typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_Observer_IsValidTarget; @@ -152,10 +151,22 @@ typedef IVoidHookChainRegistryClassImpl CReGameHook typedef IVoidHookChainClassImpl CReGameHook_CBasePlayer_SetClientUserInfoName; typedef IVoidHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_SetClientUserInfoName; +// CBasePlayer::DropPlayerItem hook +typedef IVoidHookChainClassImpl CReGameHook_CBasePlayer_DropPlayerItem; +typedef IVoidHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_DropPlayerItem; + // CBaseAnimating::ResetSequenceInfo hook typedef IVoidHookChainClassImpl CReGameHook_CBaseAnimating_ResetSequenceInfo; typedef IVoidHookChainRegistryClassImpl CReGameHookRegistry_CBaseAnimating_ResetSequenceInfo; +// CWeaponBox::Touch hook +typedef IVoidHookChainClassImpl CReGameHook_CWeaponBox_Touch; +typedef IVoidHookChainRegistryClassImpl CReGameHookRegistry_CWeaponBox_Touch; + +// CArmoury::Touch hook +typedef IVoidHookChainClassImpl CReGameHook_CArmoury_Touch; +typedef IVoidHookChainRegistryClassImpl CReGameHookRegistry_CArmoury_Touch; + // GetForceCamera hook typedef IHookChainImpl CReGameHook_GetForceCamera; typedef IHookChainRegistryImpl CReGameHookRegistry_GetForceCamera; @@ -176,6 +187,10 @@ typedef IHookChainRegistryClassEmptyImpl CReGameHook_CanBuyThis; typedef IHookChainRegistryImpl CReGameHookRegistry_CanBuyThis; +// CanBuyThisItem hook +typedef IHookChainImpl CReGameHook_CanBuyThisItem; +typedef IHookChainRegistryImpl CReGameHookRegistry_CanBuyThisItem; + // InstallGameRules hook typedef IHookChainImpl CReGameHook_InstallGameRules; typedef IHookChainRegistryImpl CReGameHookRegistry_InstallGameRules; @@ -296,14 +311,6 @@ typedef IVoidHookChainRegistryClassEmptyImpl CReGameHo typedef IVoidHookChainClassImpl CReGameHook_CSGameRules_BalanceTeams; typedef IVoidHookChainRegistryClassEmptyImpl CReGameHookRegistry_CSGameRules_BalanceTeams; -// CanBuyThisItem hook -typedef IHookChainImpl CReGameHook_CanBuyThisItem; -typedef IHookChainRegistryImpl CReGameHookRegistry_CanBuyThisItem; - -// CBasePlayer::DropPlayerItem hook -typedef IVoidHookChainClassImpl CReGameHook_CBasePlayer_DropPlayerItem; -typedef IVoidHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_DropPlayerItem; - class CReGameHookchains: public IReGameHookchains { public: // CBasePlayer virtual @@ -379,6 +386,8 @@ public: CReGameHookRegistry_CanBuyThisItem m_CanBuyThisItem; CReGameHookRegistry_CBasePlayer_DropPlayerItem m_CBasePlayer_DropPlayerItem; + CReGameHookRegistry_CWeaponBox_Touch m_CWeaponBox_Touch; + CReGameHookRegistry_CArmoury_Touch m_CArmoury_ArmouryTouch; public: virtual IReGameHookRegistry_CBasePlayer_Spawn* CBasePlayer_Spawn(); @@ -453,6 +462,8 @@ public: virtual IReGameHookRegistry_CanBuyThisItem* CanBuyThisItem(); virtual IReGameHookRegistry_CBasePlayer_DropPlayerItem* CBasePlayer_DropPlayerItem(); + virtual IReGameHookRegistry_CWeaponBox_Touch* CWeaponBox_Touch(); + virtual IReGameHookRegistry_CArmoury_Touch* CArmoury_Touch(); }; extern CReGameHookchains g_ReGameHookchains;