3 #include "../ByteBuffer.h"
4 #include "../ChunkData.h"
5 #include "../Defines.h"
63 template <auto Palette>
69 template <auto Palette>
eDimension
Dimension of a world.
std::basic_string< std::byte > ContiguousByteBuffer
An object that can store incoming bytes and lets its clients read the bytes sequentially The bytes ar...
decltype(m_Blocks)::Type BlockArray
decltype(m_Metas)::Type MetaArray
decltype(m_BlockLights)::Type LightArray
Serializes one chunk's data to (possibly multiple) protocol versions.
void WriteLightSectionGrouped(const ChunkLightData::LightArray *a_BlockLights, const ChunkLightData::LightArray *a_SkyLights)
Copies all lights in a chunk section into the packet, block light followed immediately by sky light.
void WriteBlockSectionSeamless(const ChunkBlockData::BlockArray *a_Blocks, const ChunkBlockData::MetaArray *a_Metas, UInt8 a_BitsPerEntry)
Writes all blocks in a chunk section into a series of Int64.
CircularBufferCompressor m_Compressor
A compressor used to compress the chunk data.
void Serialize47(int a_ChunkX, int a_ChunkZ, const ChunkBlockData &a_BlockData, const ChunkLightData &a_LightData, const unsigned char *a_BiomeMap)
void Serialize393(int a_ChunkX, int a_ChunkZ, const ChunkBlockData &a_BlockData, const ChunkLightData &a_LightData, const unsigned char *a_BiomeMap)
void Serialize(const ClientHandles::value_type &a_Client, int a_ChunkX, int a_ChunkZ, const ChunkBlockData &a_BlockData, const ChunkLightData &a_LightData, const unsigned char *a_BiomeMap, CacheVersion a_CacheVersion)
Serialises the given chunk, storing the result into the given cache entry, and sends the data.
cChunkDataSerializer(eDimension a_Dimension)
void Serialize110(int a_ChunkX, int a_ChunkZ, const ChunkBlockData &a_BlockData, const ChunkLightData &a_LightData, const unsigned char *a_BiomeMap)
CacheVersion
Enum to collapse protocol versions into a contiguous index.
const eDimension m_Dimension
The dimension for the World this Serializer is tied to.
std::vector< std::shared_ptr< cClientHandle > > ClientHandles
void CompressPacketInto(ChunkDataCache &a_Cache)
Finalises the data, compresses it if required, and stores it into cache.
void SendToClients(int a_ChunkX, int a_ChunkZ, const ChunkBlockData &a_BlockData, const ChunkLightData &a_LightData, const unsigned char *a_BiomeMap, const ClientHandles &a_SendTo)
For each client, serializes the chunk into their protocol version and sends it.
cByteBuffer m_Packet
A staging area used to construct the chunk packet, persistent to avoid reallocating.
void Serialize477(int a_ChunkX, int a_ChunkZ, const ChunkBlockData &a_BlockData, const ChunkLightData &a_LightData, const unsigned char *a_BiomeMap)
void Serialize107(int a_ChunkX, int a_ChunkZ, const ChunkBlockData &a_BlockData, const ChunkLightData &a_LightData, const unsigned char *a_BiomeMap)
std::array< ChunkDataCache, static_cast< size_t >CacheVersion::Last)+1 > m_Cache
A cache, mapping protocol version to a fully serialised chunk.
A single cache entry containing the raw data, compressed data, and a validity flag.
ContiguousByteBuffer ToSend