From 34e56f61f297a1ac547f2689a4708bf7474c6c21 Mon Sep 17 00:00:00 2001 From: s1lentq Date: Tue, 12 Dec 2023 18:59:13 +0700 Subject: [PATCH] Minor refactoring API functions --- regamedll/dlls/cbase.cpp | 4 ++++ regamedll/dlls/cbase.h | 15 +++++++++++- regamedll/dlls/player.cpp | 4 ---- regamedll/dlls/player.h | 3 --- regamedll/public/regamedll/API/CSEntity.h | 28 ++++------------------- 5 files changed, 22 insertions(+), 32 deletions(-) diff --git a/regamedll/dlls/cbase.cpp b/regamedll/dlls/cbase.cpp index 77a49944..1d706299 100644 --- a/regamedll/dlls/cbase.cpp +++ b/regamedll/dlls/cbase.cpp @@ -63,6 +63,10 @@ NEW_DLL_FUNCTIONS gNewDLLFunctions = nullptr }; +#ifndef REGAMEDLL_API +entvars_t *g_pevLastInflictor = nullptr; +#endif + CMemoryPool hashItemMemPool(sizeof(hash_item_t), 64); int CaseInsensitiveHash(const char *string, int iBounds) diff --git a/regamedll/dlls/cbase.h b/regamedll/dlls/cbase.h index e6830142..8149356f 100644 --- a/regamedll/dlls/cbase.h +++ b/regamedll/dlls/cbase.h @@ -341,7 +341,20 @@ inline CCSEntity *CBaseEntity::CSEntity() const { return m_pEntity; } -#endif +#else // !REGAMEDLL_API + +extern entvars_t *g_pevLastInflictor; +inline void CBaseEntity::SetDmgPenetrationLevel(int iPenetrationLevel) {} +inline void CBaseEntity::ResetDmgPenetrationLevel() {} +inline int CBaseEntity::GetDmgPenetrationLevel() const { return 0; } +inline entvars_t *CBaseEntity::GetLastInflictor() { return g_pevLastInflictor; } +inline void CBaseEntity::KilledInflicted(entvars_t *pevInflictor, entvars_t *pevAttacker, int iGib) +{ + g_pevLastInflictor = pevInflictor; + Killed(pevAttacker, iGib); + g_pevLastInflictor = nullptr; +} +#endif // !REGAMEDLL_API class CPointEntity: public CBaseEntity { public: diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 3fdad71b..e2e185a6 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -82,10 +82,6 @@ const char *CDeadHEV::m_szPoses[] = "deadtable" }; -#ifndef REGAMEDLL_API -entvars_t *g_pevLastInflictor; -#endif - LINK_ENTITY_TO_CLASS(player, CBasePlayer, CCSPlayer) #ifdef REGAMEDLL_API diff --git a/regamedll/dlls/player.h b/regamedll/dlls/player.h index bd3bf33e..8221bd48 100644 --- a/regamedll/dlls/player.h +++ b/regamedll/dlls/player.h @@ -976,9 +976,6 @@ inline CBasePlayer *UTIL_PlayerByIndexSafe(int playerIndex) return pPlayer; } -#ifndef REGAMEDLL_API -extern entvars_t *g_pevLastInflictor; -#endif extern CBaseEntity *g_pLastSpawn; extern CBaseEntity *g_pLastCTSpawn; extern CBaseEntity *g_pLastTerroristSpawn; diff --git a/regamedll/public/regamedll/API/CSEntity.h b/regamedll/public/regamedll/API/CSEntity.h index 1c26ba58..4d73075e 100644 --- a/regamedll/public/regamedll/API/CSEntity.h +++ b/regamedll/public/regamedll/API/CSEntity.h @@ -98,54 +98,34 @@ inline CBaseEntity *CCSEntity::BaseEntity() const return this->m_pContainingEntity; } +#ifdef REGAMEDLL_API inline void CBaseEntity::SetDmgPenetrationLevel(int iPenetrationLevel) { -#ifdef REGAMEDLL_API CSEntity()->m_ucDmgPenetrationLevel = iPenetrationLevel; -#endif } inline void CBaseEntity::ResetDmgPenetrationLevel() { -#ifdef REGAMEDLL_API CSEntity()->m_ucDmgPenetrationLevel = 0; -#endif } inline int CBaseEntity::GetDmgPenetrationLevel() const { -#ifdef REGAMEDLL_API return CSEntity()->m_ucDmgPenetrationLevel; -#else - return 0; -#endif } -inline void CBaseEntity::KilledInflicted(entvars_t* pevInflictor, entvars_t *pevAttacker, int iGib) +inline void CBaseEntity::KilledInflicted(entvars_t *pevInflictor, entvars_t *pevAttacker, int iGib) { -#ifdef REGAMEDLL_API CSEntity()->m_pevLastInflictor = pevInflictor; -#else - g_pevLastInflictor = pevInflictor; -#endif - Killed(pevAttacker, iGib); - -#ifdef REGAMEDLL_API CSEntity()->m_pevLastInflictor = nullptr; -#else - g_pevLastInflictor = nullptr; -#endif } -inline entvars_t* CBaseEntity::GetLastInflictor() +inline entvars_t *CBaseEntity::GetLastInflictor() { -#ifdef REGAMEDLL_API return CSEntity()->m_pevLastInflictor; -#else - return g_pevLastInflictor; -#endif } +#endif class CCSDelay: public CCSEntity {