diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2020-12-20 03:13:34 +0100 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2020-12-21 14:52:06 +0100 |
commit | d9cd2f741dd3c134aa86e52495cf5b7643ce196c (patch) | |
tree | 7864c7d467501abf7cd10ceb7aa8cafa67ddd556 /src/UI/SlotArea.cpp | |
parent | Remove unused Temporary namespace (diff) | |
download | cuberite-d9cd2f741dd3c134aa86e52495cf5b7643ce196c.tar cuberite-d9cd2f741dd3c134aa86e52495cf5b7643ce196c.tar.gz cuberite-d9cd2f741dd3c134aa86e52495cf5b7643ce196c.tar.bz2 cuberite-d9cd2f741dd3c134aa86e52495cf5b7643ce196c.tar.lz cuberite-d9cd2f741dd3c134aa86e52495cf5b7643ce196c.tar.xz cuberite-d9cd2f741dd3c134aa86e52495cf5b7643ce196c.tar.zst cuberite-d9cd2f741dd3c134aa86e52495cf5b7643ce196c.zip |
Diffstat (limited to '')
-rw-r--r-- | src/UI/SlotArea.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index c15a34714..98782800b 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -1130,7 +1130,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) const cItem Target(*GetSlot(0, a_Player)); const cItem Sacrifice(*GetSlot(1, a_Player)); - // Output initialised as copy of target + // Output initialised as copy of target. cItem Output(Target); if (Target.IsEmpty()) @@ -1148,9 +1148,8 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) int NeedExp = 0; if (!Sacrifice.IsEmpty()) { - bool IsEnchantBook = (Sacrifice.m_ItemType == E_ITEM_ENCHANTED_BOOK); - RepairCost += Sacrifice.m_RepairCost; + // Can we repair with sacrifce material? if (Target.IsDamageable() && cItemHandler::GetItemHandler(Target)->CanRepairWithRawMaterial(Sacrifice.m_ItemType)) { @@ -1166,8 +1165,9 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) return; } - int NumItemsConsumed = 0; - // Repair until out of materials, or fully repaired + char NumItemsConsumed = 0; + + // Repair until out of materials, or fully repaired: while ((DamageDiff > 0) && (NumItemsConsumed < Sacrifice.m_ItemCount)) { Output.m_ItemDamage -= DamageDiff; @@ -1176,10 +1176,12 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) ++NumItemsConsumed; } - m_StackSizeToBeUsedInRepair = static_cast<char>(NumItemsConsumed); + m_StackSizeToBeUsedInRepair = NumItemsConsumed; } else // Combining tools / armour { + const bool IsEnchantBook = (Sacrifice.m_ItemType == E_ITEM_ENCHANTED_BOOK); + // No result if we can't combine the items if (!IsEnchantBook && (!Target.IsSameType(Sacrifice) || !Target.IsDamageable())) { @@ -1197,7 +1199,8 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) // Durability = MaxDamage - m_ItemDamage = how far from broken const short TargetDurability = Target.GetMaxDamage() - Target.m_ItemDamage; const short SacrificeDurability = Sacrifice.GetMaxDamage() - Sacrifice.m_ItemDamage; - // How much durability to repair by: + + // How much durability to repair by. const short RepairDurability = SacrificeDurability + Target.GetMaxDamage() * 12 / 100; // Don't give item a negative damage: @@ -1270,7 +1273,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) Output.m_RepairCost = RepairCost; } - // If after everything, output will be the same then no point enchanting + // If after everything, output will be the same then no point enchanting: if (Target.IsEqual(Output)) { Output.Empty(); |