1
0

Fix cmake not adding Werror on clang, and _lots_ of warnings (#4963)

* Fix cmake not adding Werror on clang, and _lots_ of warnings

* WIP: Build fixes

* Cannot make intermediate blockhandler instance

* Tiger's changes

* Fix BitIndex check

* Handle invalid NextState values in cMultiVersionProtocol

Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
This commit is contained in:
peterbell10
2020-10-05 11:27:14 +01:00
committed by GitHub
parent 23021dd828
commit a9031b6bae
144 changed files with 886 additions and 862 deletions

View File

@@ -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: