summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Enchantments.cpp2
-rw-r--r--src/Enchantments.h2
-rw-r--r--src/Items/ItemArmor.h12
-rw-r--r--src/Items/ItemHandler.cpp2
-rw-r--r--src/Items/ItemHandler.h2
-rw-r--r--src/Items/ItemPickaxe.h12
-rw-r--r--src/Items/ItemShovel.h12
-rw-r--r--src/Items/ItemSword.h12
-rw-r--r--src/UI/SlotArea.cpp11
9 files changed, 33 insertions, 34 deletions
diff --git a/src/Enchantments.cpp b/src/Enchantments.cpp
index 58479d729..264878c22 100644
--- a/src/Enchantments.cpp
+++ b/src/Enchantments.cpp
@@ -83,7 +83,7 @@ void cEnchantments::AddFromString(const AString & a_StringSpec)
-size_t cEnchantments::Size(void)
+size_t cEnchantments::Count(void)
{
return m_Enchantments.size();
}
diff --git a/src/Enchantments.h b/src/Enchantments.h
index 6793aca36..85a316414 100644
--- a/src/Enchantments.h
+++ b/src/Enchantments.h
@@ -85,7 +85,7 @@ public:
void AddFromString(const AString & a_StringSpec);
/** Get the count of enchantments */
- size_t Size(void);
+ size_t Count(void);
/** Serializes all the enchantments into a string */
AString ToString(void) const;
diff --git a/src/Items/ItemArmor.h b/src/Items/ItemArmor.h
index f53100bb1..2436df5bd 100644
--- a/src/Items/ItemArmor.h
+++ b/src/Items/ItemArmor.h
@@ -60,7 +60,7 @@ public:
return true;
}
- virtual bool CanRepairWithItem(const cItem & a_Item) override
+ virtual bool CanRepairWithRawMaterial(short a_ItemType) override
{
switch (m_ItemType)
{
@@ -69,35 +69,35 @@ public:
case E_ITEM_CHAIN_HELMET:
case E_ITEM_CHAIN_LEGGINGS:
{
- return (a_Item.m_ItemType == E_ITEM_IRON);
+ return (a_ItemType == E_ITEM_IRON);
}
case E_ITEM_DIAMOND_BOOTS:
case E_ITEM_DIAMOND_CHESTPLATE:
case E_ITEM_DIAMOND_HELMET:
case E_ITEM_DIAMOND_LEGGINGS:
{
- return (a_Item.m_ItemType == E_ITEM_DIAMOND);
+ return (a_ItemType == E_ITEM_DIAMOND);
}
case E_ITEM_IRON_BOOTS:
case E_ITEM_IRON_CHESTPLATE:
case E_ITEM_IRON_HELMET:
case E_ITEM_IRON_LEGGINGS:
{
- return (a_Item.m_ItemType == E_ITEM_IRON);
+ return (a_ItemType == E_ITEM_IRON);
}
case E_ITEM_GOLD_BOOTS:
case E_ITEM_GOLD_CHESTPLATE:
case E_ITEM_GOLD_HELMET:
case E_ITEM_GOLD_LEGGINGS:
{
- return (a_Item.m_ItemType == E_ITEM_GOLD);
+ return (a_ItemType == E_ITEM_GOLD);
}
case E_ITEM_LEATHER_BOOTS:
case E_ITEM_LEATHER_CAP:
case E_ITEM_LEATHER_PANTS:
case E_ITEM_LEATHER_TUNIC:
{
- return (a_Item.m_ItemType == E_ITEM_LEATHER);
+ return (a_ItemType == E_ITEM_LEATHER);
}
}
return false;
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index 105def2ce..5cc5b66a0 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -512,7 +512,7 @@ bool cItemHandler::IsPlaceable(void)
-bool cItemHandler::CanRepairWithItem(const cItem & a_Item)
+bool cItemHandler::CanRepairWithRawMaterial(short a_ItemType)
{
return false;
}
diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h
index 420eefcf1..ca090eb29 100644
--- a/src/Items/ItemHandler.h
+++ b/src/Items/ItemHandler.h
@@ -86,7 +86,7 @@ public:
virtual bool IsPlaceable(void);
/** Can the anvil repair this item, when a_Item is the second input? */
- virtual bool CanRepairWithItem(const cItem & a_Item);
+ virtual bool CanRepairWithRawMaterial(short a_ItemType);
/** Get the repair cost from the item, or 0 if the item hasn't repair cost. */
virtual int GetRepairCost(void);
diff --git a/src/Items/ItemPickaxe.h b/src/Items/ItemPickaxe.h
index 46e68ec70..ff2c2069b 100644
--- a/src/Items/ItemPickaxe.h
+++ b/src/Items/ItemPickaxe.h
@@ -86,15 +86,15 @@ public:
return false;
}
- virtual bool CanRepairWithItem(const cItem & a_Item) override
+ virtual bool CanRepairWithRawMaterial(short a_ItemType) override
{
switch (m_ItemType)
{
- case E_ITEM_WOODEN_PICKAXE: return (a_Item.m_ItemType == E_BLOCK_PLANKS);
- case E_ITEM_STONE_PICKAXE: return (a_Item.m_ItemType == E_BLOCK_COBBLESTONE);
- case E_ITEM_IRON_PICKAXE: return (a_Item.m_ItemType == E_ITEM_IRON);
- case E_ITEM_GOLD_PICKAXE: return (a_Item.m_ItemType == E_ITEM_GOLD);
- case E_ITEM_DIAMOND_PICKAXE: return (a_Item.m_ItemType == E_ITEM_DIAMOND);
+ case E_ITEM_WOODEN_PICKAXE: return (a_ItemType == E_BLOCK_PLANKS);
+ case E_ITEM_STONE_PICKAXE: return (a_ItemType == E_BLOCK_COBBLESTONE);
+ case E_ITEM_IRON_PICKAXE: return (a_ItemType == E_ITEM_IRON);
+ case E_ITEM_GOLD_PICKAXE: return (a_ItemType == E_ITEM_GOLD);
+ case E_ITEM_DIAMOND_PICKAXE: return (a_ItemType == E_ITEM_DIAMOND);
}
return false;
}
diff --git a/src/Items/ItemShovel.h b/src/Items/ItemShovel.h
index 7659ccc54..333ba46e8 100644
--- a/src/Items/ItemShovel.h
+++ b/src/Items/ItemShovel.h
@@ -42,15 +42,15 @@ public:
return (a_BlockType == E_BLOCK_SNOW);
}
- virtual bool CanRepairWithItem(const cItem & a_Item) override
+ virtual bool CanRepairWithRawMaterial(short a_ItemType) override
{
switch (m_ItemType)
{
- case E_ITEM_WOODEN_SHOVEL: return (a_Item.m_ItemType == E_BLOCK_PLANKS);
- case E_ITEM_STONE_SHOVEL: return (a_Item.m_ItemType == E_BLOCK_COBBLESTONE);
- case E_ITEM_IRON_SHOVEL: return (a_Item.m_ItemType == E_ITEM_IRON);
- case E_ITEM_GOLD_SHOVEL: return (a_Item.m_ItemType == E_ITEM_GOLD);
- case E_ITEM_DIAMOND_SHOVEL: return (a_Item.m_ItemType == E_ITEM_DIAMOND);
+ case E_ITEM_WOODEN_SHOVEL: return (a_ItemType == E_BLOCK_PLANKS);
+ case E_ITEM_STONE_SHOVEL: return (a_ItemType == E_BLOCK_COBBLESTONE);
+ case E_ITEM_IRON_SHOVEL: return (a_ItemType == E_ITEM_IRON);
+ case E_ITEM_GOLD_SHOVEL: return (a_ItemType == E_ITEM_GOLD);
+ case E_ITEM_DIAMOND_SHOVEL: return (a_ItemType == E_ITEM_DIAMOND);
}
return false;
}
diff --git a/src/Items/ItemSword.h b/src/Items/ItemSword.h
index 34656ff99..44feb2d83 100644
--- a/src/Items/ItemSword.h
+++ b/src/Items/ItemSword.h
@@ -24,15 +24,15 @@ public:
return (a_BlockType == E_BLOCK_COBWEB);
}
- virtual bool CanRepairWithItem(const cItem & a_Item) override
+ virtual bool CanRepairWithRawMaterial(short a_ItemType) override
{
switch (m_ItemType)
{
- case E_ITEM_WOODEN_SWORD: return (a_Item.m_ItemType == E_BLOCK_PLANKS);
- case E_ITEM_STONE_SWORD: return (a_Item.m_ItemType == E_BLOCK_COBBLESTONE);
- case E_ITEM_IRON_SWORD: return (a_Item.m_ItemType == E_ITEM_IRON);
- case E_ITEM_GOLD_SWORD: return (a_Item.m_ItemType == E_ITEM_GOLD);
- case E_ITEM_DIAMOND_SWORD: return (a_Item.m_ItemType == E_ITEM_DIAMOND);
+ case E_ITEM_WOODEN_SWORD: return (a_ItemType == E_BLOCK_PLANKS);
+ case E_ITEM_STONE_SWORD: return (a_ItemType == E_BLOCK_COBBLESTONE);
+ case E_ITEM_IRON_SWORD: return (a_ItemType == E_ITEM_IRON);
+ case E_ITEM_GOLD_SWORD: return (a_ItemType == E_ITEM_GOLD);
+ case E_ITEM_DIAMOND_SWORD: return (a_ItemType == E_ITEM_DIAMOND);
}
return false;
}
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index 0e3e293aa..fcf5f6f6b 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -797,7 +797,7 @@ void cSlotAreaAnvil::OnTakeResult(cPlayer & a_Player)
cFastRandom Random;
if (!a_Player.IsGameModeCreative() && (Block == E_BLOCK_ANVIL) && (Random.NextFloat(1.0F) < 0.12F))
{
- NIBBLETYPE var4 = BlockMeta & 0x3;
+ NIBBLETYPE Orientation = BlockMeta & 0x3;
NIBBLETYPE AnvilDamage = BlockMeta >> 2;
++AnvilDamage;
@@ -810,7 +810,7 @@ void cSlotAreaAnvil::OnTakeResult(cPlayer & a_Player)
}
else
{
- a_Player.GetWorld()->SetBlockMeta(PosX, PosY, PosZ, var4 | AnvilDamage << 2);
+ a_Player.GetWorld()->SetBlockMeta(PosX, PosY, PosZ, Orientation | (AnvilDamage << 2));
a_Player.GetWorld()->BroadcastSoundParticleEffect(1021, PosX, PosY, PosZ, 0);
}
}
@@ -832,7 +832,7 @@ bool cSlotAreaAnvil::CanTakeResultItem(cPlayer & a_Player)
(a_Player.GetXpLevel() >= m_MaximumCost) // or the player have enough exp?
) &&
(!GetSlot(2, a_Player)->IsEmpty()) && // Is a item in the result slot?
- (m_MaximumCost > 0) // And: Is m_MaximumCost higher than 0?
+ (m_MaximumCost > 0) // When no maximum cost is set, the item isn't set from the UpdateResult() method and can't be a valid enchanting result.
);
}
@@ -871,8 +871,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player)
if (!SecondInput.IsEmpty())
{
RepairCost += cItemHandler::GetItemHandler(SecondInput)->GetRepairCost();
-
- if (Input.IsDamageable() && cItemHandler::GetItemHandler(Input)->CanRepairWithItem(SecondInput))
+ if (Input.IsDamageable() && cItemHandler::GetItemHandler(Input)->CanRepairWithRawMaterial(SecondInput.m_ItemType))
{
// Tool and armor repair with special item (iron / gold / diamond / ...)
int DamageDiff = std::min((int)Input.m_ItemDamage, (int)Input.GetMaxDamage() / 4);
@@ -889,7 +888,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player)
while ((DamageDiff > 0) && (x < SecondInput.m_ItemCount))
{
Input.m_ItemDamage -= DamageDiff;
- NeedExp += std::max(1, DamageDiff / 100) + Input.m_Enchantments.Size();
+ NeedExp += std::max(1, DamageDiff / 100) + Input.m_Enchantments.Count();
DamageDiff = std::min((int)Input.m_ItemDamage, (int)Input.GetMaxDamage() / 4);
++x;