From 8a8a28a024432cbde29029f7c27b121d239917a6 Mon Sep 17 00:00:00 2001 From: Jonathan <30329245+CookStar@users.noreply.github.com> Date: Wed, 23 Sep 2020 10:16:11 +0900 Subject: [PATCH 1/4] Fix #350, Updated CTakeDamageInfo wrapper for CS:GO. --- src/core/modules/entities/entities.h | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) mode change 100644 => 100755 src/core/modules/entities/entities.h diff --git a/src/core/modules/entities/entities.h b/src/core/modules/entities/entities.h old mode 100644 new mode 100755 index 296caaf86..bab6f93bd --- a/src/core/modules/entities/entities.h +++ b/src/core/modules/entities/entities.h @@ -48,6 +48,12 @@ #include "game/server/entityoutput.h" +//----------------------------------------------------------------------------- +// External variables. +//----------------------------------------------------------------------------- +extern CGlobalVars *gpGlobals; + + //----------------------------------------------------------------------------- // IServerEntity extension class. //----------------------------------------------------------------------------- @@ -96,12 +102,40 @@ class TakeDamageInfoBaseWrapper: public CTakeDamageInfo unsigned int get_attacker() { +#if defined(ENGINE_CSGO) + return ExcIndexFromBaseHandle(m_CSGOAttacker.m_hHndl); +#else return ExcIndexFromBaseHandle(m_hAttacker); +#endif } void set_attacker(unsigned int uiAttacker) { +#if defined(ENGINE_CSGO) + m_CSGOAttacker.m_bNeedInit = false; + m_CSGOAttacker.m_hHndl = ExcBaseHandleFromIndex(uiAttacker); + m_CSGOAttacker.m_bIsWorld = true; + + if (uiAttacker > WORLD_ENTITY_INDEX && + uiAttacker <= (unsigned int) gpGlobals->maxClients) + { + m_CSGOAttacker.m_bIsWorld = false; + m_CSGOAttacker.m_bIsPlayer = true; + m_CSGOAttacker.m_iClientIndex = (int)uiAttacker; + + IPlayerInfo* pPlayerInfo; + if (PlayerInfoFromIndex(uiAttacker, pPlayerInfo)) + { + m_CSGOAttacker.m_iUserId = pPlayerInfo->GetUserID(); + + int iTeamIndex = pPlayerInfo->GetTeamIndex(); + m_CSGOAttacker.m_iTeamChecked = iTeamIndex; + m_CSGOAttacker.m_iTeamNum = iTeamIndex; + } + } +#else m_hAttacker = ExcBaseHandleFromIndex(uiAttacker); +#endif } unsigned int get_weapon() From 58b10f016f52fa3e386a08e540d0c30ef8d8a094 Mon Sep 17 00:00:00 2001 From: Jonathan <30329245+CookStar@users.noreply.github.com> Date: Wed, 23 Sep 2020 19:50:08 +0900 Subject: [PATCH 2/4] Changed get_attacker to return m_CSGOAttacker.m_iClientIndex. --- src/core/modules/entities/entities.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/modules/entities/entities.h b/src/core/modules/entities/entities.h index bab6f93bd..5f1311504 100755 --- a/src/core/modules/entities/entities.h +++ b/src/core/modules/entities/entities.h @@ -103,7 +103,7 @@ class TakeDamageInfoBaseWrapper: public CTakeDamageInfo unsigned int get_attacker() { #if defined(ENGINE_CSGO) - return ExcIndexFromBaseHandle(m_CSGOAttacker.m_hHndl); + return (unsigned int)m_CSGOAttacker.m_iClientIndex; #else return ExcIndexFromBaseHandle(m_hAttacker); #endif @@ -112,8 +112,8 @@ class TakeDamageInfoBaseWrapper: public CTakeDamageInfo void set_attacker(unsigned int uiAttacker) { #if defined(ENGINE_CSGO) - m_CSGOAttacker.m_bNeedInit = false; m_CSGOAttacker.m_hHndl = ExcBaseHandleFromIndex(uiAttacker); + m_CSGOAttacker.m_bNeedInit = false; m_CSGOAttacker.m_bIsWorld = true; if (uiAttacker > WORLD_ENTITY_INDEX && From 817d279d2d888daf9790adf2448dda821b4ca784 Mon Sep 17 00:00:00 2001 From: Jonathan <30329245+CookStar@users.noreply.github.com> Date: Thu, 24 Sep 2020 14:06:18 +0900 Subject: [PATCH 3/4] Updated m_CSGOAttacker.m_bIsWorld. --- src/core/modules/entities/entities.h | 29 ++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/core/modules/entities/entities.h b/src/core/modules/entities/entities.h index 5f1311504..68d65b91d 100755 --- a/src/core/modules/entities/entities.h +++ b/src/core/modules/entities/entities.h @@ -114,24 +114,29 @@ class TakeDamageInfoBaseWrapper: public CTakeDamageInfo #if defined(ENGINE_CSGO) m_CSGOAttacker.m_hHndl = ExcBaseHandleFromIndex(uiAttacker); m_CSGOAttacker.m_bNeedInit = false; - m_CSGOAttacker.m_bIsWorld = true; + m_CSGOAttacker.m_bIsWorld = false; + m_CSGOAttacker.m_iClientIndex = (int)uiAttacker; - if (uiAttacker > WORLD_ENTITY_INDEX && - uiAttacker <= (unsigned int) gpGlobals->maxClients) + IPlayerInfo* pPlayerInfo; + if (PlayerInfoFromIndex(uiAttacker, pPlayerInfo)) { - m_CSGOAttacker.m_bIsWorld = false; m_CSGOAttacker.m_bIsPlayer = true; - m_CSGOAttacker.m_iClientIndex = (int)uiAttacker; - IPlayerInfo* pPlayerInfo; - if (PlayerInfoFromIndex(uiAttacker, pPlayerInfo)) + int iTeamIndex = pPlayerInfo->GetTeamIndex(); + m_CSGOAttacker.m_iTeamChecked = iTeamIndex; + m_CSGOAttacker.m_iTeamNum = iTeamIndex; + m_CSGOAttacker.m_iUserId = pPlayerInfo->GetUserID(); + } + else + { + if (uiAttacker == 0) { - m_CSGOAttacker.m_iUserId = pPlayerInfo->GetUserID(); - - int iTeamIndex = pPlayerInfo->GetTeamIndex(); - m_CSGOAttacker.m_iTeamChecked = iTeamIndex; - m_CSGOAttacker.m_iTeamNum = iTeamIndex; + m_CSGOAttacker.m_bIsWorld = true; } + m_CSGOAttacker.m_bIsPlayer = false; + m_CSGOAttacker.m_iTeamChecked = -1; + m_CSGOAttacker.m_iTeamNum = -1; + m_CSGOAttacker.m_iUserId = -1; } #else m_hAttacker = ExcBaseHandleFromIndex(uiAttacker); From b19fc0806b85cbafd2cfead7b7f54ce57c98f899 Mon Sep 17 00:00:00 2001 From: Jonathan <30329245+CookStar@users.noreply.github.com> Date: Fri, 25 Sep 2020 01:23:00 +0900 Subject: [PATCH 4/4] Deleted external variables. --- src/core/modules/entities/entities.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/core/modules/entities/entities.h b/src/core/modules/entities/entities.h index 68d65b91d..19a950027 100755 --- a/src/core/modules/entities/entities.h +++ b/src/core/modules/entities/entities.h @@ -48,12 +48,6 @@ #include "game/server/entityoutput.h" -//----------------------------------------------------------------------------- -// External variables. -//----------------------------------------------------------------------------- -extern CGlobalVars *gpGlobals; - - //----------------------------------------------------------------------------- // IServerEntity extension class. //-----------------------------------------------------------------------------