summaryrefslogtreecommitdiffstats
path: root/source/World.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-08-14 13:43:55 +0200
committermadmaxoft <github@xoft.cz>2013-08-14 13:43:55 +0200
commitf8757d3606a9cf14a353e5b7a61b8e660a4cce6d (patch)
tree134fb9be8d1d7dfd0fb687923bd0a276e0b7698d /source/World.cpp
parentPlayer counts are now properly handled. (diff)
downloadcuberite-f8757d3606a9cf14a353e5b7a61b8e660a4cce6d.tar
cuberite-f8757d3606a9cf14a353e5b7a61b8e660a4cce6d.tar.gz
cuberite-f8757d3606a9cf14a353e5b7a61b8e660a4cce6d.tar.bz2
cuberite-f8757d3606a9cf14a353e5b7a61b8e660a4cce6d.tar.lz
cuberite-f8757d3606a9cf14a353e5b7a61b8e660a4cce6d.tar.xz
cuberite-f8757d3606a9cf14a353e5b7a61b8e660a4cce6d.tar.zst
cuberite-f8757d3606a9cf14a353e5b7a61b8e660a4cce6d.zip
Diffstat (limited to 'source/World.cpp')
-rw-r--r--source/World.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/source/World.cpp b/source/World.cpp
index 7a1ecb82e..59240c7da 100644
--- a/source/World.cpp
+++ b/source/World.cpp
@@ -817,6 +817,26 @@ void cWorld::TickClients(float a_Dt)
cClientHandleList RemoveClients;
{
cCSLock Lock(m_CSClients);
+
+ // Remove clients scheduled for removal:
+ for (cClientHandleList::iterator itr = m_ClientsToRemove.begin(), end = m_ClientsToRemove.end(); itr != end; ++itr)
+ {
+ m_Clients.remove(*itr);
+ } // for itr - m_ClientsToRemove[]
+ m_ClientsToRemove.clear();
+
+ // Add clients scheduled for adding:
+ for (cClientHandleList::iterator itr = m_ClientsToAdd.begin(), end = m_ClientsToAdd.end(); itr != end; ++itr)
+ {
+ if (std::find(m_Clients.begin(), m_Clients.end(), *itr) != m_Clients.end())
+ {
+ ASSERT(!"Adding a client that is already in the clientlist");
+ continue;
+ }
+ m_Clients.push_back(*itr);
+ } // for itr - m_ClientsToRemove[]
+ m_ClientsToAdd.clear();
+
// Tick the clients, take out those that have been destroyed into RemoveClients
for (cClientHandleList::iterator itr = m_Clients.begin(); itr != m_Clients.end();)
{
@@ -2018,7 +2038,7 @@ void cWorld::AddPlayer(cPlayer * a_Player)
if (a_Player->GetClientHandle() != NULL)
{
cCSLock Lock(m_CSClients);
- m_Clients.push_back(a_Player->GetClientHandle());
+ m_ClientsToAdd.push_back(a_Player->GetClientHandle());
}
// The player has already been added to the chunkmap as the entity, do NOT add again!
@@ -2040,7 +2060,7 @@ void cWorld::RemovePlayer(cPlayer * a_Player)
if (a_Player->GetClientHandle() != NULL)
{
cCSLock Lock(m_CSClients);
- m_Clients.remove(a_Player->GetClientHandle());
+ m_ClientsToRemove.push_back(a_Player->GetClientHandle());
}
}