Cache player IClient pointer on connect.
This commit is contained in:
parent
338fdb37f6
commit
c31eaa01a3
@ -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<INetChannel *>(engine->GetPlayerNetInfo(m_iIndex));
|
||||
if (pNetChan)
|
||||
{
|
||||
m_pIClient = static_cast<IClient *>(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<INetChannel *>(engine->GetPlayerNetInfo(m_iIndex));
|
||||
if (pNetChan)
|
||||
{
|
||||
return static_cast<IClient *>(pNetChan->GetMsgHandler());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
#endif
|
||||
return m_pIClient;
|
||||
}
|
||||
|
||||
unsigned int CPlayer::GetSerial()
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user