From 15a9f8336ec360185f74f86cd6f0fad5a3b6ced4 Mon Sep 17 00:00:00 2001 From: dystopm Date: Sun, 26 Nov 2023 01:17:49 -0300 Subject: [PATCH] Tiny API code clean --- regamedll/dlls/API/CSEntity.cpp | 6 +++--- regamedll/dlls/API/CSPlayer.cpp | 2 +- regamedll/public/regamedll/API/CSEntity.h | 8 ++++++++ regamedll/public/regamedll/regamedll_api.h | 8 ++++---- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/regamedll/dlls/API/CSEntity.cpp b/regamedll/dlls/API/CSEntity.cpp index 0e037d29e..00f7badc6 100644 --- a/regamedll/dlls/API/CSEntity.cpp +++ b/regamedll/dlls/API/CSEntity.cpp @@ -30,15 +30,15 @@ void CCSEntity::FireBullets(int iShots, Vector &vecSrc, Vector &vecDirShooting, Vector &vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker) { - m_pContainingEntity->FireBullets(iShots, vecSrc, vecDirShooting, vecSpread, flDistance, iBulletType, iTracerFreq, iDamage, pevAttacker); + BaseEntity()->FireBullets(iShots, vecSrc, vecDirShooting, vecSpread, flDistance, iBulletType, iTracerFreq, iDamage, pevAttacker); } void CCSEntity::FireBuckshots(ULONG cShots, Vector &vecSrc, Vector &vecDirShooting, Vector &vecSpread, float flDistance, int iTracerFreq, int iDamage, entvars_t *pevAttacker) { - m_pContainingEntity->FireBuckshots(cShots, vecSrc, vecDirShooting, vecSpread, flDistance, iTracerFreq, iDamage, pevAttacker); + BaseEntity()->FireBuckshots(cShots, vecSrc, vecDirShooting, vecSpread, flDistance, iTracerFreq, iDamage, pevAttacker); } Vector CCSEntity::FireBullets3(Vector &vecSrc, Vector &vecDirShooting, float vecSpread, float flDistance, int iPenetration, int iBulletType, int iDamage, float flRangeModifier, entvars_t *pevAttacker, bool bPistol, int shared_rand) { - return m_pContainingEntity->FireBullets3(vecSrc, vecDirShooting, vecSpread, flDistance, iPenetration, iBulletType, iDamage, flRangeModifier, pevAttacker, bPistol, shared_rand); + return BaseEntity()->FireBullets3(vecSrc, vecDirShooting, vecSpread, flDistance, iPenetration, iBulletType, iDamage, flRangeModifier, pevAttacker, bPistol, shared_rand); } diff --git a/regamedll/dlls/API/CSPlayer.cpp b/regamedll/dlls/API/CSPlayer.cpp index e55afd082..1011971b5 100644 --- a/regamedll/dlls/API/CSPlayer.cpp +++ b/regamedll/dlls/API/CSPlayer.cpp @@ -266,7 +266,7 @@ EXT_FUNC CBaseEntity *CCSPlayer::GiveNamedItemEx(const char *pszName) EXT_FUNC bool CCSPlayer::IsConnected() const { - return m_pContainingEntity->has_disconnected == false; + return BaseEntity()->has_disconnected == false; } EXT_FUNC void CCSPlayer::SetAnimation(PLAYER_ANIM playerAnim) diff --git a/regamedll/public/regamedll/API/CSEntity.h b/regamedll/public/regamedll/API/CSEntity.h index e2c1922c8..8bf9e0d69 100644 --- a/regamedll/public/regamedll/API/CSEntity.h +++ b/regamedll/public/regamedll/API/CSEntity.h @@ -43,6 +43,8 @@ class CCSEntity virtual void FireBuckshots(ULONG cShots, Vector &vecSrc, Vector &vecDirShooting, Vector &vecSpread, float flDistance, int iTracerFreq, int iDamage, entvars_t *pevAttacker); virtual Vector FireBullets3(Vector &vecSrc, Vector &vecDirShooting, float vecSpread, float flDistance, int iPenetration, int iBulletType, int iDamage, float flRangeModifier, entvars_t *pevAttacker, bool bPistol, int shared_rand); + CBaseEntity *BaseEntity() const; + public: CBaseEntity *m_pContainingEntity; unsigned char m_ucDmgPenetrationLevel; // penetration level of the damage caused by the inflictor @@ -88,6 +90,12 @@ class CCSEntity #endif }; +// Inlines +inline CBaseEntity *CCSEntity::BaseEntity() const +{ + return this->m_pContainingEntity; +} + inline void CBaseEntity::SetDmgPenetrationLevel(int iPenetrationLevel) { #ifdef REGAMEDLL_API diff --git a/regamedll/public/regamedll/regamedll_api.h b/regamedll/public/regamedll/regamedll_api.h index e11914944..95f20dba5 100644 --- a/regamedll/public/regamedll/regamedll_api.h +++ b/regamedll/public/regamedll/regamedll_api.h @@ -588,10 +588,6 @@ typedef IHookChainRegistry IReGameHookRegistry_CSGameRules_TeamS typedef IHookChain IReGameHook_CSGameRules_PlayerGotWeapon; typedef IHookChainRegistry IReGameHookRegistry_CSGameRules_PlayerGotWeapon; -// CHalfLifeMultiplay::SendDeathMessage hook -typedef IHookChain IReGameHook_CSGameRules_SendDeathMessage; -typedef IHookChainRegistry IReGameHookRegistry_CSGameRules_SendDeathMessage; - // CBotManager::OnEvent hook typedef IHookChain IReGameHook_CBotManager_OnEvent; typedef IHookChainRegistry IReGameHookRegistry_CBotManager_OnEvent; @@ -616,6 +612,10 @@ typedef IHookChainRegistryClass IReGameHook_CBasePlayerWeapon_SendWeaponAnim; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayerWeapon_SendWeaponAnim; +// CHalfLifeMultiplay::SendDeathMessage hook +typedef IHookChain IReGameHook_CSGameRules_SendDeathMessage; +typedef IHookChainRegistry IReGameHookRegistry_CSGameRules_SendDeathMessage; + // CBasePlayer::PlayerDeathThink hook typedef IHookChainClass IReGameHook_CBasePlayer_PlayerDeathThink; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_PlayerDeathThink;