diff options
author | Howaner <franzi.moos@googlemail.com> | 2014-09-08 12:24:06 +0200 |
---|---|---|
committer | Howaner <franzi.moos@googlemail.com> | 2014-09-08 12:24:06 +0200 |
commit | 38124bcce3c5e8ed8e4dba904dc4f15f89a82c14 (patch) | |
tree | 7f28ca9ff1c9d024c67ca9cdd1b8e66d29a30640 /src/Protocol/ChunkDataSerializer.cpp | |
parent | Added GetProtocolVersion() to cProtocol. (diff) | |
download | cuberite-38124bcce3c5e8ed8e4dba904dc4f15f89a82c14.tar cuberite-38124bcce3c5e8ed8e4dba904dc4f15f89a82c14.tar.gz cuberite-38124bcce3c5e8ed8e4dba904dc4f15f89a82c14.tar.bz2 cuberite-38124bcce3c5e8ed8e4dba904dc4f15f89a82c14.tar.lz cuberite-38124bcce3c5e8ed8e4dba904dc4f15f89a82c14.tar.xz cuberite-38124bcce3c5e8ed8e4dba904dc4f15f89a82c14.tar.zst cuberite-38124bcce3c5e8ed8e4dba904dc4f15f89a82c14.zip |
Diffstat (limited to 'src/Protocol/ChunkDataSerializer.cpp')
-rw-r--r-- | src/Protocol/ChunkDataSerializer.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/Protocol/ChunkDataSerializer.cpp b/src/Protocol/ChunkDataSerializer.cpp index a2e0c9ef9..d4574954e 100644 --- a/src/Protocol/ChunkDataSerializer.cpp +++ b/src/Protocol/ChunkDataSerializer.cpp @@ -182,25 +182,26 @@ void cChunkDataSerializer::Serialize80(AString & a_Data, int a_ChunkX, int a_Chu // TODO: Do not copy data and then compress it; rather, compress partial blocks of data (zlib *can* stream) // Blocktypes converter (1.8 included the meta into the blocktype): - /*unsigned short Blocks[ARRAYCOUNT(m_BlockTypes)]; + unsigned char Blocks[cChunkDef::NumBlocks * 2]; + size_t LastOffset = 0; for (size_t Index = 0; Index < cChunkDef::NumBlocks; Index++) { - BLOCKTYPE BlockType = m_BlockTypes[Index]; + BLOCKTYPE BlockType = m_BlockTypes[Index] & 0xFF; NIBBLETYPE BlockMeta = m_BlockMetas[Index / 2] >> ((Index & 1) * 4) & 0x0f; - Blocks[Index] = ((unsigned short)BlockType << 4) | ((unsigned short)BlockMeta); - }*/ + Blocks[LastOffset] = (BlockType << 4) | ((unsigned char)BlockMeta); + Blocks[LastOffset + 1] = (unsigned char)BlockType >> 4; + LastOffset += 2; + } const int BiomeDataSize = cChunkDef::Width * cChunkDef::Width; - const int MetadataOffset = sizeof(m_BlockTypes); - const int BlockLightOffset = MetadataOffset + sizeof(m_BlockMetas); + const int BlockLightOffset = sizeof(Blocks); const int SkyLightOffset = BlockLightOffset + sizeof(m_BlockLight); const int BiomeOffset = SkyLightOffset + sizeof(m_BlockSkyLight); const int DataSize = BiomeOffset + BiomeDataSize; // Temporary buffer for the composed data: char AllData [DataSize]; - memcpy(AllData, m_BlockTypes, sizeof(m_BlockTypes)); - memcpy(AllData + MetadataOffset, m_BlockMetas, sizeof(m_BlockMetas)); + memcpy(AllData, Blocks, sizeof(Blocks)); memcpy(AllData + BlockLightOffset, m_BlockLight, sizeof(m_BlockLight)); memcpy(AllData + SkyLightOffset, m_BlockSkyLight, sizeof(m_BlockSkyLight)); memcpy(AllData + BiomeOffset, m_BiomeData, BiomeDataSize); |