1.1 --- a/core/PlayerManager.cpp Thu Feb 19 14:23:36 2009 +1300
1.2 +++ b/core/PlayerManager.cpp Thu Feb 19 19:19:44 2009 +1300
1.3 @@ -81,6 +81,8 @@
1.4
1.5 ConCommand *maxplayersCmd = NULL;
1.6
1.7 +unsigned int g_PlayerSerialCount = 0;
1.8 +
1.9 class KickPlayerTimer : public ITimedEvent
1.10 {
1.11 public:
1.12 @@ -1356,6 +1358,28 @@
1.13 }
1.14 }
1.15
1.16 +int PlayerManager::GetClientFromSerial(unsigned int serial)
1.17 +{
1.18 + serial_t s;
1.19 + s.value = serial;
1.20 +
1.21 + int client = s.bits.index;
1.22 +
1.23 + IGamePlayer *pPlayer = GetGamePlayer(client);
1.24 +
1.25 + if (!pPlayer)
1.26 + {
1.27 + return 0;
1.28 + }
1.29 +
1.30 + if (serial == pPlayer->GetSerial())
1.31 + {
1.32 + return client;
1.33 + }
1.34 +
1.35 + return 0;
1.36 +}
1.37 +
1.38 #if SOURCE_ENGINE >= SE_ORANGEBOX
1.39 void CmdMaxplayersCallback(const CCommand &command)
1.40 {
1.41 @@ -1397,6 +1421,9 @@
1.42 m_iIndex = IndexOfEdict(pEntity);
1.43 m_LangId = g_Translator.GetServerLanguage();
1.44
1.45 + m_Serial.bits.index = m_iIndex;
1.46 + m_Serial.bits.serial = g_PlayerSerialCount++;
1.47 +
1.48 char ip2[24], *ptr;
1.49 strncopy(ip2, ip, sizeof(ip2));
1.50 if ((ptr = strchr(ip2, ':')) != NULL)
1.51 @@ -1760,3 +1787,8 @@
1.52 return PLAYER_LIFE_DEAD;
1.53 }
1.54 }
1.55 +
1.56 +unsigned int CPlayer::GetSerial()
1.57 +{
1.58 + return m_Serial.value;
1.59 +}
1.60 \ No newline at end of file