From 1745de6acae67d9226d573afb0bc76c726dc2a76 Mon Sep 17 00:00:00 2001 From: s1lent Date: Thu, 6 Jun 2019 02:57:40 +0700 Subject: [PATCH] Added API hook CBasePlayer::HintMessageEx Bump minor version API --- gradle.properties | 2 +- regamedll/dlls/API/CAPI_Impl.cpp | 1 + regamedll/dlls/API/CAPI_Impl.h | 9 ++++++++- regamedll/dlls/API/CSPlayer.cpp | 5 +++++ regamedll/dlls/player.cpp | 11 +++++++++-- regamedll/dlls/player.h | 2 ++ regamedll/public/regamedll/API/CSPlayer.h | 1 + regamedll/public/regamedll/regamedll_api.h | 7 ++++++- 8 files changed, 33 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index a2937989..704a66e3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ majorVersion=5 -minorVersion=7 +minorVersion=9 maintenanceVersion=0 diff --git a/regamedll/dlls/API/CAPI_Impl.cpp b/regamedll/dlls/API/CAPI_Impl.cpp index 7d67e0f9..0a464b06 100644 --- a/regamedll/dlls/API/CAPI_Impl.cpp +++ b/regamedll/dlls/API/CAPI_Impl.cpp @@ -160,6 +160,7 @@ GAMEHOOK_REGISTRY(PlantBomb); GAMEHOOK_REGISTRY(CBasePlayer_SetSpawnProtection); GAMEHOOK_REGISTRY(CBasePlayer_RemoveSpawnProtection); GAMEHOOK_REGISTRY(IsPenetrableEntity); +GAMEHOOK_REGISTRY(CBasePlayer_HintMessageEx); int CReGameApi::GetMajorVersion() { return REGAMEDLL_API_VERSION_MAJOR; diff --git a/regamedll/dlls/API/CAPI_Impl.h b/regamedll/dlls/API/CAPI_Impl.h index 3afe1181..a4f44804 100644 --- a/regamedll/dlls/API/CAPI_Impl.h +++ b/regamedll/dlls/API/CAPI_Impl.h @@ -533,6 +533,10 @@ typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBase typedef IHookChainImpl CReGameHook_IsPenetrableEntity; typedef IHookChainRegistryImpl CReGameHookRegistry_IsPenetrableEntity; +// CBasePlayer::HintMessage hook +typedef IHookChainClassImpl CReGameHook_CBasePlayer_HintMessageEx; +typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_HintMessageEx; + class CReGameHookchains: public IReGameHookchains { public: // CBasePlayer virtual @@ -640,6 +644,8 @@ public: CReGameHookRegistry_CBasePlayer_SetSpawnProtection m_CBasePlayer_SetSpawnProtection; CReGameHookRegistry_CBasePlayer_RemoveSpawnProtection m_CBasePlayer_RemoveSpawnProtection; CReGameHookRegistry_IsPenetrableEntity m_IsPenetrableEntity; + CReGameHookRegistry_CBasePlayer_HintMessageEx m_CBasePlayer_HintMessageEx; + public: virtual IReGameHookRegistry_CBasePlayer_Spawn *CBasePlayer_Spawn(); virtual IReGameHookRegistry_CBasePlayer_Precache *CBasePlayer_Precache(); @@ -700,7 +706,7 @@ public: virtual IReGameHookRegistry_BuyGunAmmo *BuyGunAmmo(); virtual IReGameHookRegistry_BuyWeaponByWeaponID *BuyWeaponByWeaponID(); virtual IReGameHookRegistry_InternalCommand *InternalCommand(); - + virtual IReGameHookRegistry_CSGameRules_FShouldSwitchWeapon *CSGameRules_FShouldSwitchWeapon(); virtual IReGameHookRegistry_CSGameRules_GetNextBestWeapon *CSGameRules_GetNextBestWeapon(); virtual IReGameHookRegistry_CSGameRules_FlPlayerFallDamage *CSGameRules_FlPlayerFallDamage(); @@ -745,6 +751,7 @@ public: virtual IReGameHookRegistry_CBasePlayer_SetSpawnProtection *CBasePlayer_SetSpawnProtection(); virtual IReGameHookRegistry_CBasePlayer_RemoveSpawnProtection *CBasePlayer_RemoveSpawnProtection(); virtual IReGameHookRegistry_IsPenetrableEntity *IsPenetrableEntity(); + virtual IReGameHookRegistry_CBasePlayer_HintMessageEx *CBasePlayer_HintMessageEx(); }; extern CReGameHookchains g_ReGameHookchains; diff --git a/regamedll/dlls/API/CSPlayer.cpp b/regamedll/dlls/API/CSPlayer.cpp index 84533b7f..b33d54fc 100644 --- a/regamedll/dlls/API/CSPlayer.cpp +++ b/regamedll/dlls/API/CSPlayer.cpp @@ -499,3 +499,8 @@ EXT_FUNC void CCSPlayer::RemoveSpawnProtection() { BasePlayer()->RemoveSpawnProtection(); } + +EXT_FUNC bool CCSPlayer::HintMessageEx(const char *pMessage, float duration, bool bDisplayIfPlayerDead, bool bOverride) +{ + return BasePlayer()->HintMessageEx(pMessage, duration, bDisplayIfPlayerDead, bOverride); +} diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 6759f031..b406a230 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -7184,17 +7184,24 @@ void EXT_FUNC CBasePlayer::__API_HOOK(ResetMaxSpeed)() pev->maxspeed = speed; } -bool CBasePlayer::HintMessage(const char *pMessage, BOOL bDisplayIfPlayerDead, BOOL bOverride) +LINK_HOOK_CLASS_CHAIN(bool, CBasePlayer, HintMessageEx, (const char *pMessage, float duration, bool bDisplayIfPlayerDead, bool bOverride), pMessage, duration, bDisplayIfPlayerDead, bOverride) + +bool EXT_FUNC CBasePlayer::__API_HOOK(HintMessageEx)(const char *pMessage, float duration, bool bDisplayIfPlayerDead, bool bOverride) { if (!bDisplayIfPlayerDead && !IsAlive()) return false; if (bOverride || m_bShowHints) - return m_hintMessageQueue.AddMessage(pMessage, 6.0, true, nullptr); + return m_hintMessageQueue.AddMessage(pMessage, duration, true, nullptr); return true; } +bool EXT_FUNC CBasePlayer::HintMessage(const char *pMessage, BOOL bDisplayIfPlayerDead, BOOL bOverride) +{ + return HintMessageEx(pMessage, 6.0f, bDisplayIfPlayerDead, bOverride); +} + Vector CBasePlayer::GetAutoaimVector(float flDelta) { Vector vecSrc; diff --git a/regamedll/dlls/player.h b/regamedll/dlls/player.h index db58a38a..e756c41b 100644 --- a/regamedll/dlls/player.h +++ b/regamedll/dlls/player.h @@ -421,6 +421,7 @@ public: bool CanSwitchTeam_OrigFunc(TeamName teamToSwap); void SetSpawnProtection_OrigFunc(float flProtectionTime); void RemoveSpawnProtection_OrigFunc(); + bool HintMessageEx_OrigFunc(const char *pMessage, float duration = 6.0f, bool bDisplayIfPlayerDead = false, bool bOverride = false); CCSPlayer *CSPlayer() const; #endif // REGAMEDLL_API @@ -510,6 +511,7 @@ public: CBaseEntity *GiveNamedItemEx(const char *pszName); void EnableControl(BOOL fControl); bool HintMessage(const char *pMessage, BOOL bDisplayIfPlayerDead = FALSE, BOOL bOverride = FALSE); + bool HintMessageEx(const char *pMessage, float duration = 6.0f, bool bDisplayIfPlayerDead = false, bool bOverride = false); void SendAmmoUpdate(); void SendFOV(int fov); void WaterMove(); diff --git a/regamedll/public/regamedll/API/CSPlayer.h b/regamedll/public/regamedll/API/CSPlayer.h index 96d425e3..debe0bc7 100644 --- a/regamedll/public/regamedll/API/CSPlayer.h +++ b/regamedll/public/regamedll/API/CSPlayer.h @@ -82,6 +82,7 @@ public: virtual bool RemovePlayerItemEx(const char* pszItemName, bool bRemoveAmmo); virtual void SetSpawnProtection(float flProtectionTime); virtual void RemoveSpawnProtection(); + virtual bool HintMessageEx(const char *pMessage, float duration = 6.0f, bool bDisplayIfPlayerDead = false, bool bOverride = false); CBasePlayer *BasePlayer() const; diff --git a/regamedll/public/regamedll/regamedll_api.h b/regamedll/public/regamedll/regamedll_api.h index 224fa1e8..cd258ab3 100644 --- a/regamedll/public/regamedll/regamedll_api.h +++ b/regamedll/public/regamedll/regamedll_api.h @@ -38,7 +38,7 @@ #include #define REGAMEDLL_API_VERSION_MAJOR 5 -#define REGAMEDLL_API_VERSION_MINOR 8 +#define REGAMEDLL_API_VERSION_MINOR 9 // CBasePlayer::Spawn hook typedef IHookChainClass IReGameHook_CBasePlayer_Spawn; @@ -436,6 +436,10 @@ typedef IHookChainRegistryClass IReGameHookRegistry_CBa typedef IHookChain IReGameHook_IsPenetrableEntity; typedef IHookChainRegistry IReGameHookRegistry_IsPenetrableEntity; +// CBasePlayer::HintMessageEx hook +typedef IHookChainClass IReGameHook_CBasePlayer_HintMessageEx; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_HintMessageEx; + class IReGameHookchains { public: virtual ~IReGameHookchains() {} @@ -544,6 +548,7 @@ public: virtual IReGameHookRegistry_CBasePlayer_RemoveSpawnProtection *CBasePlayer_RemoveSpawnProtection() = 0; virtual IReGameHookRegistry_CBasePlayer_SetSpawnProtection *CBasePlayer_SetSpawnProtection() = 0; virtual IReGameHookRegistry_IsPenetrableEntity *IsPenetrableEntity() = 0; + virtual IReGameHookRegistry_CBasePlayer_HintMessageEx *CBasePlayer_HintMessageEx() = 0; }; struct ReGameFuncs_t {