diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2021-01-06 01:35:42 +0100 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2021-01-12 13:34:34 +0100 |
commit | 054a89dd9e5d6819adede9d7ba781b69f98ff2f4 (patch) | |
tree | 820a104cae2d9e4ec912b0a1bd7debac52cf4cc9 /src/Server.cpp | |
parent | Convert most calls to blocking GetHeight/GetBiomeAt to direct chunk accesses (diff) | |
download | cuberite-054a89dd9e5d6819adede9d7ba781b69f98ff2f4.tar cuberite-054a89dd9e5d6819adede9d7ba781b69f98ff2f4.tar.gz cuberite-054a89dd9e5d6819adede9d7ba781b69f98ff2f4.tar.bz2 cuberite-054a89dd9e5d6819adede9d7ba781b69f98ff2f4.tar.lz cuberite-054a89dd9e5d6819adede9d7ba781b69f98ff2f4.tar.xz cuberite-054a89dd9e5d6819adede9d7ba781b69f98ff2f4.tar.zst cuberite-054a89dd9e5d6819adede9d7ba781b69f98ff2f4.zip |
Diffstat (limited to 'src/Server.cpp')
-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[] } |