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/ClientHandle.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/ClientHandle.h') diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 983cb039d..d18b66280 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -105,6 +105,9 @@ public: // tolua_export We use Version-3 UUIDs for offline UUIDs, online UUIDs are Version-4, thus we can tell them apart. */ static bool IsUUIDOnline(const cUUID & a_UUID); // Exported in ManualBindings.cpp + /** Flushes all buffered outgoing data to the network. */ + void ProcessProtocolOut(); + /** Formats the type of message with the proper color and prefix for sending to the client. */ static AString FormatMessageType(bool ShouldAppendChatPrefixes, eMessageType a_ChatPrefix, const AString & a_AdditionalData); @@ -443,13 +446,17 @@ private: /** Protects m_IncomingData against multithreaded access. */ cCriticalSection m_CSIncomingData; - /** Queue for the incoming data received on the link until it is processed in Tick(). + /** Queue for the incoming data received on the link until it is processed in ProcessProtocolIn(). Protected by m_CSIncomingData. */ ContiguousByteBuffer m_IncomingData; /** Protects m_OutgoingData against multithreaded access. */ cCriticalSection m_CSOutgoingData; + /** Buffer for storing outgoing data from any thread; will get sent in ProcessProtocolOut() at the end of each tick. + Protected by m_CSOutgoingData. */ + ContiguousByteBuffer m_OutgoingData; + /** A pointer to a World-owned player object, created in FinishAuthenticate when authentication succeeds. The player should only be accessed from the tick thread of the World that owns him. After the player object is handed off to the World, lifetime is managed automatically, guaranteed to outlast this client handle. -- cgit v1.2.3