From 2687f2df30210ada485c28c98e52db08d460d5a3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 28 Mar 2021 14:44:20 +0100 Subject: Fix chunk block changes being sent out of order (#5169) * Flush out all pending, buffered changes at the end of each tick, after every chunk is ticked. This makes every block update client-side in unison, instead of unlucky ones only being sent 1 tick later. * Re-add buffer for outgoing network data; IOCP async WSASend has higher overhead than expected... Fixes regression introduced in 054a89dd9 --- src/ChunkMap.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/ChunkMap.cpp') diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 7bdd1c649..669a4f564 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -1339,10 +1339,18 @@ void cChunkMap::SpawnMobs(cMobSpawner & a_MobSpawner) void cChunkMap::Tick(std::chrono::milliseconds a_Dt) { cCSLock Lock(m_CSChunks); + + // Do the magic of updating the world: for (auto & Chunk : m_Chunks) { Chunk.second.Tick(a_Dt); } + + // Finally, only after all chunks are ticked, tell the client about all aggregated changes: + for (auto & Chunk : m_Chunks) + { + Chunk.second.BroadcastPendingChanges(); + } } -- cgit v1.2.3