From f1470fcf9f1dc907241a645614cdcd5547dc1dbd Mon Sep 17 00:00:00 2001 From: Hownaer Date: Thu, 28 Aug 2014 15:21:38 +0200 Subject: Fixed bad values in the IsEnchantable() method. --- src/Item.cpp | 20 ++++++++++++++++---- src/Item.h | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Item.cpp b/src/Item.cpp index 4d29318e6..ebdf99ca5 100644 --- a/src/Item.cpp +++ b/src/Item.cpp @@ -190,9 +190,16 @@ void cItem::FromJson(const Json::Value & a_Value) -bool cItem::IsEnchantable(short a_ItemType) +bool cItem::IsEnchantable(short a_ItemType, bool a_WithBook) { - if (ItemCategory::IsTool(a_ItemType) || ItemCategory::IsArmor(a_ItemType)) + if ( + ItemCategory::IsAxe(a_ItemType) || + ItemCategory::IsSword(a_ItemType) || + ItemCategory::IsShovel(a_ItemType) || + ItemCategory::IsPickaxe(a_ItemType) || + (a_WithBook && ItemCategory::IsHoe(a_ItemType)) || + ItemCategory::IsArmor(a_ItemType) + ) { return true; } @@ -201,12 +208,17 @@ bool cItem::IsEnchantable(short a_ItemType) { case E_ITEM_BOOK: case E_ITEM_BOW: - case E_ITEM_CARROT_ON_STICK: case E_ITEM_FISHING_ROD: - case E_ITEM_SHEARS: { return true; } + + case E_ITEM_CARROT_ON_STICK: + case E_ITEM_SHEARS: + case E_ITEM_FLINT_AND_STEEL: + { + return a_WithBook; + } } return false; diff --git a/src/Item.h b/src/Item.h index d8b9e78a0..61011d861 100644 --- a/src/Item.h +++ b/src/Item.h @@ -184,7 +184,7 @@ public: void FromJson(const Json::Value & a_Value); /** Returns true if the specified item type is enchantable (as per 1.2.5 protocol requirements) */ - static bool IsEnchantable(short a_ItemType); // tolua_export + static bool IsEnchantable(short a_ItemType, bool a_WithBook = false); // tolua_export /** Returns the enchantability of the item. When the item hasn't a enchantability, it will returns 0 */ int GetEnchantability(); // tolua_export -- cgit v1.2.3