From d98e2bdaa3903de29f62791c05472a693b0ea36b Mon Sep 17 00:00:00 2001 From: hle0 <91701075+hle0@users.noreply.github.com> Date: Sat, 26 Mar 2022 17:10:30 -0400 Subject: fix various compiler warnings (and some unwanted case statement fallthroughs) --- src/Bindings/LuaServerHandle.cpp | 2 +- src/ByteBuffer.cpp | 2 +- src/Entities/Pawn.cpp | 2 +- src/Entities/Player.cpp | 4 ++-- src/FurnaceRecipe.cpp | 2 +- src/Protocol/Protocol_1_8.cpp | 3 +++ src/Server.cpp | 2 +- src/Simulator/SandSimulator.cpp | 2 +- src/StringCompression.cpp | 4 ++-- 9 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/Bindings/LuaServerHandle.cpp b/src/Bindings/LuaServerHandle.cpp index 1162d87c0..c07cd0a82 100644 --- a/src/Bindings/LuaServerHandle.cpp +++ b/src/Bindings/LuaServerHandle.cpp @@ -143,7 +143,7 @@ cTCPLink::cCallbacksPtr cLuaServerHandle::OnIncomingConnection(const AString & a cCSLock Lock(m_CSConnections); m_Connections.push_back(res); - return std::move(res); + return res; } diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp index 1974e1211..ce9df77cc 100644 --- a/src/ByteBuffer.cpp +++ b/src/ByteBuffer.cpp @@ -538,7 +538,7 @@ bool cByteBuffer::ReadUUID(cUUID & a_Value) { CHECK_THREAD - std::array UUIDBuf; + std::array UUIDBuf = {0}; if (!ReadBuf(UUIDBuf.data(), UUIDBuf.size())) { return false; diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index 760c9c0e6..361450349 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -320,7 +320,7 @@ void cPawn::HandleFalling(void) With this in mind, we first check the block at the player's feet, then the one below that (because fences), and decide which behaviour we want to go with. */ - BLOCKTYPE BlockAtFoot = (cChunkDef::IsValidHeight(POSY_TOINT)) ? GetWorld()->GetBlock(POS_TOINT) : E_BLOCK_AIR; + BLOCKTYPE BlockAtFoot = (cChunkDef::IsValidHeight(POSY_TOINT)) ? GetWorld()->GetBlock(POS_TOINT) : static_cast(E_BLOCK_AIR); /* We initialize these with what the foot is really IN, because for sampling we will move down with the epsilon above */ bool IsFootInWater = IsBlockWater(BlockAtFoot); diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 3fd2aac48..c2c3b51ea 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -2377,8 +2377,8 @@ bool cPlayer::DoesPlacingBlocksIntersectEntity(const std::initializer_listGetBlock({ x - 1, y, z }), m_World->GetBlock({ x + 1, y, z }), - (y == 0) ? E_BLOCK_AIR : m_World->GetBlock({ x, y - 1, z }), - (y == cChunkDef::Height - 1) ? E_BLOCK_AIR : m_World->GetBlock({ x, y + 1, z }), + (y == 0) ? static_cast(E_BLOCK_AIR) : m_World->GetBlock({ x, y - 1, z }), + (y == cChunkDef::Height - 1) ? static_cast(E_BLOCK_AIR) : m_World->GetBlock({ x, y + 1, z }), m_World->GetBlock({ x, y, z - 1 }), m_World->GetBlock({ x, y, z + 1 }) ); diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp index 621a47a31..7960523b2 100644 --- a/src/FurnaceRecipe.cpp +++ b/src/FurnaceRecipe.cpp @@ -73,7 +73,7 @@ void cFurnaceRecipe::ReloadRecipes(void) size_t FirstCommentSymbol = ParsingLine.find('#'); if ((FirstCommentSymbol != AString::npos) && (FirstCommentSymbol != 0)) { - ParsingLine.erase(ParsingLine.begin() + static_cast(FirstCommentSymbol), ParsingLine.end()); + ParsingLine.erase(ParsingLine.begin() + static_cast(FirstCommentSymbol), ParsingLine.end()); } if (IsOnlyWhitespace(ParsingLine)) diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp index 69fe40b9b..a84dadf53 100644 --- a/src/Protocol/Protocol_1_8.cpp +++ b/src/Protocol/Protocol_1_8.cpp @@ -2972,6 +2972,7 @@ void cProtocol_1_8_0::ParseItemMetadata(cItem & a_Item, const ContiguousByteBuff { a_Item.m_RepairCost = NBT.GetInt(tag); } + break; } default: LOGD("Unimplemented NBT data when parsing!"); break; } @@ -3940,6 +3941,8 @@ UInt8 cProtocol_1_8_0::GetProtocolEntityType(const cEntity & a_Entity) case PType::pkFirework: return 76; case PType::pkWitherSkull: return 66; } + + break; } case Type::etFloater: return 90; case Type::etItemFrame: return 71; diff --git a/src/Server.cpp b/src/Server.cpp index d70164316..880ed6c72 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -321,7 +321,7 @@ cTCPLink::cCallbacksPtr cServer::OnConnectionAccepted(const AString & a_RemoteIP cClientHandlePtr NewHandle = std::make_shared(a_RemoteIPAddress, m_ClientViewDistance); cCSLock Lock(m_CSClients); m_Clients.push_back(NewHandle); - return std::move(NewHandle); + return NewHandle; } diff --git a/src/Simulator/SandSimulator.cpp b/src/Simulator/SandSimulator.cpp index 8b0d1be7f..13bc6bb36 100644 --- a/src/Simulator/SandSimulator.cpp +++ b/src/Simulator/SandSimulator.cpp @@ -43,7 +43,7 @@ void cSandSimulator::SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, continue; } - BLOCKTYPE BlockBelow = (itr->y > 0) ? a_Chunk->GetBlock(itr->x, itr->y - 1, itr->z) : E_BLOCK_AIR; + BLOCKTYPE BlockBelow = (itr->y > 0) ? a_Chunk->GetBlock(itr->x, itr->y - 1, itr->z) : static_cast(E_BLOCK_AIR); if (CanStartFallingThrough(BlockBelow)) { if (m_IsInstantFall) diff --git a/src/StringCompression.cpp b/src/StringCompression.cpp index 6678fe1bd..d82f45987 100644 --- a/src/StringCompression.cpp +++ b/src/StringCompression.cpp @@ -76,7 +76,7 @@ Compression::Result Compression::Compressor::Compress(const void * const Input, { // First see if the stack buffer has enough space: { - Result::Static Buffer; + Result::Static Buffer = {static_cast(0)}; const auto BytesWrittenOut = Algorithm(m_Handle, Input, Size, Buffer.data(), Buffer.size()); if (BytesWrittenOut != 0) @@ -189,7 +189,7 @@ Compression::Result Compression::Extractor::Extract(const ContiguousByteBufferVi { // First see if the stack buffer has enough space: { - Result::Static Buffer; + Result::Static Buffer = {static_cast(0)}; size_t BytesWrittenOut; switch (Algorithm(m_Handle, Input.data(), Input.size(), Buffer.data(), Buffer.size(), &BytesWrittenOut)) -- cgit v1.2.3