diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-03-05 17:41:57 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-03-05 17:41:57 +0100 |
commit | 4d65ffffc0b6f35ac84e310fd4bc9739ea7e0c0a (patch) | |
tree | ccc5f55d8f7a15f08bab8f0222fd1b2f95e5d7a2 /source/cClientHandle.cpp | |
parent | Removed redstone debugging: powered dirt blocks change into stone (diff) | |
download | cuberite-4d65ffffc0b6f35ac84e310fd4bc9739ea7e0c0a.tar cuberite-4d65ffffc0b6f35ac84e310fd4bc9739ea7e0c0a.tar.gz cuberite-4d65ffffc0b6f35ac84e310fd4bc9739ea7e0c0a.tar.bz2 cuberite-4d65ffffc0b6f35ac84e310fd4bc9739ea7e0c0a.tar.lz cuberite-4d65ffffc0b6f35ac84e310fd4bc9739ea7e0c0a.tar.xz cuberite-4d65ffffc0b6f35ac84e310fd4bc9739ea7e0c0a.tar.zst cuberite-4d65ffffc0b6f35ac84e310fd4bc9739ea7e0c0a.zip |
Diffstat (limited to '')
-rw-r--r-- | source/cClientHandle.cpp | 55 |
1 files changed, 22 insertions, 33 deletions
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp index f27ca9e61..9ea063f11 100644 --- a/source/cClientHandle.cpp +++ b/source/cClientHandle.cpp @@ -1681,35 +1681,6 @@ void cClientHandle::Tick(float a_Dt) Send(Ping);
m_LastPingTime = m_PingStartTime;
}
-
- if (m_State >= csDownloadingWorld)
- {
- cWorld * World = m_Player->GetWorld();
-
- cCSLock Lock(m_CSChunkLists);
-
- // Send the chunks:
- int NumSent = 0;
- for (cChunkCoordsList::iterator itr = m_ChunksToSend.begin(); itr != m_ChunksToSend.end();)
- {
- if (!World->SendChunkTo(itr->m_ChunkX, itr->m_ChunkY, itr->m_ChunkZ, this))
- {
- ++itr;
- continue;
- }
- itr = m_ChunksToSend.erase(itr);
- NumSent++;
- if (NumSent > 10)
- {
- // Only send up to 10 chunks per tick, otherwise we'd choke the tick thread
- break;
- }
- } // for itr - m_ChunksToSend[]
- Lock.Unlock();
-
- // Check even if we didn't send anything - a chunk may have sent a notification that we'd miss otherwise
- CheckIfWorldDownloaded();
- }
}
@@ -1737,20 +1708,38 @@ void cClientHandle::Send(const cPacket * a_Packet, ENUM_PRIORITY a_Priority /* = case E_PLAYERMOVELOOK:
case E_KEEP_ALIVE:
case E_PRE_CHUNK:
+ case E_MAP_CHUNK:
{
// Allow
break;
}
- case E_MAP_CHUNK:
+ default: return;
+ }
+ }
+
+ // Check chunks being sent, erase them from m_ChunksToSend:
+ if (a_Packet->m_PacketID == E_MAP_CHUNK)
+ {
+ #if (MINECRAFT_1_2_2 == 1)
+ int ChunkX = ((cPacket_MapChunk *)a_Packet)->m_PosX;
+ int ChunkZ = ((cPacket_MapChunk *)a_Packet)->m_PosZ;
+ #else
+ int ChunkX = ((cPacket_MapChunk *)a_Packet)->m_PosX / cChunk::c_ChunkWidth;
+ int ChunkZ = ((cPacket_MapChunk *)a_Packet)->m_PosZ / cChunk::c_ChunkWidth;
+ #endif
+ cCSLock Lock(m_CSChunkLists);
+ for (cChunkCoordsList::iterator itr = m_ChunksToSend.begin(); itr != m_ChunksToSend.end(); ++itr)
+ {
+ if ((itr->m_ChunkX == ChunkX) && (itr->m_ChunkZ == ChunkZ))
{
+ m_ChunksToSend.erase(itr);
CheckIfWorldDownloaded();
break;
}
-
- default: return;
- }
+ } // for itr - m_ChunksToSend[]
}
+ // Optimize away multiple queued RelativeEntityMoveLook packets:
cCSLock Lock(m_CSPackets);
if (a_Priority == E_PRIORITY_NORMAL)
{
|