From 6c4740c79889531ca1109d0f2d81eef6f8326e31 Mon Sep 17 00:00:00 2001 From: tycho Date: Tue, 15 Sep 2015 17:12:03 +0100 Subject: Always tick clients in the server --- src/Server.cpp | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) (limited to 'src/Server.cpp') diff --git a/src/Server.cpp b/src/Server.cpp index 12c45467d..c75fa3c39 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -153,16 +153,6 @@ cServer::cServer(void) : -void cServer::ClientMovedToWorld(const cClientHandle * a_Client) -{ - cCSLock Lock(m_CSClients); - m_ClientsToRemove.push_back(const_cast(a_Client)); -} - - - - - void cServer::PlayerCreated(const cPlayer * a_Player) { UNUSED(a_Player); @@ -268,7 +258,7 @@ int cServer::GetNumPlayers(void) const -bool cServer::IsPlayerInQueue(AString a_Username) +bool cServer::IsClientOnServer(AString a_Username) { cCSLock Lock(m_CSClients); for (auto client : m_Clients) @@ -284,7 +274,6 @@ bool cServer::IsPlayerInQueue(AString a_Username) - void cServer::PrepareKeys(void) { LOGD("Generating protocol encryption keypair..."); @@ -329,7 +318,7 @@ bool cServer::Tick(float a_Dt) // Let the Root process all the queued commands: cRoot::Get()->TickCommands(); - // Tick all clients not yet assigned to a world: + // Tick all clients TickClients(a_Dt); if (!m_bRestarting) @@ -354,20 +343,6 @@ void cServer::TickClients(float a_Dt) { cCSLock Lock(m_CSClients); - // Remove clients that have moved to a world (the world will be ticking them from now on) - for (auto itr = m_ClientsToRemove.begin(), end = m_ClientsToRemove.end(); itr != end; ++itr) - { - for (auto itrC = m_Clients.begin(), endC = m_Clients.end(); itrC != endC; ++itrC) - { - if (itrC->get() == *itr) - { - m_Clients.erase(itrC); - break; - } - } - } // for itr - m_ClientsToRemove[] - m_ClientsToRemove.clear(); - // Tick the remaining clients, take out those that have been destroyed into RemoveClients for (auto itr = m_Clients.begin(); itr != m_Clients.end();) { @@ -378,7 +353,7 @@ void cServer::TickClients(float a_Dt) itr = m_Clients.erase(itr); continue; } - (*itr)->ServerTick(a_Dt); + (*itr)->Tick(a_Dt); ++itr; } // for itr - m_Clients[] } @@ -687,3 +662,7 @@ void cServer::AuthenticateUser(int a_ClientID, const AString & a_Name, const ASt +void cServer::QueueRemoveAndDestroyClient(cClientHandle * a_Client) +{ + a_Client->Destroy(); +} -- cgit v1.2.3