Added a client verification serial API (bug 3616, r=dvander)

This commit is contained in:
Matt Woodrow
2009-02-19 19:19:44 +13:00
parent db43487b5a
commit ca3df3bd50
5 changed files with 94 additions and 1 deletions
+32
View File
@@ -81,6 +81,8 @@ extern bool __SourceHook_FHRemoveConCommandDispatch(void *,bool,class fastdelega
ConCommand *maxplayersCmd = NULL;
unsigned int g_PlayerSerialCount = 0;
class KickPlayerTimer : public ITimedEvent
{
public:
@@ -1356,6 +1358,28 @@ void PlayerManager::MaxPlayersChanged( int newvalue /*= -1*/ )
}
}
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 @@ void CPlayer::Initialize(const char *name, const char *ip, edict_t *pEntity)
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 @@ int CPlayer::GetLifeState()
return PLAYER_LIFE_DEAD;
}
}
unsigned int CPlayer::GetSerial()
{
return m_Serial.value;
}