From 1632d5f8f1f3f1edb7ac2d0f4c79be9fbdae91ca Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 18 May 2015 15:43:24 +0100 Subject: Fixes #2003 --- src/UI/SlotArea.cpp | 2 +- src/UI/Window.cpp | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'src/UI') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 37683a8e5..accd44b06 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -1394,7 +1394,7 @@ void cSlotAreaBeacon::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) // cSlotAreaEnchanting: cSlotAreaEnchanting::cSlotAreaEnchanting(cWindow & a_ParentWindow, int a_BlockX, int a_BlockY, int a_BlockZ) : - cSlotAreaTemporary(1, a_ParentWindow), + cSlotAreaTemporary(2, a_ParentWindow), m_BlockX(a_BlockX), m_BlockY(a_BlockY), m_BlockZ(a_BlockZ) diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index d1c08acec..61e25651b 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -92,9 +92,9 @@ const AString cWindow::GetWindowTypeName(void) const int cWindow::GetNumSlots(void) const { int res = 0; - for (cSlotAreas::const_iterator itr = m_SlotAreas.begin(), end = m_SlotAreas.end(); itr != end; ++itr) + for (const auto & itr : m_SlotAreas) { - res += (*itr)->GetNumSlots(); + res += itr->GetNumSlots(); } // for itr - m_SlotAreas[] return res; } @@ -261,16 +261,14 @@ void cWindow::Clicked( } int LocalSlotNum = a_SlotNum; - int idx = 0; - for (cSlotAreas::iterator itr = m_SlotAreas.begin(), end = m_SlotAreas.end(); itr != end; ++itr) + for (const auto & itr : m_SlotAreas) { - if (LocalSlotNum < (*itr)->GetNumSlots()) + if (LocalSlotNum < itr->GetNumSlots()) { - (*itr)->Clicked(a_Player, LocalSlotNum, a_ClickAction, a_ClickedItem); + itr->Clicked(a_Player, LocalSlotNum, a_ClickAction, a_ClickedItem); return; } - LocalSlotNum -= (*itr)->GetNumSlots(); - idx++; + LocalSlotNum -= itr->GetNumSlots(); } LOGWARNING("Slot number higher than available window slots: %d, max %d received from \"%s\"; ignoring.", -- 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/UI/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/UI') diff --git a/src/UI/CMakeLists.txt b/src/UI/CMakeLists.txt index ef4afc40a..e01a09bb8 100644 --- a/src/UI/CMakeLists.txt +++ b/src/UI/CMakeLists.txt @@ -34,6 +34,11 @@ SET (HDRS MinecartWithChestWindow.h WindowOwner.h) +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set_source_files_properties(SlotArea.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion -Wno-error=switch-enum -Wno-error=sign-conversion") + set_source_files_properties(Window.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion -Wno-error=switch-enum -Wno-error=sign-conversion") +endif() + if(NOT MSVC) add_library(UI ${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/UI/CMakeLists.txt | 5 +++-- src/UI/EnchantingWindow.cpp | 6 +++--- src/UI/EnderChestWindow.cpp | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 7 deletions(-) (limited to 'src/UI') diff --git a/src/UI/CMakeLists.txt b/src/UI/CMakeLists.txt index e01a09bb8..178498479 100644 --- a/src/UI/CMakeLists.txt +++ b/src/UI/CMakeLists.txt @@ -35,8 +35,9 @@ SET (HDRS WindowOwner.h) if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set_source_files_properties(SlotArea.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion -Wno-error=switch-enum -Wno-error=sign-conversion") - set_source_files_properties(Window.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion -Wno-error=switch-enum -Wno-error=sign-conversion") + set_source_files_properties(SlotArea.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion -Wno-error=switch-enum -Wno-error=sign-conversion -Wno-error=old-style-cast") + set_source_files_properties(Window.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion -Wno-error=switch-enum -Wno-error=sign-conversion -Wno-error=old-style-cast") + set_source_files_properties(ChestWindow.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast") endif() if(NOT MSVC) diff --git a/src/UI/EnchantingWindow.cpp b/src/UI/EnchantingWindow.cpp index fe21ee83d..4c5bcbfd5 100644 --- a/src/UI/EnchantingWindow.cpp +++ b/src/UI/EnchantingWindow.cpp @@ -30,7 +30,7 @@ cEnchantingWindow::cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : void cEnchantingWindow::SetProperty(short a_Property, short a_Value, cPlayer & a_Player) { - if ((a_Property < 0) || ((size_t)a_Property >= ARRAYCOUNT(m_PropertyValue))) + if ((a_Property < 0) || (static_cast(a_Property) >= ARRAYCOUNT(m_PropertyValue))) { ASSERT(!"a_Property is invalid"); return; @@ -47,7 +47,7 @@ void cEnchantingWindow::SetProperty(short a_Property, short a_Value, cPlayer & a void cEnchantingWindow::SetProperty(short a_Property, short a_Value) { - if ((a_Property < 0) || ((size_t)a_Property >= ARRAYCOUNT(m_PropertyValue))) + if ((a_Property < 0) || (static_cast(a_Property) >= ARRAYCOUNT(m_PropertyValue))) { ASSERT(!"a_Property is invalid"); return; @@ -63,7 +63,7 @@ void cEnchantingWindow::SetProperty(short a_Property, short a_Value) short cEnchantingWindow::GetPropertyValue(short a_Property) { - if ((a_Property < 0) || ((size_t)a_Property >= ARRAYCOUNT(m_PropertyValue))) + if ((a_Property < 0) || (static_cast(a_Property) >= ARRAYCOUNT(m_PropertyValue))) { ASSERT(!"a_Property is invalid"); return 0; diff --git a/src/UI/EnderChestWindow.cpp b/src/UI/EnderChestWindow.cpp index a5484468f..9a4918aa4 100644 --- a/src/UI/EnderChestWindow.cpp +++ b/src/UI/EnderChestWindow.cpp @@ -24,7 +24,12 @@ cEnderChestWindow::cEnderChestWindow(cEnderChestEntity * a_EnderChest) : m_SlotAreas.push_back(new cSlotAreaHotBar(*this)); // Play the opening sound: - m_World->BroadcastSoundEffect("random.chestopen", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1); + m_World->BroadcastSoundEffect( + "random.chestopen", + static_cast(m_BlockX), + static_cast(m_BlockY), + static_cast(m_BlockZ), + 1, 1); // Send out the chest-open packet: m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, E_BLOCK_ENDER_CHEST); @@ -40,7 +45,12 @@ cEnderChestWindow::~cEnderChestWindow() m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, E_BLOCK_ENDER_CHEST); // Play the closing sound - m_World->BroadcastSoundEffect("random.chestclosed", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1); + m_World->BroadcastSoundEffect( + "random.chestclosed", + static_cast(m_BlockX), + static_cast(m_BlockY), + static_cast(m_BlockZ), + 1, 1); } -- cgit v1.2.3 From 10c9e66aad9a0d994c5c227f5dedec4af19db9b2 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 24 May 2015 13:37:36 +0100 Subject: Fixes #2041 --- src/UI/SlotArea.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/UI') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index accd44b06..5b58b18b6 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -2154,10 +2154,10 @@ bool cSlotAreaArmor::CanPlaceArmorInSlot(int a_SlotNum, const cItem & a_Item) { switch (a_SlotNum) { - case 0: return ItemCategory::IsHelmet (a_Item.m_ItemType); + case 0: return (ItemCategory::IsHelmet(a_Item.m_ItemType) || (a_Item.m_ItemType == E_BLOCK_PUMPKIN)); case 1: return ItemCategory::IsChestPlate(a_Item.m_ItemType); - case 2: return ItemCategory::IsLeggings (a_Item.m_ItemType); - case 3: return ItemCategory::IsBoots (a_Item.m_ItemType); + case 2: return ItemCategory::IsLeggings(a_Item.m_ItemType); + case 3: return ItemCategory::IsBoots(a_Item.m_ItemType); } return false; } -- cgit v1.2.3 From b2fa71a32ac8bd86bda778a5d54fe2e7e471a1c0 Mon Sep 17 00:00:00 2001 From: tycho Date: Thu, 28 May 2015 12:29:26 +0100 Subject: Fix comments --- src/UI/EnderChestWindow.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/UI') diff --git a/src/UI/EnderChestWindow.cpp b/src/UI/EnderChestWindow.cpp index 9a4918aa4..c597f3a9b 100644 --- a/src/UI/EnderChestWindow.cpp +++ b/src/UI/EnderChestWindow.cpp @@ -29,7 +29,9 @@ cEnderChestWindow::cEnderChestWindow(cEnderChestEntity * a_EnderChest) : static_cast(m_BlockX), static_cast(m_BlockY), static_cast(m_BlockZ), - 1, 1); + 1, + 1 + ); // Send out the chest-open packet: m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, E_BLOCK_ENDER_CHEST); @@ -46,11 +48,12 @@ cEnderChestWindow::~cEnderChestWindow() // Play the closing sound m_World->BroadcastSoundEffect( - "random.chestclosed", - static_cast(m_BlockX), - static_cast(m_BlockY), - static_cast(m_BlockZ), - 1, 1); + "random.chestclosed", + static_cast(m_BlockX), + static_cast(m_BlockY), + static_cast(m_BlockZ), + 1, 1 + ); } -- cgit v1.2.3