diff options
author | madmaxoft <github@xoft.cz> | 2013-08-14 10:24:34 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2013-08-14 10:24:34 +0200 |
commit | 8c3837987bd5f74563790c15a1d52755383135ae (patch) | |
tree | b91188a05d3a3053d5ad08cd7bb550c9d4b5518b /source/ClientHandle.cpp | |
parent | Exported cWorld:BroadcastChat() to the Lua API; used in the Core. (diff) | |
download | cuberite-8c3837987bd5f74563790c15a1d52755383135ae.tar cuberite-8c3837987bd5f74563790c15a1d52755383135ae.tar.gz cuberite-8c3837987bd5f74563790c15a1d52755383135ae.tar.bz2 cuberite-8c3837987bd5f74563790c15a1d52755383135ae.tar.lz cuberite-8c3837987bd5f74563790c15a1d52755383135ae.tar.xz cuberite-8c3837987bd5f74563790c15a1d52755383135ae.tar.zst cuberite-8c3837987bd5f74563790c15a1d52755383135ae.zip |
Diffstat (limited to '')
-rw-r--r-- | source/ClientHandle.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp index fe78ef2b6..32bfb00f5 100644 --- a/source/ClientHandle.cpp +++ b/source/ClientHandle.cpp @@ -275,7 +275,7 @@ void cClientHandle::Authenticate(void) void cClientHandle::StreamChunks(void) { - if ((m_State < csAuthenticating) || (m_State >= csDestroying)) + if ((m_State < csAuthenticated) || (m_State >= csDestroying)) { return; } @@ -1314,6 +1314,42 @@ void cClientHandle::SendData(const char * a_Data, int a_Size) +void cClientHandle::MoveToWorld(cWorld & a_World, bool a_SendRespawnPacket) +{ + ASSERT(m_Player != NULL); + + if (a_SendRespawnPacket) + { + SendRespawn(); + } + + cWorld * World = m_Player->GetWorld(); + + // Remove all associated chunks: + cChunkCoordsList Chunks; + { + cCSLock Lock(m_CSChunkLists); + std::swap(Chunks, m_LoadedChunks); + m_ChunksToSend.clear(); + } + for (cChunkCoordsList::iterator itr = Chunks.begin(), end = Chunks.end(); itr != end; ++itr) + { + World->RemoveChunkClient(itr->m_ChunkX, itr->m_ChunkZ, this); + m_Protocol->SendUnloadChunk(itr->m_ChunkX, itr->m_ChunkZ); + } // for itr - Chunks[] + + // Do NOT stream new chunks, the new world runs its own tick thread and may deadlock + // Instead, the chunks will be streamed when the client is moved to the new world's Tick list, + // by setting state to csAuthenticated + m_State = csAuthenticated; + m_LastStreamedChunkX = 0x7fffffff; + m_LastStreamedChunkZ = 0x7fffffff; +} + + + + + bool cClientHandle::CheckBlockInteractionsRate(void) { ASSERT(m_Player != NULL); |