From f2689c4887e6bd66af34de81cd793322f1dd57c4 Mon Sep 17 00:00:00 2001 From: tycho Date: Tue, 19 May 2015 11:50:59 +0100 Subject: Fixed a lot of warnings --- src/Blocks/BlockAnvil.h | 8 ++++---- src/Blocks/BlockButton.h | 2 +- src/Blocks/BlockCocoaPod.h | 4 +++- src/Blocks/BlockHopper.h | 2 +- src/Blocks/BlockLadder.h | 7 ++++++- src/Blocks/BlockLeaves.h | 2 +- src/Blocks/BlockWallSign.h | 12 +++++++----- 7 files changed, 23 insertions(+), 14 deletions(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockAnvil.h b/src/Blocks/BlockAnvil.h index abfa0f782..154394550 100644 --- a/src/Blocks/BlockAnvil.h +++ b/src/Blocks/BlockAnvil.h @@ -46,10 +46,10 @@ public: switch (Direction) { - case 0: a_BlockMeta = 0x2 | Meta << 2; break; - case 1: a_BlockMeta = 0x3 | Meta << 2; break; - case 2: a_BlockMeta = 0x0 | Meta << 2; break; - case 3: a_BlockMeta = 0x1 | Meta << 2; break; + case 0: a_BlockMeta = static_cast(0x2 | Meta << 2); break; + case 1: a_BlockMeta = static_cast(0x3 | Meta << 2); break; + case 2: a_BlockMeta = static_cast(0x0 | Meta << 2); break; + case 3: a_BlockMeta = static_cast(0x1 | Meta << 2); break; default: { return false; diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h index d24c7d952..d65d9722d 100644 --- a/src/Blocks/BlockButton.h +++ b/src/Blocks/BlockButton.h @@ -67,7 +67,7 @@ public: case BLOCK_FACE_XM: return 0x2; case BLOCK_FACE_XP: return 0x1; case BLOCK_FACE_YM: return 0x0; - default: + case BLOCK_FACE_NONE: { ASSERT(!"Unhandled block face!"); return 0x0; diff --git a/src/Blocks/BlockCocoaPod.h b/src/Blocks/BlockCocoaPod.h index 1b659d48f..50552c788 100644 --- a/src/Blocks/BlockCocoaPod.h +++ b/src/Blocks/BlockCocoaPod.h @@ -81,7 +81,9 @@ public: case BLOCK_FACE_XM: return 3; case BLOCK_FACE_XP: return 1; case BLOCK_FACE_ZP: return 2; - default: + case BLOCK_FACE_NONE: + case BLOCK_FACE_YM: + case BLOCK_FACE_YP: { ASSERT(!"Unknown face"); return 0; diff --git a/src/Blocks/BlockHopper.h b/src/Blocks/BlockHopper.h index 4a5d32dd5..06e2b0e9f 100644 --- a/src/Blocks/BlockHopper.h +++ b/src/Blocks/BlockHopper.h @@ -35,7 +35,7 @@ public: case BLOCK_FACE_NORTH: a_BlockMeta = E_META_HOPPER_FACING_ZP; break; case BLOCK_FACE_SOUTH: a_BlockMeta = E_META_HOPPER_FACING_ZM; break; case BLOCK_FACE_WEST: a_BlockMeta = E_META_HOPPER_FACING_XP; break; - default: a_BlockMeta = E_META_HOPPER_UNATTACHED; break; + case BLOCK_FACE_NONE: a_BlockMeta = E_META_HOPPER_UNATTACHED; break; } return true; } diff --git a/src/Blocks/BlockLadder.h b/src/Blocks/BlockLadder.h index ab3f55439..f49f1adc7 100644 --- a/src/Blocks/BlockLadder.h +++ b/src/Blocks/BlockLadder.h @@ -57,7 +57,12 @@ public: case BLOCK_FACE_ZP: return 0x3; case BLOCK_FACE_XM: return 0x4; case BLOCK_FACE_XP: return 0x5; - default: return 0x2; + case BLOCK_FACE_NONE: + case BLOCK_FACE_YM: + case BLOCK_FACE_YP: + { + return 0x2; + } } } diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h index 8e44c94ac..b7b2cc127 100644 --- a/src/Blocks/BlockLeaves.h +++ b/src/Blocks/BlockLeaves.h @@ -47,7 +47,7 @@ public: cItem( E_BLOCK_SAPLING, 1, - (m_BlockType == E_BLOCK_LEAVES) ? (a_BlockMeta & 0x03) : (2 << (a_BlockMeta & 0x01)) + (m_BlockType == E_BLOCK_LEAVES) ? (a_BlockMeta & 0x03) : static_cast(2 << (a_BlockMeta & 0x01)) ) ); } diff --git a/src/Blocks/BlockWallSign.h b/src/Blocks/BlockWallSign.h index b6599d033..9b90b78bf 100644 --- a/src/Blocks/BlockWallSign.h +++ b/src/Blocks/BlockWallSign.h @@ -55,11 +55,13 @@ public: { switch (a_Direction) { - case 0x2: return 0x2; - case 0x3: return 0x3; - case 0x4: return 0x4; - case 0x5: return 0x5; - default: + case BLOCK_FACE_ZM: return 0x2; + case BLOCK_FACE_ZP: return 0x3; + case BLOCK_FACE_XM: return 0x4; + case BLOCK_FACE_XP: return 0x5; + case BLOCK_FACE_NONE: + case BLOCK_FACE_YP: + case BLOCK_FACE_YM: { break; } -- cgit v1.2.3 From fa4fb75e03c6241370588de2ed62270e1043b312 Mon Sep 17 00:00:00 2001 From: tycho Date: Tue, 19 May 2015 12:28:31 +0100 Subject: Fixed compile and a few more warnings --- src/Blocks/BlockLever.h | 14 +++++++------- src/Blocks/BlockQuartz.h | 2 +- src/Blocks/BlockRail.h | 7 ++++++- src/Blocks/BlockSideways.h | 2 +- src/Blocks/BlockTorch.h | 2 +- src/Blocks/BlockTrapdoor.h | 4 +++- src/Blocks/BlockTripwireHook.h | 8 +++++++- 7 files changed, 26 insertions(+), 13 deletions(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h index 2da138e5f..5792d280b 100644 --- a/src/Blocks/BlockLever.h +++ b/src/Blocks/BlockLever.h @@ -59,13 +59,13 @@ public: // Determine lever direction: switch (a_Dir) { - case BLOCK_FACE_YP: return 0x6; - case BLOCK_FACE_XP: return 0x1; - case BLOCK_FACE_XM: return 0x2; - case BLOCK_FACE_ZP: return 0x3; - case BLOCK_FACE_ZM: return 0x4; - case BLOCK_FACE_YM: return 0x0; - default: return 0x6; + case BLOCK_FACE_YP: return 0x6; + case BLOCK_FACE_XP: return 0x1; + case BLOCK_FACE_XM: return 0x2; + case BLOCK_FACE_ZP: return 0x3; + case BLOCK_FACE_ZM: return 0x4; + case BLOCK_FACE_YM: return 0x0; + case BLOCK_FACE_NONE: return 0x6; } } diff --git a/src/Blocks/BlockQuartz.h b/src/Blocks/BlockQuartz.h index edc4fb9c5..6f5c23902 100644 --- a/src/Blocks/BlockQuartz.h +++ b/src/Blocks/BlockQuartz.h @@ -58,7 +58,7 @@ public: return 0x3; // East or west } - default: + case BLOCK_FACE_NONE: { ASSERT(!"Unhandled block face!"); return a_QuartzMeta; // No idea, give a special meta (all sides the same) diff --git a/src/Blocks/BlockRail.h b/src/Blocks/BlockRail.h index a2e27a351..eecd07006 100644 --- a/src/Blocks/BlockRail.h +++ b/src/Blocks/BlockRail.h @@ -487,7 +487,12 @@ public: } break; } - default: break; + case BLOCK_FACE_NONE: + case BLOCK_FACE_YM: + case BLOCK_FACE_YP: + { + break; + } } return true; } diff --git a/src/Blocks/BlockSideways.h b/src/Blocks/BlockSideways.h index 4b1e38d6d..74b05e33c 100644 --- a/src/Blocks/BlockSideways.h +++ b/src/Blocks/BlockSideways.h @@ -58,7 +58,7 @@ public: return a_Meta | 0x4; // East or west } - default: + case BLOCK_FACE_NONE: { ASSERT(!"Unhandled block face!"); return a_Meta | 0xC; // No idea, give a special meta diff --git a/src/Blocks/BlockTorch.h b/src/Blocks/BlockTorch.h index d63df94cf..aaf50d23d 100644 --- a/src/Blocks/BlockTorch.h +++ b/src/Blocks/BlockTorch.h @@ -59,7 +59,7 @@ public: case BLOCK_FACE_WEST: return E_META_TORCH_WEST; case BLOCK_FACE_NORTH: return E_META_TORCH_NORTH; case BLOCK_FACE_SOUTH: return E_META_TORCH_SOUTH; - default: + case BLOCK_FACE_NONE: { ASSERT(!"Unhandled torch direction!"); break; diff --git a/src/Blocks/BlockTrapdoor.h b/src/Blocks/BlockTrapdoor.h index dbb0b5a5b..2841e3e08 100644 --- a/src/Blocks/BlockTrapdoor.h +++ b/src/Blocks/BlockTrapdoor.h @@ -74,7 +74,9 @@ public: case BLOCK_FACE_ZM: return 0x0; case BLOCK_FACE_XP: return 0x3; case BLOCK_FACE_XM: return 0x2; - default: + case BLOCK_FACE_NONE: + case BLOCK_FACE_YM: + case BLOCK_FACE_YP: { ASSERT(!"Unhandled block face!"); return 0; diff --git a/src/Blocks/BlockTripwireHook.h b/src/Blocks/BlockTripwireHook.h index 88d389711..c7a96d393 100644 --- a/src/Blocks/BlockTripwireHook.h +++ b/src/Blocks/BlockTripwireHook.h @@ -37,7 +37,13 @@ public: case BLOCK_FACE_XP: return 0x3; case BLOCK_FACE_ZM: return 0x2; case BLOCK_FACE_ZP: return 0x0; - default: ASSERT(!"Unhandled tripwire hook direction!"); return 0x0; + case BLOCK_FACE_NONE: + case BLOCK_FACE_YM: + case BLOCK_FACE_YP: + { + ASSERT(!"Unhandled tripwire hook direction!"); + return 0x0; + } } } -- cgit v1.2.3 From 77f1f58c0a7eb55001b375f1945690ed5c1e87a2 Mon Sep 17 00:00:00 2001 From: tycho Date: Tue, 19 May 2015 19:32:10 +0100 Subject: Make -Werror disabling file only Ad fix a load of warnings --- src/Blocks/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Blocks') diff --git a/src/Blocks/CMakeLists.txt b/src/Blocks/CMakeLists.txt index ed3e321d4..d7ea6258f 100644 --- a/src/Blocks/CMakeLists.txt +++ b/src/Blocks/CMakeLists.txt @@ -95,6 +95,7 @@ SET (HDRS MetaRotator.h WorldInterface.h) + if(NOT MSVC) add_library(Blocks ${SRCS} ${HDRS}) endif() -- cgit v1.2.3 From dae9e5792a4f030ae9e748548a16a89790fbd311 Mon Sep 17 00:00:00 2001 From: tycho Date: Sun, 24 May 2015 12:56:56 +0100 Subject: Made -Weverything an error. --- src/Blocks/BlockBed.h | 2 +- src/Blocks/BlockDoor.h | 6 +++--- src/Blocks/BlockSlab.h | 4 ++-- src/Blocks/CMakeLists.txt | 4 ++++ 4 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockBed.h b/src/Blocks/BlockBed.h index 46f361686..57ffebfca 100644 --- a/src/Blocks/BlockBed.h +++ b/src/Blocks/BlockBed.h @@ -53,7 +53,7 @@ public: a_Rotation = (a_Rotation / 360) * 4; - return ((char)a_Rotation + 2) % 4; + return (static_cast(a_Rotation + 2)) % 4; } static Vector3i MetaDataToDirection(NIBBLETYPE a_MetaData) diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h index 445383e7c..9332e6728 100644 --- a/src/Blocks/BlockDoor.h +++ b/src/Blocks/BlockDoor.h @@ -245,10 +245,10 @@ public: if (a_BlockX > 0) { NIBBLETYPE DownMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ); - return (NIBBLETYPE) ((DownMeta & 0x07) | 0x08 | (Meta << 4)); + return static_cast((DownMeta & 0x07) | 0x08 | (Meta << 4)); } // This is the top part of the door at the bottommost layer of the world, there's no bottom: - return (NIBBLETYPE) (0x08 | (Meta << 4)); + return static_cast(0x08 | (Meta << 4)); } else { @@ -256,7 +256,7 @@ public: if (a_BlockY < cChunkDef::Height - 1) { NIBBLETYPE UpMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY + 1, a_BlockZ); - return (NIBBLETYPE) (Meta | (UpMeta << 4)); + return static_cast(Meta | (UpMeta << 4)); } // This is the bottom part of the door at the topmost layer of the world, there's no top: return Meta; diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index d762154df..9b3fad72e 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -41,7 +41,7 @@ public: ) override { a_BlockType = m_BlockType; - NIBBLETYPE Meta = (NIBBLETYPE) a_Player->GetEquippedItem().m_ItemDamage; + NIBBLETYPE Meta = static_cast(a_Player->GetEquippedItem().m_ItemDamage); // Set the correct metadata based on player equipped item (i.e. a_BlockMeta not initialised yet) switch (a_BlockFace) @@ -104,7 +104,7 @@ public: virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override { - if ((a_BlockFace == BLOCK_FACE_NONE) || (a_Player->GetEquippedItem().m_ItemType != (short)m_BlockType)) + if ((a_BlockFace == BLOCK_FACE_NONE) || (a_Player->GetEquippedItem().m_ItemType != static_cast(m_BlockType))) { return; } diff --git a/src/Blocks/CMakeLists.txt b/src/Blocks/CMakeLists.txt index d7ea6258f..d8affd9cf 100644 --- a/src/Blocks/CMakeLists.txt +++ b/src/Blocks/CMakeLists.txt @@ -95,6 +95,10 @@ SET (HDRS MetaRotator.h WorldInterface.h) +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set_source_files_properties(BlockHandler.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast") + set_source_files_properties(BlockPiston.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast") +endif() if(NOT MSVC) add_library(Blocks ${SRCS} ${HDRS}) -- cgit v1.2.3 From 48c153bf53d5606e351bd180e2fd9345034f60aa Mon Sep 17 00:00:00 2001 From: Mattes D Date: Tue, 2 Jun 2015 12:51:43 +0200 Subject: Fixed warnings in MSVC. It complained about undefined return values or using uninitialized variables. --- src/Blocks/BlockButton.h | 6 ++++++ src/Blocks/BlockCocoaPod.h | 4 ++++ src/Blocks/BlockLadder.h | 4 ++++ src/Blocks/BlockLever.h | 4 ++++ src/Blocks/BlockQuartz.h | 5 +++++ src/Blocks/BlockSideways.h | 4 ++++ src/Blocks/BlockTrapdoor.h | 7 +++++++ src/Blocks/BlockTripwireHook.h | 8 ++++++++ 8 files changed, 42 insertions(+) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h index d65d9722d..154cd610e 100644 --- a/src/Blocks/BlockButton.h +++ b/src/Blocks/BlockButton.h @@ -73,8 +73,13 @@ public: return 0x0; } } + #if !defined(__clang__) + ASSERT(!"Unknown BLOCK_FACE"); + return 0; + #endif } + inline static eBlockFace BlockMetaDataToBlockFace(NIBBLETYPE a_Meta) { switch (a_Meta & 0x7) @@ -93,6 +98,7 @@ public: } } + virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { NIBBLETYPE Meta; diff --git a/src/Blocks/BlockCocoaPod.h b/src/Blocks/BlockCocoaPod.h index 50552c788..4d16d2552 100644 --- a/src/Blocks/BlockCocoaPod.h +++ b/src/Blocks/BlockCocoaPod.h @@ -89,6 +89,10 @@ public: return 0; } } + #if !defined(__clang__) + ASSERT(!"Unknown BLOCK_FACE"); + return 0; + #endif } } ; diff --git a/src/Blocks/BlockLadder.h b/src/Blocks/BlockLadder.h index f49f1adc7..d727f8f8e 100644 --- a/src/Blocks/BlockLadder.h +++ b/src/Blocks/BlockLadder.h @@ -64,6 +64,10 @@ public: return 0x2; } } + #if !defined(__clang__) + ASSERT(!"Unknown BLOCK_FACE"); + return 0; + #endif } diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h index 5792d280b..8d676b56f 100644 --- a/src/Blocks/BlockLever.h +++ b/src/Blocks/BlockLever.h @@ -67,6 +67,10 @@ public: case BLOCK_FACE_YM: return 0x0; case BLOCK_FACE_NONE: return 0x6; } + #if !defined(__clang__) + ASSERT(!"Unknown BLOCK_FACE"); + return 0; + #endif } diff --git a/src/Blocks/BlockQuartz.h b/src/Blocks/BlockQuartz.h index 6f5c23902..b936a7e4a 100644 --- a/src/Blocks/BlockQuartz.h +++ b/src/Blocks/BlockQuartz.h @@ -36,6 +36,7 @@ public: return true; } + inline static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_BlockFace, NIBBLETYPE a_QuartzMeta) { switch (a_BlockFace) @@ -64,5 +65,9 @@ public: return a_QuartzMeta; // No idea, give a special meta (all sides the same) } } + #if !defined(__clang__) + ASSERT(!"Unknown BLOCK_FACE"); + return 0; + #endif } } ; diff --git a/src/Blocks/BlockSideways.h b/src/Blocks/BlockSideways.h index 74b05e33c..e52fbaa2f 100644 --- a/src/Blocks/BlockSideways.h +++ b/src/Blocks/BlockSideways.h @@ -64,6 +64,10 @@ public: return a_Meta | 0xC; // No idea, give a special meta } } + #if !defined(__clang__) + ASSERT(!"Unknown BLOCK_FACE"); + return 0; + #endif } } ; diff --git a/src/Blocks/BlockTrapdoor.h b/src/Blocks/BlockTrapdoor.h index 2841e3e08..a1d2dff6f 100644 --- a/src/Blocks/BlockTrapdoor.h +++ b/src/Blocks/BlockTrapdoor.h @@ -66,6 +66,7 @@ public: return true; } + inline static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_BlockFace) { switch (a_BlockFace) @@ -82,8 +83,13 @@ public: return 0; } } + #if !defined(__clang__) + ASSERT(!"Unknown BLOCK_FACE"); + return 0; + #endif } + inline static eBlockFace BlockMetaDataToBlockFace(NIBBLETYPE a_Meta) { switch (a_Meta & 0x3) @@ -100,6 +106,7 @@ public: } } + virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { NIBBLETYPE Meta; diff --git a/src/Blocks/BlockTripwireHook.h b/src/Blocks/BlockTripwireHook.h index c7a96d393..39892af5a 100644 --- a/src/Blocks/BlockTripwireHook.h +++ b/src/Blocks/BlockTripwireHook.h @@ -16,6 +16,7 @@ public: { } + virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, @@ -29,6 +30,7 @@ public: return true; } + inline static NIBBLETYPE DirectionToMetadata(eBlockFace a_Direction) { switch (a_Direction) @@ -45,8 +47,13 @@ public: return 0x0; } } + #if !defined(__clang__) + ASSERT(!"Unknown BLOCK_FACE"); + return 0; + #endif } + inline static eBlockFace MetadataToDirection(NIBBLETYPE a_Meta) { switch (a_Meta & 0x03) @@ -59,6 +66,7 @@ public: } } + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { // Reset meta to zero -- cgit v1.2.3