From a1e7b9dae598701c21ec7ea8996a369b560a885a Mon Sep 17 00:00:00 2001 From: s1lentq Date: Mon, 20 Jun 2016 14:05:47 +0700 Subject: [PATCH] Added api hook CBasePlayer::DropPlayerItem --- regamedll/dlls/player.cpp | 4 +++- regamedll/dlls/player.h | 1 + regamedll/dlls/util.h | 1 + regamedll/extra/cssdk/dlls/regamedll_api.h | 7 ++++++- regamedll/extra/cssdk/dlls/util.h | 1 + regamedll/public/regamedll/regamedll_api.h | 7 ++++++- regamedll/regamedll/regamedll_api_impl.cpp | 1 + regamedll/regamedll/regamedll_api_impl.h | 6 ++++++ 8 files changed, 25 insertions(+), 3 deletions(-) diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 225a4482..c38ed735 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -7300,7 +7300,9 @@ void CBasePlayer::UpdateStatusBar() } } -void CBasePlayer::DropPlayerItem(const char *pszItemName) +LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, DropPlayerItem, (const char *pszItemName), pszItemName); + +void CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszItemName) { if (!Q_strlen(pszItemName)) { diff --git a/regamedll/dlls/player.h b/regamedll/dlls/player.h index f3a45ff1..b578de89 100644 --- a/regamedll/dlls/player.h +++ b/regamedll/dlls/player.h @@ -493,6 +493,7 @@ public: void StartObserver(Vector vecPosition, Vector vecViewAngle); void HandleSignals(); void DropPlayerItem(const char *pszItemName); + void DropPlayerItem_(const char *pszItemName); BOOL HasPlayerItem(CBasePlayerItem *pCheckItem); BOOL HasNamedPlayerItem(const char *pszItemName); BOOL HasWeapons(); diff --git a/regamedll/dlls/util.h b/regamedll/dlls/util.h index 4fb9badd..0386e09b 100644 --- a/regamedll/dlls/util.h +++ b/regamedll/dlls/util.h @@ -93,6 +93,7 @@ extern globalvars_t *gpGlobals; #define SND_CHANGE_VOL (1<<6) // duplicated in protocol.h change sound vol #define SND_CHANGE_PITCH (1<<7) // duplicated in protocol.h change sound pitch +// All monsters need this data #define DONT_BLEED -1 #define BLOOD_COLOR_RED (byte)247 #define BLOOD_COLOR_YELLOW (byte)195 diff --git a/regamedll/extra/cssdk/dlls/regamedll_api.h b/regamedll/extra/cssdk/dlls/regamedll_api.h index 14106a86..1c76c5e9 100644 --- a/regamedll/extra/cssdk/dlls/regamedll_api.h +++ b/regamedll/extra/cssdk/dlls/regamedll_api.h @@ -32,6 +32,7 @@ #include "interface.h" #include "player.h" #include "gamerules.h" +#include "client.h" #define REGAMEDLL_API_VERSION_MAJOR 3 #define REGAMEDLL_API_VERSION_MINOR 1 @@ -124,7 +125,6 @@ typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBase typedef IVoidHookChainClass IReGameHook_CBasePlayer_Blind; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Blind; - // CBasePlayer::Observer_IsValidTarget hook typedef IHookChainClass IReGameHook_CBasePlayer_Observer_IsValidTarget; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget; @@ -305,6 +305,10 @@ typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_BalanceTeams; 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() {} @@ -380,6 +384,7 @@ public: virtual IReGameHookRegistry_CSGameRules_BalanceTeams* CSGameRules_BalanceTeams() = 0; virtual IReGameHookRegistry_CanBuyThisItem* CanBuyThisItem() = 0; + virtual IReGameHookRegistry_CBasePlayer_DropPlayerItem* CBasePlayer_DropPlayerItem() = 0; }; struct ReGameFuncs_t { diff --git a/regamedll/extra/cssdk/dlls/util.h b/regamedll/extra/cssdk/dlls/util.h index c032d321..f5482ee0 100644 --- a/regamedll/extra/cssdk/dlls/util.h +++ b/regamedll/extra/cssdk/dlls/util.h @@ -57,6 +57,7 @@ extern globalvars_t *gpGlobals; #define SND_CHANGE_VOL (1<<6) // duplicated in protocol.h change sound vol #define SND_CHANGE_PITCH (1<<7) // duplicated in protocol.h change sound pitch +// All monsters need this data #define DONT_BLEED -1 #define BLOOD_COLOR_RED (byte)247 #define BLOOD_COLOR_YELLOW (byte)195 diff --git a/regamedll/public/regamedll/regamedll_api.h b/regamedll/public/regamedll/regamedll_api.h index 14106a86..1c76c5e9 100644 --- a/regamedll/public/regamedll/regamedll_api.h +++ b/regamedll/public/regamedll/regamedll_api.h @@ -32,6 +32,7 @@ #include "interface.h" #include "player.h" #include "gamerules.h" +#include "client.h" #define REGAMEDLL_API_VERSION_MAJOR 3 #define REGAMEDLL_API_VERSION_MINOR 1 @@ -124,7 +125,6 @@ typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBase typedef IVoidHookChainClass IReGameHook_CBasePlayer_Blind; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Blind; - // CBasePlayer::Observer_IsValidTarget hook typedef IHookChainClass IReGameHook_CBasePlayer_Observer_IsValidTarget; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget; @@ -305,6 +305,10 @@ typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_BalanceTeams; 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() {} @@ -380,6 +384,7 @@ public: virtual IReGameHookRegistry_CSGameRules_BalanceTeams* CSGameRules_BalanceTeams() = 0; virtual IReGameHookRegistry_CanBuyThisItem* CanBuyThisItem() = 0; + virtual IReGameHookRegistry_CBasePlayer_DropPlayerItem* CBasePlayer_DropPlayerItem() = 0; }; struct ReGameFuncs_t { diff --git a/regamedll/regamedll/regamedll_api_impl.cpp b/regamedll/regamedll/regamedll_api_impl.cpp index 7b538cbd..b1c0c3d8 100644 --- a/regamedll/regamedll/regamedll_api_impl.cpp +++ b/regamedll/regamedll/regamedll_api_impl.cpp @@ -115,6 +115,7 @@ IReGameHookRegistry_CSGameRules_GoToIntermission* CReGameHookchains::CSGameRules 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() { diff --git a/regamedll/regamedll/regamedll_api_impl.h b/regamedll/regamedll/regamedll_api_impl.h index e55764e0..642159cb 100644 --- a/regamedll/regamedll/regamedll_api_impl.h +++ b/regamedll/regamedll/regamedll_api_impl.h @@ -300,6 +300,10 @@ typedef IVoidHookChainRegistryClassEmptyImpl CReGameHo 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 @@ -374,6 +378,7 @@ public: CReGameHookRegistry_CSGameRules_BalanceTeams m_CSGameRules_BalanceTeams; CReGameHookRegistry_CanBuyThisItem m_CanBuyThisItem; + CReGameHookRegistry_CBasePlayer_DropPlayerItem m_CBasePlayer_DropPlayerItem; public: virtual IReGameHookRegistry_CBasePlayer_Spawn* CBasePlayer_Spawn(); @@ -447,6 +452,7 @@ public: virtual IReGameHookRegistry_CSGameRules_BalanceTeams* CSGameRules_BalanceTeams(); virtual IReGameHookRegistry_CanBuyThisItem* CanBuyThisItem(); + virtual IReGameHookRegistry_CBasePlayer_DropPlayerItem* CBasePlayer_DropPlayerItem(); }; extern CReGameHookchains g_ReGameHookchains;