diff -r ab9d418dc8b2 -r 15213de19689 core/PlayerManager.cpp --- a/core/PlayerManager.cpp Thu Feb 19 14:23:36 2009 +1300 +++ b/core/PlayerManager.cpp Thu Feb 19 19:19:44 2009 +1300 @@ -81,6 +81,8 @@ ConCommand *maxplayersCmd = NULL; +unsigned int g_PlayerSerialCount = 0; + class KickPlayerTimer : public ITimedEvent { public: @@ -1356,6 +1358,28 @@ } } +int PlayerManager::GetClientFromSerial(unsigned int serial) +{ + serial_t s; + s.value = serial; + + int client = s.bits.index; + + IGamePlayer *pPlayer = GetGamePlayer(client); + + if (!pPlayer) + { + return 0; + } + + if (serial == pPlayer->GetSerial()) + { + return client; + } + + return 0; +} + #if SOURCE_ENGINE >= SE_ORANGEBOX void CmdMaxplayersCallback(const CCommand &command) { @@ -1397,6 +1421,9 @@ m_iIndex = IndexOfEdict(pEntity); m_LangId = g_Translator.GetServerLanguage(); + m_Serial.bits.index = m_iIndex; + m_Serial.bits.serial = g_PlayerSerialCount++; + char ip2[24], *ptr; strncopy(ip2, ip, sizeof(ip2)); if ((ptr = strchr(ip2, ':')) != NULL) @@ -1760,3 +1787,8 @@ return PLAYER_LIFE_DEAD; } } + +unsigned int CPlayer::GetSerial() +{ + return m_Serial.value; +} \ No newline at end of file