summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Mobs/Wolf.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp
index 560a6b2fa..33a9b31ee 100644
--- a/src/Mobs/Wolf.cpp
+++ b/src/Mobs/Wolf.cpp
@@ -169,10 +169,13 @@ void cWolf::ReceiveNearbyFightInfo(AString a_PlayerID, cPawn * a_Opponent, bool
void cWolf::OnRightClicked(cPlayer & a_Player)
{
+ const cItem & EquippedItem = a_Player.GetEquippedItem();
+ const int EquippedItemType = EquippedItem.m_ItemType;
+
if (!IsTame() && !IsAngry())
{
// If the player is holding a bone, try to tame the wolf:
- if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_BONE)
+ if (EquippedItemType == E_ITEM_BONE)
{
if (!a_Player.IsGameModeCreative())
{
@@ -199,7 +202,7 @@ void cWolf::OnRightClicked(cPlayer & a_Player)
else if (IsTame())
{
// Feed the wolf, restoring its health, or dye its collar:
- switch (a_Player.GetEquippedItem().m_ItemType)
+ switch (EquippedItemType)
{
case E_ITEM_RAW_BEEF:
case E_ITEM_STEAK:
@@ -211,7 +214,7 @@ void cWolf::OnRightClicked(cPlayer & a_Player)
{
if (m_Health < m_MaxHealth)
{
- Heal(ItemHandler(a_Player.GetEquippedItem().m_ItemType)->GetFoodInfo().FoodLevel);
+ Heal(ItemHandler(EquippedItemType)->GetFoodInfo(&EquippedItem).FoodLevel);
if (!a_Player.IsGameModeCreative())
{
a_Player.GetInventory().RemoveOneEquippedItem();
@@ -223,7 +226,7 @@ void cWolf::OnRightClicked(cPlayer & a_Player)
{
if (a_Player.GetUUID() == m_OwnerUUID) // Is the player the owner of the dog?
{
- SetCollarColor(a_Player.GetEquippedItem().m_ItemDamage);
+ SetCollarColor(EquippedItem.m_ItemDamage);
if (!a_Player.IsGameModeCreative())
{
a_Player.GetInventory().RemoveOneEquippedItem();