From 090d8305e4e3c3ee085a897b72f2b4708e183eb8 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 5 Oct 2020 13:09:42 +0100 Subject: Warnings improvements * Turn off global-constructors warning. These are needed to implement cRoot signal handler functionality * Add Clang flags based on version lookup instead of a compile test. The CMake config process is single threaded and slow enough already * Reduced GetStackValue verbosity + Clarify EnchantmentLevel, StayCount, AlwaysTicked, ViewDistance signedness + Give SettingsRepositoryInterface a move constructor to simplify main.cpp code - Remove do {} while (false) construction in redstone handler --- src/Protocol/ChunkDataSerializer.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/Protocol/ChunkDataSerializer.cpp') diff --git a/src/Protocol/ChunkDataSerializer.cpp b/src/Protocol/ChunkDataSerializer.cpp index 9f8b91ac1..d2b8489ea 100644 --- a/src/Protocol/ChunkDataSerializer.cpp +++ b/src/Protocol/ChunkDataSerializer.cpp @@ -503,26 +503,27 @@ 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 - int BitIndex = 0; // The bit-position in Buffer that represents where to write next + unsigned char BitIndex = 0; // The bit-position in Buffer that represents where to write next for (size_t Index = 0; Index != cChunkData::SectionBlockCount; Index++) { 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(Palette(BlockType, BlockMeta)); + const auto Value = Palette(BlockType, BlockMeta); // Write as much as possible of Value, starting from BitIndex, into Buffer: - Buffer |= Value << BitIndex; + Buffer |= static_cast(Value) << BitIndex; // The _signed_ count of bits in Value left to write - if (BitIndex + a_BitsPerEntry >= 64) + const auto Remaining = static_cast(a_BitsPerEntry - (64 - BitIndex)); + if (Remaining >= 0) { // 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 >> (64 - BitIndex); - BitIndex = a_BitsPerEntry - (64 - BitIndex); + Buffer = static_cast(Value >> (a_BitsPerEntry - Remaining)); + BitIndex = static_cast(Remaining); } else { -- cgit v1.2.3