summaryrefslogtreecommitdiffstats
path: root/src/Protocol/ChunkDataSerializer.cpp
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2016-02-05 22:45:45 +0100
committerLogicParrot <LogicParrot@users.noreply.github.com>2016-02-05 22:50:18 +0100
commitca6ef58b1ee8521e4b940ee4883dee714960e413 (patch)
tree8532add455224b07c07a759e3d906f50c0695888 /src/Protocol/ChunkDataSerializer.cpp
parentMerge pull request #2972 from marvinkopf/PlayerAutoComplete (diff)
downloadcuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.gz
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.bz2
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.lz
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.xz
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.zst
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.zip
Diffstat (limited to '')
-rw-r--r--src/Protocol/ChunkDataSerializer.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/Protocol/ChunkDataSerializer.cpp b/src/Protocol/ChunkDataSerializer.cpp
index 8c5569cc7..848a6f597 100644
--- a/src/Protocol/ChunkDataSerializer.cpp
+++ b/src/Protocol/ChunkDataSerializer.cpp
@@ -39,14 +39,14 @@ const AString & cChunkDataSerializer::Serialize(int a_Version, int a_ChunkX, int
{
return itr->second;
}
-
+
AString data;
switch (a_Version)
{
case RELEASE_1_3_2: Serialize39(data); break;
case RELEASE_1_8_0: Serialize47(data, a_ChunkX, a_ChunkZ); break;
// TODO: Other protocol versions may serialize the data differently; implement here
-
+
default:
{
LOGERROR("cChunkDataSerializer::Serialize(): Unknown version: %d", a_Version);
@@ -74,7 +74,7 @@ void cChunkDataSerializer::Serialize39(AString & a_Data)
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];
@@ -91,29 +91,29 @@ void cChunkDataSerializer::Serialize39(AString & a_Data)
char CompressedBlockData[CompressedMaxSize];
uLongf CompressedSize = compressBound(DataSize);
-
+
// Run-time check that our compile-time guess about CompressedMaxSize was enough:
ASSERT(CompressedSize <= CompressedMaxSize);
-
+
compress2(reinterpret_cast<Bytef*>(CompressedBlockData), &CompressedSize, reinterpret_cast<const Bytef*>(AllData), sizeof(AllData), Z_DEFAULT_COMPRESSION);
// Now put all those data into a_Data:
-
+
// "Ground-up continuous", or rather, "biome data present" flag:
a_Data.push_back('\x01');
-
+
// Two bitmaps; we're aways sending the full chunk with no additional data, so the bitmaps are 0xffff and 0, respectively
// Also, no endian flipping is needed because of the const values
unsigned short BitMap1 = 0xffff;
unsigned short BitMap2 = 0;
a_Data.append(reinterpret_cast<const char *>(&BitMap1), sizeof(short));
a_Data.append(reinterpret_cast<const char *>(&BitMap2), sizeof(short));
-
+
UInt32 CompressedSizeBE = htonl(static_cast<UInt32>(CompressedSize));
a_Data.append(reinterpret_cast<const char *>(&CompressedSizeBE), sizeof(CompressedSizeBE));
-
+
// Unlike 29, 39 doesn't have the "unused" int
-
+
a_Data.append(CompressedBlockData, CompressedSize);
}