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/UI/SlotArea.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/UI/SlotArea.cpp') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index c6c06b084..c15a34714 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -1698,18 +1698,18 @@ void cSlotAreaEnchanting::UpdateResult(cPlayer & a_Player) } // Pseudocode found at: https://minecraft.gamepedia.com/Enchanting_mechanics - const auto Bookshelves = std::min(static_cast(GetBookshelvesCount(*a_Player.GetWorld())), 15); + const auto Bookshelves = std::min(GetBookshelvesCount(*a_Player.GetWorld()), 15U); // A PRNG initialised using the player's enchantment seed. auto Random = a_Player.GetEnchantmentRandomProvider(); // Calculate the levels for the offered enchantment options: - const auto Base = (Random.RandInt(1, 8) + (Bookshelves / 2) + Random.RandInt(0, Bookshelves)); - const std::array OptionLevels + const auto Base = (Random.RandInt(1U, 8U) + (Bookshelves / 2) + Random.RandInt(0U, Bookshelves)); + const std::array OptionLevels { - static_cast(std::max(Base / 3, 1)), - static_cast((Base * 2) / 3 + 1), - static_cast(std::max(Base, Bookshelves * 2)) + std::max(Base / 3, 1U), + (Base * 2) / 3 + 1, + std::max(Base, Bookshelves * 2) }; // Properties set according to: https://wiki.vg/Protocol#Window_Property @@ -1728,7 +1728,7 @@ void cSlotAreaEnchanting::UpdateResult(cPlayer & a_Player) LOGD("Generated enchanted item %d with enchantments: %s", i, EnchantedItem.m_Enchantments.ToString()); // Send the level requirement for the enchantment option: - m_ParentWindow.SetProperty(i, OptionLevels[i]); + m_ParentWindow.SetProperty(i, static_cast(OptionLevels[i])); // Get the first enchantment ID, which must exist: ASSERT(EnchantedItem.m_Enchantments.begin() != EnchantedItem.m_Enchantments.end()); -- cgit v1.2.3