summaryrefslogtreecommitdiffstats
path: root/src/Server.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-01-06 01:35:42 +0100
committerTiger Wang <ziwei.tiger@outlook.com>2021-01-12 13:34:34 +0100
commit054a89dd9e5d6819adede9d7ba781b69f98ff2f4 (patch)
tree820a104cae2d9e4ec912b0a1bd7debac52cf4cc9 /src/Server.cpp
parentConvert most calls to blocking GetHeight/GetBiomeAt to direct chunk accesses (diff)
downloadcuberite-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 '')
-rw-r--r--src/Server.cpp10
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[]
}