summaryrefslogtreecommitdiffstats
path: root/src/Protocol/ChunkDataSerializer.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-07-19 17:29:49 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2020-07-19 17:29:49 +0200
commit00f8c3a2251833f2d16ec89861a4377029cb2401 (patch)
tree595e6a1a43c31efdd5f47daff11f9a34c4d3a8e0 /src/Protocol/ChunkDataSerializer.h
parentReduce duplication in CompressPacket (diff)
downloadcuberite-00f8c3a2251833f2d16ec89861a4377029cb2401.tar
cuberite-00f8c3a2251833f2d16ec89861a4377029cb2401.tar.gz
cuberite-00f8c3a2251833f2d16ec89861a4377029cb2401.tar.bz2
cuberite-00f8c3a2251833f2d16ec89861a4377029cb2401.tar.lz
cuberite-00f8c3a2251833f2d16ec89861a4377029cb2401.tar.xz
cuberite-00f8c3a2251833f2d16ec89861a4377029cb2401.tar.zst
cuberite-00f8c3a2251833f2d16ec89861a4377029cb2401.zip
Diffstat (limited to '')
-rw-r--r--src/Protocol/ChunkDataSerializer.h47
1 files changed, 25 insertions, 22 deletions
diff --git a/src/Protocol/ChunkDataSerializer.h b/src/Protocol/ChunkDataSerializer.h
index 2670a0705..69e0a7689 100644
--- a/src/Protocol/ChunkDataSerializer.h
+++ b/src/Protocol/ChunkDataSerializer.h
@@ -7,6 +7,12 @@
+class cByteBuffer;
+
+
+
+
+
/** Serializes one chunk's data to (possibly multiple) protocol versions.
Caches the serialized data for as long as this object lives, so that the same data can be sent to
other clients using the same protocol. */
@@ -14,26 +20,31 @@ class cChunkDataSerializer
{
public:
- enum
- {
- RELEASE_1_8_0 = 47,
- RELEASE_1_9_0 = 107,
- RELEASE_1_9_4 = 110,
- RELEASE_1_13 = 393,
- } ;
-
cChunkDataSerializer(
- const cChunkData & a_Data,
- const unsigned char * a_BiomeData,
- const eDimension a_Dimension
+ int a_ChunkX,
+ int a_ChunkZ,
+ const cChunkData & a_Data,
+ const unsigned char * a_BiomeData,
+ const eDimension a_Dimension
);
- /** Serializes the contained chunk data into the specified protocol version. */
- const AString & Serialize(int a_Version, int a_ChunkX, int a_ChunkZ);
+ /** For each client, serializes the chunk into their protocol version and sends it. */
+ void SendToClients(const std::unordered_set<cClientHandle *> & a_SendTo);
protected:
- using Serializations = std::map<int, AString>;
+ void Serialize47 (const std::vector<cClientHandle *> & a_SendTo); // Release 1.8
+ void Serialize107(const std::vector<cClientHandle *> & a_SendTo); // Release 1.9
+ void Serialize110(const std::vector<cClientHandle *> & a_SendTo); // Release 1.9.4
+
+ template <auto Palette>
+ void Serialize393And401(const std::vector<cClientHandle *> & a_SendTo); // Release 1.13 - 1.13.1
+
+ /** Finalises the data, compresses it if required, and delivers it to all clients. */
+ void CompressAndSend(cByteBuffer & a_Packet, const std::vector<cClientHandle *> & a_SendTo);
+
+ /** The coordinates of the chunk to serialise. */
+ int m_ChunkX, m_ChunkZ;
/** The data read from the chunk, to be serialized. */
const cChunkData & m_Data;
@@ -43,14 +54,6 @@ protected:
/** The dimension where the chunk resides. */
const eDimension m_Dimension;
-
- /** The per-protocol serialized data, cached for reuse for other clients. */
- Serializations m_Serializations;
-
- void Serialize47 (AString & a_Data, int a_ChunkX, int a_ChunkZ); // Release 1.8
- void Serialize107(AString & a_Data, int a_ChunkX, int a_ChunkZ); // Release 1.9
- void Serialize110(AString & a_Data, int a_ChunkX, int a_ChunkZ); // Release 1.9.4
- void Serialize393(AString & a_Data, int a_ChunkX, int a_ChunkZ); // Release 1.13
} ;