diff options
Diffstat (limited to 'src/UI')
-rw-r--r-- | src/UI/SlotArea.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 53d406e65..a452227f8 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -1684,18 +1684,18 @@ void cSlotAreaEnchanting::UpdateResult(cPlayer & a_Player) } // Pseudocode found at: https://minecraft.gamepedia.com/Enchanting_mechanics - const auto Bookshelves = std::min(GetBookshelvesCount(*a_Player.GetWorld()), 15U); + const auto Bookshelves = std::min(static_cast<int>(GetBookshelvesCount(*a_Player.GetWorld())), 15); // 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(1U, 8U) + (Bookshelves / 2) + Random.RandInt(0U, Bookshelves)); - const std::array<unsigned int, 3> OptionLevels + const auto Base = (Random.RandInt(1, 8) + (Bookshelves / 2) + Random.RandInt(0, Bookshelves)); + const std::array<short, 3> OptionLevels { - std::max(Base / 3, 1U), - (Base * 2) / 3 + 1, - std::max(Base, Bookshelves * 2) + static_cast<short>(std::max(Base / 3, 1)), + static_cast<short>((Base * 2) / 3 + 1), + static_cast<short>(std::max(Base, Bookshelves * 2)) }; // Properties set according to: https://wiki.vg/Protocol#Window_Property @@ -1714,16 +1714,16 @@ 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, static_cast<short>(OptionLevels[i])); + m_ParentWindow.SetProperty(i, OptionLevels[i]); // Get the first enchantment ID, which must exist: ASSERT(EnchantedItem.m_Enchantments.begin() != EnchantedItem.m_Enchantments.end()); - const short EnchantmentID = static_cast<short>(EnchantedItem.m_Enchantments.begin()->first); + const auto EnchantmentID = static_cast<short>(EnchantedItem.m_Enchantments.begin()->first); // Send the enchantment ID of the first enchantment on our item: m_ParentWindow.SetProperty(4 + i, EnchantmentID); - const short EnchantmentLevel = static_cast<short>(EnchantedItem.m_Enchantments.GetLevel(EnchantmentID)); + const auto EnchantmentLevel = static_cast<short>(EnchantedItem.m_Enchantments.GetLevel(EnchantmentID)); ASSERT(EnchantmentLevel > 0); // Send the level for the first enchantment on our item: |