summaryrefslogtreecommitdiffstats
path: root/src/Protocol/ChunkDataSerializer.cpp
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2020-10-05 12:27:14 +0200
committerGitHub <noreply@github.com>2020-10-05 12:27:14 +0200
commita9031b6bae742b333b1b390192fa590f2ecb07ea (patch)
treeb2802c81d24d339c201a0747d66ba44e9ea8b1b0 /src/Protocol/ChunkDataSerializer.cpp
parentFixed current end generator (#4968) (diff)
downloadcuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar
cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar.gz
cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar.bz2
cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar.lz
cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar.xz
cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar.zst
cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.zip
Diffstat (limited to '')
-rw-r--r--src/Protocol/ChunkDataSerializer.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/Protocol/ChunkDataSerializer.cpp b/src/Protocol/ChunkDataSerializer.cpp
index 2fd9e1cc2..9f8b91ac1 100644
--- a/src/Protocol/ChunkDataSerializer.cpp
+++ b/src/Protocol/ChunkDataSerializer.cpp
@@ -503,31 +503,30 @@ inline void cChunkDataSerializer::WriteSectionDataSeamless(const cChunkData::sCh
ASSERT(a_BitsPerEntry < 64);
UInt64 Buffer = 0; // A buffer to compose multiple smaller bitsizes into one 64-bit number
- unsigned char BitIndex = 0; // The bit-position in Buffer that represents where to write next
+ int BitIndex = 0; // The bit-position in Buffer that represents where to write next
for (size_t Index = 0; Index != cChunkData::SectionBlockCount; Index++)
{
- const UInt32 BlockType = a_Section.m_BlockTypes[Index];
- const UInt32 BlockMeta = (a_Section.m_BlockMetas[Index / 2] >> ((Index % 2) * 4)) & 0x0f;
- const UInt32 Value = Palette(BlockType, BlockMeta);
+ const BLOCKTYPE BlockType = a_Section.m_BlockTypes[Index];
+ const NIBBLETYPE BlockMeta = (a_Section.m_BlockMetas[Index / 2] >> ((Index % 2) * 4)) & 0x0f;
+ const auto Value = static_cast<UInt64>(Palette(BlockType, BlockMeta));
// Write as much as possible of Value, starting from BitIndex, into Buffer:
- Buffer |= static_cast<UInt64>(Value) << BitIndex;
+ Buffer |= Value << BitIndex;
// The _signed_ count of bits in Value left to write
- const char Remaining = a_BitsPerEntry - (64 - BitIndex);
- if (Remaining >= 0)
+ if (BitIndex + a_BitsPerEntry >= 64)
{
// There were some bits remaining: we've filled the buffer. Flush it:
m_Packet.WriteBEUInt64(Buffer);
// And write the remaining bits, setting the new BitIndex:
- Buffer = Value >> (a_BitsPerEntry - Remaining);
- BitIndex = Remaining;
+ Buffer = Value >> (64 - BitIndex);
+ BitIndex = a_BitsPerEntry - (64 - BitIndex);
}
else
{
- // It fit, sexcellent.
+ // It fit, excellent.
BitIndex += a_BitsPerEntry;
}
}