summaryrefslogtreecommitdiffstats
path: root/src/Protocol/ChunkDataSerializer.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2020-01-03 17:31:13 +0100
committerMattes D <github@xoft.cz>2020-01-07 06:53:17 +0100
commit4aef80b47eb6941d7fc41e57efe147af0ece1f9b (patch)
tree4aeb7c9e8e4aa3ae2ceed1cc60155d868852c5cd /src/Protocol/ChunkDataSerializer.h
parentStringUtils: Added note to StringsConcat about StringJoin. (diff)
downloadcuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar.gz
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar.bz2
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar.lz
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar.xz
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar.zst
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.zip
Diffstat (limited to 'src/Protocol/ChunkDataSerializer.h')
-rw-r--r--src/Protocol/ChunkDataSerializer.h54
1 files changed, 33 insertions, 21 deletions
diff --git a/src/Protocol/ChunkDataSerializer.h b/src/Protocol/ChunkDataSerializer.h
index 7011d3e15..a77935258 100644
--- a/src/Protocol/ChunkDataSerializer.h
+++ b/src/Protocol/ChunkDataSerializer.h
@@ -1,31 +1,16 @@
-
-// ChunkDataSerializer.h
-
-// Interfaces to the cChunkDataSerializer class representing the object that can:
-// - serialize chunk data to different protocol versions
-// - cache such serialized data for multiple clients
+#pragma once
#include "../ChunkData.h"
+
+/** 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. */
class cChunkDataSerializer
{
-protected:
- const cChunkData & m_Data;
- const unsigned char * m_BiomeData;
- const eDimension m_Dimension;
-
- typedef std::map<int, AString> Serializations;
-
- 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
-
public:
enum
{
@@ -41,7 +26,34 @@ public:
const eDimension a_Dimension
);
- const AString & Serialize(int a_Version, int a_ChunkX, int a_ChunkZ); // Returns one of the internal m_Serializations[]
+ /** Serializes the contained chunk data into the specified protocol version.
+ TEMPORARY: a_BlockTypeMap is used for the 1.13+ protocols to map from BLOCKTYPE#META to NetBlockID.
+ a_BlockTypeMap is ignored for pre-1.13 protocols. */
+ const AString & Serialize(int a_Version, int a_ChunkX, int a_ChunkZ, const std::map<UInt32, UInt32> & a_BlockTypeMap);
+
+
+protected:
+
+ using Serializations = std::map<int, AString>;
+
+
+ /** The data read from the chunk, to be serialized. */
+ const cChunkData & m_Data;
+
+ /** The biomes in the chunk, to be serialized. */
+ const unsigned char * m_BiomeData;
+
+ /** 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, const std::map<UInt32, UInt32> & a_BlockTypeMap); // Release 1.13
} ;