From d3c1c626f569e5aa58085425924cca45927b6199 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Sun, 4 Feb 2018 23:07:12 +0000 Subject: Deal with covered switches consistently (#4161) * Fixes a number of ": not all control paths return a value" warnings on MSVC. * Introduces the UNREACHABLE global macro and uses it instead of conditionally compiled switch defaults. * Move cNBTParseErrorCategory from FastNBT.h into FastNBT.cpp to prevent bad calls to message() --- src/Generating/MineShafts.cpp | 45 ++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 24 deletions(-) (limited to 'src/Generating/MineShafts.cpp') diff --git a/src/Generating/MineShafts.cpp b/src/Generating/MineShafts.cpp index 755fa23a3..5a9fd6368 100644 --- a/src/Generating/MineShafts.cpp +++ b/src/Generating/MineShafts.cpp @@ -767,33 +767,30 @@ void cMineShaftCorridor::PlaceChest(cChunkDesc & a_ChunkDesc) int BlockZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width; int x, z; NIBBLETYPE Meta = 0; - switch (m_Direction) + [&] { - case dirXM: - case dirXP: + switch (m_Direction) { - x = m_BoundingBox.p1.x + m_ChestPosition - BlockX; - z = m_BoundingBox.p1.z - BlockZ; - Meta = E_META_CHEST_FACING_ZP; - break; - } + case dirXM: + case dirXP: + { + x = m_BoundingBox.p1.x + m_ChestPosition - BlockX; + z = m_BoundingBox.p1.z - BlockZ; + Meta = E_META_CHEST_FACING_ZP; + return; + } - case dirZM: - case dirZP: - { - x = m_BoundingBox.p1.x - BlockX; - z = m_BoundingBox.p1.z + m_ChestPosition - BlockZ; - Meta = E_META_CHEST_FACING_XP; - break; - } - #if !defined(__clang__) - default: - { - ASSERT(!"Unknown direction"); - return; - } - #endif - } // switch (Dir) + case dirZM: + case dirZP: + { + x = m_BoundingBox.p1.x - BlockX; + z = m_BoundingBox.p1.z + m_ChestPosition - BlockZ; + Meta = E_META_CHEST_FACING_XP; + return; + } + } // switch (Dir) + UNREACHABLE("Unsupported corridor direction"); + }(); if ( (x >= 0) && (x < cChunkDef::Width) && -- cgit v1.2.3