From 9ffbac4f4e8885b0b177d2369be0abff33aaaf1e Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Wed, 18 Feb 2015 18:44:31 -0500 Subject: [PATCH] Simplified code. (We don't need m_Shared). --- extensions/tf2/conditions.cpp | 16 ++++++---------- extensions/tf2/conditions.h | 8 +++----- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/extensions/tf2/conditions.cpp b/extensions/tf2/conditions.cpp index 685d28184..e02190c99 100644 --- a/extensions/tf2/conditions.cpp +++ b/extensions/tf2/conditions.cpp @@ -110,7 +110,7 @@ static void OnPlayerCondChange(const SendProp *pProp, const void *pStructBase, c void PlayerConditionsMgr::OnConVarChange(CondVar var, const SendProp *pProp, const void *pStructBase, const void *pData, DVariant *pOut, int iElement, int objectID) { auto pCondData = new CondChangeData_t; - pCondData->pPlayer = (CBaseEntity *)((intp)pStructBase - GetPropOffs(m_Shared)); + pCondData->pPlayer = (CBaseEntity *)((intp)pData - GetPropOffs(var)); pCondData->var = var; pCondData->newConds = *(int *)pData; @@ -129,11 +129,8 @@ bool PlayerConditionsMgr::SetupProp(const char *varname) return false; } - if (var != m_Shared) - { - m_BackupProxyFns[var] = GetProp(var)->GetProxyFn(); - GetProp(var)->SetProxyFn(OnPlayerCondChange); - } + m_BackupProxyFns[var] = GetProp(var)->GetProxyFn(); + GetProp(var)->SetProxyFn(OnPlayerCondChange); return true; } @@ -155,8 +152,7 @@ bool PlayerConditionsMgr::Init() && SetupProp<_condition_bits>("_condition_bits") && SetupProp("m_nPlayerCondEx") && SetupProp("m_nPlayerCondEx2") - && SetupProp("m_nPlayerCondEx3") - && SetupProp("m_Shared"); + && SetupProp("m_nPlayerCondEx3"); if (!bFoundProps) return false; @@ -171,7 +167,7 @@ bool PlayerConditionsMgr::Init() continue; CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(i); - for (size_t j = 0; j < CondVar_LastNotifyProp; ++j) + for (size_t j = 0; j < CondVar_Count; ++j) { m_OldConds[i][j] = *(int *)((intp) pEntity + GetPropOffs((CondVar)j)); } @@ -182,7 +178,7 @@ bool PlayerConditionsMgr::Init() void PlayerConditionsMgr::Shutdown() { - for (size_t i = 0; i < CondVar_LastNotifyProp; ++i) + for (size_t i = 0; i < CondVar_Count; ++i) { GetProp((CondVar)i)->SetProxyFn(m_BackupProxyFns[i]); } diff --git a/extensions/tf2/conditions.h b/extensions/tf2/conditions.h index 9baaaae66..4aa760915 100644 --- a/extensions/tf2/conditions.h +++ b/extensions/tf2/conditions.h @@ -52,8 +52,6 @@ public: m_nPlayerCondEx, m_nPlayerCondEx2, m_nPlayerCondEx3, - m_Shared, - CondVar_LastNotifyProp = m_Shared, CondVar_Count }; @@ -72,10 +70,10 @@ private: template bool SetupProp(const char *varname); private: - int m_OldConds[SM_MAXPLAYERS + 1][CondVar_LastNotifyProp]; + int m_OldConds[SM_MAXPLAYERS + 1][CondVar_Count]; sm_sendprop_info_t m_CondVarProps[CondVar_Count]; - int m_CondOffset[CondVar_LastNotifyProp]; - SendVarProxyFn m_BackupProxyFns[CondVar_LastNotifyProp]; + int m_CondOffset[CondVar_Count]; + SendVarProxyFn m_BackupProxyFns[CondVar_Count]; }; extern PlayerConditionsMgr g_CondMgr;