From eeb63b8901a9c049f1bb594abb9ce9b4a9c47620 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 11 Jan 2021 16:39:43 +0000 Subject: zlib -> libdeflate (#5085) + Use libdeflate + Use std::byte * Fix passing temporary to string_view + Emulate make_unique_for_overwrite --- src/Protocol/ChunkDataSerializer.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/Protocol/ChunkDataSerializer.h') diff --git a/src/Protocol/ChunkDataSerializer.h b/src/Protocol/ChunkDataSerializer.h index aeff7c356..ea0b0be11 100644 --- a/src/Protocol/ChunkDataSerializer.h +++ b/src/Protocol/ChunkDataSerializer.h @@ -3,6 +3,8 @@ #include "../ByteBuffer.h" #include "../ChunkData.h" #include "../Defines.h" +#include "CircularBufferCompressor.h" +#include "StringCompression.h" @@ -37,8 +39,7 @@ class cChunkDataSerializer /** A single cache entry containing the raw data, compressed data, and a validity flag. */ struct ChunkDataCache { - std::string PacketData; - std::string ToSend; + ContiguousByteBuffer ToSend; bool Engaged = false; }; @@ -50,7 +51,7 @@ public: Parameters are the coordinates of the chunk to serialise, and the data and biome data read from the chunk. */ void SendToClients(int a_ChunkX, int a_ChunkZ, const cChunkData & a_Data, const unsigned char * a_BiomeData, const ClientHandles & a_SendTo); -protected: +private: /** Serialises the given chunk, storing the result into the given cache entry, and sends the data. If the cache entry is already present, simply re-uses it. */ @@ -74,6 +75,9 @@ protected: /** A staging area used to construct the chunk packet, persistent to avoid reallocating. */ cByteBuffer m_Packet; + /** A compressor used to compress the chunk data. */ + CircularBufferCompressor m_Compressor; + /** The dimension for the World this Serializer is tied to. */ const eDimension m_Dimension; @@ -81,7 +85,3 @@ protected: It is used during a single invocation of SendToClients with more than one client. */ std::array(CacheVersion::Last) + 1> m_Cache; } ; - - - - -- cgit v1.2.3