summaryrefslogtreecommitdiffstats
path: root/src/UI
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2020-10-05 12:27:14 +0200
committerGitHub <noreply@github.com>2020-10-05 12:27:14 +0200
commita9031b6bae742b333b1b390192fa590f2ecb07ea (patch)
treeb2802c81d24d339c201a0747d66ba44e9ea8b1b0 /src/UI
parentFixed current end generator (#4968) (diff)
downloadcuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar
cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar.gz
cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar.bz2
cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar.lz
cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar.xz
cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar.zst
cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.zip
Diffstat (limited to 'src/UI')
-rw-r--r--src/UI/SlotArea.cpp18
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: