2020-01-03 11:31:13 -05:00
|
|
|
#pragma once
|
2013-07-29 07:13:03 -04:00
|
|
|
|
2018-08-28 20:51:25 -04:00
|
|
|
#include "../ChunkData.h"
|
2020-04-03 02:57:01 -04:00
|
|
|
#include "../Defines.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-01-03 11:31:13 -05:00
|
|
|
|
2020-07-19 11:29:49 -04:00
|
|
|
class cByteBuffer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-01-03 11:31:13 -05:00
|
|
|
/** 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. */
|
2013-07-29 07:13:03 -04:00
|
|
|
class cChunkDataSerializer
|
|
|
|
{
|
|
|
|
public:
|
2020-07-18 09:22:14 -04:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
cChunkDataSerializer(
|
2020-07-19 11:29:49 -04:00
|
|
|
int a_ChunkX,
|
|
|
|
int a_ChunkZ,
|
|
|
|
const cChunkData & a_Data,
|
|
|
|
const unsigned char * a_BiomeData,
|
|
|
|
const eDimension a_Dimension
|
2013-07-29 07:13:03 -04:00
|
|
|
);
|
|
|
|
|
2020-07-19 11:29:49 -04:00
|
|
|
/** For each client, serializes the chunk into their protocol version and sends it. */
|
|
|
|
void SendToClients(const std::unordered_set<cClientHandle *> & a_SendTo);
|
2020-01-03 11:31:13 -05:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2020-07-19 11:29:49 -04:00
|
|
|
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;
|
2020-01-03 11:31:13 -05:00
|
|
|
|
|
|
|
/** 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;
|
2013-07-29 07:13:03 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|