summaryrefslogtreecommitdiffstats
path: root/src/ClientHandle.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-06-06 18:22:42 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2021-06-28 22:54:21 +0200
commit04f02a675de1b788f5e5ed6e681828ea3e358df7 (patch)
tree9cc4c57cde889ef015b6cb5c85357ff9220a197e /src/ClientHandle.cpp
parentSetBedPos: make World parameter non-null (diff)
downloadcuberite-04f02a675de1b788f5e5ed6e681828ea3e358df7.tar
cuberite-04f02a675de1b788f5e5ed6e681828ea3e358df7.tar.gz
cuberite-04f02a675de1b788f5e5ed6e681828ea3e358df7.tar.bz2
cuberite-04f02a675de1b788f5e5ed6e681828ea3e358df7.tar.lz
cuberite-04f02a675de1b788f5e5ed6e681828ea3e358df7.tar.xz
cuberite-04f02a675de1b788f5e5ed6e681828ea3e358df7.tar.zst
cuberite-04f02a675de1b788f5e5ed6e681828ea3e358df7.zip
Diffstat (limited to '')
-rw-r--r--src/ClientHandle.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 1edd612b1..eac73e4ab 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -2173,13 +2173,23 @@ void cClientHandle::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlock
ASSERT(!a_Changes.empty()); // We don't want to be sending empty change packets!
// Do not send block changes in chunks that weren't sent to the client yet:
- cChunkCoords ChunkCoords = cChunkCoords(a_ChunkX, a_ChunkZ);
- cCSLock Lock(m_CSChunkLists);
- if (std::find(m_SentChunks.begin(), m_SentChunks.end(), ChunkCoords) != m_SentChunks.end())
{
- Lock.Unlock();
- m_Protocol->SendBlockChanges(a_ChunkX, a_ChunkZ, a_Changes);
+ cCSLock Lock(m_CSChunkLists);
+ if (std::find(m_SentChunks.begin(), m_SentChunks.end(), cChunkCoords(a_ChunkX, a_ChunkZ)) == m_SentChunks.end())
+ {
+ return;
+ }
+ }
+
+ // Use a dedicated packet for single changes:
+ if (a_Changes.size() == 1)
+ {
+ const auto & Change = a_Changes[0];
+ m_Protocol->SendBlockChange(Change.GetX(), Change.GetY(), Change.GetZ(), Change.m_BlockType, Change.m_BlockMeta);
+ return;
}
+
+ m_Protocol->SendBlockChanges(a_ChunkX, a_ChunkZ, a_Changes);
}