diff options
Diffstat (limited to '')
-rw-r--r-- | src/Server.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/Server.cpp b/src/Server.cpp index eb8b3de36..cd44e948f 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -319,7 +319,6 @@ cTCPLink::cCallbacksPtr cServer::OnConnectionAccepted(const AString & a_RemoteIP { LOGD("Client \"%s\" connected!", a_RemoteIPAddress.c_str()); cClientHandlePtr NewHandle = std::make_shared<cClientHandle>(a_RemoteIPAddress, m_ClientViewDistance); - NewHandle->SetSelf(NewHandle); cCSLock Lock(m_CSClients); m_Clients.push_back(NewHandle); return std::move(NewHandle); @@ -368,14 +367,17 @@ void cServer::TickClients(float a_Dt) // Tick the remaining clients, take out those that have been destroyed into RemoveClients for (auto itr = m_Clients.begin(); itr != m_Clients.end();) { - if ((*itr)->IsDestroyed()) + auto & Client = *itr; + + Client->ServerTick(a_Dt); + if (Client->IsDestroyed()) { // Delete the client later, when CS is not held, to avoid deadlock: https://forum.cuberite.org/thread-374.html - RemoveClients.push_back(*itr); + RemoveClients.push_back(std::move(Client)); itr = m_Clients.erase(itr); continue; } - (*itr)->ServerTick(a_Dt); + ++itr; } // for itr - m_Clients[] } |