summaryrefslogtreecommitdiffstats
path: root/source/cClientHandle.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-03-06 15:52:44 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-03-06 15:52:44 +0100
commit8cdd63f06c692f117088909ea5c9b950bba34376 (patch)
treef07924d43ede604c6a5fe30df5914c68a8f7f1dc /source/cClientHandle.cpp
parentFixed bug FS#157 http://mc-server.org/support/index.php?do=details&task_id=157 (diff)
downloadcuberite-8cdd63f06c692f117088909ea5c9b950bba34376.tar
cuberite-8cdd63f06c692f117088909ea5c9b950bba34376.tar.gz
cuberite-8cdd63f06c692f117088909ea5c9b950bba34376.tar.bz2
cuberite-8cdd63f06c692f117088909ea5c9b950bba34376.tar.lz
cuberite-8cdd63f06c692f117088909ea5c9b950bba34376.tar.xz
cuberite-8cdd63f06c692f117088909ea5c9b950bba34376.tar.zst
cuberite-8cdd63f06c692f117088909ea5c9b950bba34376.zip
Diffstat (limited to 'source/cClientHandle.cpp')
-rw-r--r--source/cClientHandle.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp
index 9ea063f11..ee9f0ab3a 100644
--- a/source/cClientHandle.cpp
+++ b/source/cClientHandle.cpp
@@ -240,6 +240,7 @@ void cClientHandle::Destroy()
if ((m_Player != NULL) && (m_Player->GetWorld() != NULL))
{
RemoveFromAllChunks();
+ m_Player->GetWorld()->RemoveClientFromChunkSender(this);
}
m_bDestroyed = true;
@@ -355,7 +356,8 @@ void cClientHandle::StreamChunks(void)
cWorld * World = m_Player->GetWorld();
ASSERT(World != NULL);
- // Remove all loaded chunks that are no longer in range:
+ // Remove all loaded chunks that are no longer in range; deferred to out-of-CS:
+ cChunkCoordsList RemoveChunks;
{
cCSLock Lock(m_CSChunkLists);
for (cChunkCoordsList::iterator itr = m_LoadedChunks.begin(); itr != m_LoadedChunks.end();)
@@ -364,8 +366,7 @@ void cClientHandle::StreamChunks(void)
int RelZ = (*itr).m_ChunkZ - ChunkPosZ;
if ((RelX > m_ViewDistance) || (RelX < -m_ViewDistance) || (RelZ > m_ViewDistance) || (RelZ < -m_ViewDistance))
{
- World->RemoveChunkClient(itr->m_ChunkX, itr->m_ChunkY, itr->m_ChunkZ, this);
- Send( cPacket_PreChunk( itr->m_ChunkX, itr->m_ChunkZ, false ) );
+ RemoveChunks.push_back(*itr);
itr = m_LoadedChunks.erase(itr);
}
else
@@ -385,8 +386,13 @@ void cClientHandle::StreamChunks(void)
{
++itr;
}
- }
+ } // for itr - m_ChunksToSend[]
}
+ for (cChunkCoordsList::iterator itr = RemoveChunks.begin(); itr != RemoveChunks.end(); ++itr)
+ {
+ World->RemoveChunkClient(itr->m_ChunkX, itr->m_ChunkY, itr->m_ChunkZ, this);
+ Send(cPacket_PreChunk(itr->m_ChunkX, itr->m_ChunkZ, false));
+ } // for itr - RemoveChunks[]
// Add all chunks that are in range and not yet in m_LoadedChunks:
// Queue these smartly - from the center out to the edge
@@ -435,6 +441,7 @@ void cClientHandle::StreamChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
cCSLock Lock(m_CSChunkLists);
m_LoadedChunks.push_back(cChunkCoords(a_ChunkX, a_ChunkY, a_ChunkZ));
m_ChunksToSend.push_back(cChunkCoords(a_ChunkX, a_ChunkY, a_ChunkZ));
+ World->SendChunkTo(a_ChunkX, a_ChunkY, a_ChunkZ, this);
}
}