From c31eaa01a32ae865894a08a40cc9415dc8113ef4 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Fri, 23 Jun 2017 11:08:07 -0400 Subject: [PATCH] Cache player IClient pointer on connect. --- core/PlayerManager.cpp | 32 ++++++++++++++++---------------- core/PlayerManager.h | 1 + 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp index f21050bb..d00273d2 100644 --- a/core/PlayerManager.cpp +++ b/core/PlayerManager.cpp @@ -1960,6 +1960,21 @@ void CPlayer::Initialize(const char *name, const char *ip, edict_t *pEntity) } m_IpNoPort.assign(ip2); +#if SOURCE_ENGINE == SE_TF2 \ + || SOURCE_ENGINE == SE_CSS \ + || SOURCE_ENGINE == SE_DODS \ + || SOURCE_ENGINE == SE_HL2DM \ + || SOURCE_ENGINE == SE_BMS \ + || SOURCE_ENGINE == SE_INSURGENCY + m_pIClient = engine->GetIServer()->GetClient(m_iIndex - 1); +#else + INetChannel *pNetChan = static_cast(engine->GetPlayerNetInfo(m_iIndex)); + if (pNetChan) + { + m_pIClient = static_cast(pNetChan->GetMsgHandler()); + } +#endif + UpdateAuthIds(); } @@ -2550,22 +2565,7 @@ int CPlayer::GetLifeState() IClient *CPlayer::GetIClient() const { -#if SOURCE_ENGINE == SE_TF2 \ - || SOURCE_ENGINE == SE_CSS \ - || SOURCE_ENGINE == SE_DODS \ - || SOURCE_ENGINE == SE_HL2DM \ - || SOURCE_ENGINE == SE_BMS \ - || SOURCE_ENGINE == SE_INSURGENCY - return engine->GetIServer()->GetClient(m_iIndex - 1); -#else - INetChannel *pNetChan = static_cast(engine->GetPlayerNetInfo(m_iIndex)); - if (pNetChan) - { - return static_cast(pNetChan->GetMsgHandler()); - } - - return nullptr; -#endif + return m_pIClient; } unsigned int CPlayer::GetSerial() diff --git a/core/PlayerManager.h b/core/PlayerManager.h index d5bb32a4..e66995aa 100644 --- a/core/PlayerManager.h +++ b/core/PlayerManager.h @@ -138,6 +138,7 @@ private: bool m_TempAdmin = false; edict_t *m_pEdict = nullptr; IPlayerInfo *m_Info = nullptr; + IClient *m_pIClient = nullptr; String m_LastPassword; bool m_bAdminCheckSignalled = false; int m_iIndex;