diff options
Diffstat (limited to 'src/Item.h')
-rw-r--r-- | src/Item.h | 97 |
1 files changed, 44 insertions, 53 deletions
diff --git a/src/Item.h b/src/Item.h index a3379ebdc..65e20de79 100644 --- a/src/Item.h +++ b/src/Item.h @@ -25,7 +25,7 @@ class cColor; namespace Json { - class Value; +class Value; } @@ -35,7 +35,7 @@ namespace Json // tolua_begin class cItem { -public: + public: /** Creates an empty item */ cItem(void); @@ -49,14 +49,14 @@ public: const AStringVector & a_LoreTable = {} ); - // The constructor is disabled in code, because the compiler generates it anyway, - // but it needs to stay because ToLua needs to generate the binding for it - #ifdef TOLUA_EXPOSITION +// The constructor is disabled in code, because the compiler generates it anyway, +// but it needs to stay because ToLua needs to generate the binding for it +#ifdef TOLUA_EXPOSITION /** Creates an exact copy of the item */ cItem(const cItem & a_CopyFrom); - #endif +#endif /** Empties the item and frees up any dynamic storage used by the internals. */ void Empty(void); @@ -66,21 +66,15 @@ public: void Clear(void); /** Returns true if the item represents an empty stack - either the type is invalid, or count is zero. */ - bool IsEmpty(void) const - { - return ((m_ItemType <= 0) || (m_ItemCount <= 0)); - } + bool IsEmpty(void) const { return ((m_ItemType <= 0) || (m_ItemCount <= 0)); } /* Returns true if this itemstack can stack with the specified stack (types match, enchantments etc.) ItemCounts are ignored. */ bool IsEqual(const cItem & a_Item) const { return ( - IsSameType(a_Item) && - (m_ItemDamage == a_Item.m_ItemDamage) && - (m_Enchantments == a_Item.m_Enchantments) && - (m_CustomName == a_Item.m_CustomName) && - (m_LoreTable == a_Item.m_LoreTable) && + IsSameType(a_Item) && (m_ItemDamage == a_Item.m_ItemDamage) && (m_Enchantments == a_Item.m_Enchantments) && + (m_CustomName == a_Item.m_CustomName) && (m_LoreTable == a_Item.m_LoreTable) && m_FireworkItem.IsEqualTo(a_Item.m_FireworkItem) ); } @@ -92,10 +86,7 @@ public: } - bool IsBothNameAndLoreEmpty(void) const - { - return (m_CustomName.empty() && m_LoreTable.empty()); - } + bool IsBothNameAndLoreEmpty(void) const { return (m_CustomName.empty() && m_LoreTable.empty()); } bool IsCustomNameEmpty(void) const { return (m_CustomName.empty()); } @@ -155,20 +146,21 @@ public: XP cost of the transfer. */ int AddEnchantmentsFromItem(const cItem & a_Other); // tolua_export - /** Returns whether or not this item is allowed to have the given enchantment. Note: Does not check whether the enchantment is exclusive with the current enchantments on the item. */ + /** Returns whether or not this item is allowed to have the given enchantment. Note: Does not check whether the + * enchantment is exclusive with the current enchantments on the item. */ bool CanHaveEnchantment(int a_EnchantmentID); // tolua_begin - short m_ItemType; - char m_ItemCount; - short m_ItemDamage; - cEnchantments m_Enchantments; - AString m_CustomName; + short m_ItemType; + char m_ItemCount; + short m_ItemDamage; + cEnchantments m_Enchantments; + AString m_CustomName; // tolua_end - AStringVector m_LoreTable; // Exported in ManualBindings.cpp + AStringVector m_LoreTable; // Exported in ManualBindings.cpp /** Compares two items for the same type or category. Type of item is defined @@ -181,7 +173,7 @@ public: */ struct sItemCompare { - bool operator() (const cItem & a_Lhs, const cItem & a_Rhs) const + bool operator()(const cItem & a_Lhs, const cItem & a_Rhs) const { if (a_Lhs.m_ItemType != a_Rhs.m_ItemType) { @@ -197,9 +189,9 @@ public: // tolua_begin - int m_RepairCost; - cFireworkItem m_FireworkItem; - cColor m_ItemColor; + int m_RepairCost; + cFireworkItem m_FireworkItem; + cColor m_ItemColor; }; // tolua_end @@ -213,12 +205,11 @@ Note that this class is zero-indexed! class cItems // tolua_export : public std::vector<cItem> { // tolua_export -public: - + public: cItems(const cItems &) = default; cItems(cItems &&) = default; - cItems & operator = (const cItems &) = default; - cItems & operator = (cItems &&) = default; + cItems & operator=(const cItems &) = default; + cItems & operator=(cItems &&) = default; /** Constructs a new instance containing the specified item. */ cItems(cItem && a_InitialItem); @@ -228,19 +219,19 @@ public: /** Need a Lua-accessible constructor */ cItems(void) {} - cItem * Get (int a_Idx); - void Set (int a_Idx, const cItem & a_Item); - void Add (const cItem & a_Item) {push_back(a_Item); } - void Add (short a_ItemType) { emplace_back(a_ItemType); } - void Add (short a_ItemType, char a_ItemCount) { emplace_back(a_ItemType, a_ItemCount); } - void Delete(int a_Idx); - void Clear (void) {clear(); } - size_t Size (void) const { return size(); } - void Set (int a_Idx, short a_ItemType, char a_ItemCount, short a_ItemDamage); - bool Contains(const cItem & a_Item); - bool ContainsType(const cItem & a_Item); - - void Add (short a_ItemType, char a_ItemCount, short a_ItemDamage) + cItem * Get(int a_Idx); + void Set(int a_Idx, const cItem & a_Item); + void Add(const cItem & a_Item) { push_back(a_Item); } + void Add(short a_ItemType) { emplace_back(a_ItemType); } + void Add(short a_ItemType, char a_ItemCount) { emplace_back(a_ItemType, a_ItemCount); } + void Delete(int a_Idx); + void Clear(void) { clear(); } + size_t Size(void) const { return size(); } + void Set(int a_Idx, short a_ItemType, char a_ItemCount, short a_ItemDamage); + bool Contains(const cItem & a_Item); + bool ContainsType(const cItem & a_Item); + + void Add(short a_ItemType, char a_ItemCount, short a_ItemDamage) { emplace_back(a_ItemType, a_ItemCount, a_ItemDamage); } @@ -249,7 +240,7 @@ public: void AddItemGrid(const cItemGrid & a_ItemGrid); // tolua_end -} ; // tolua_export +}; // tolua_export @@ -258,9 +249,9 @@ public: /** Used to store loot probability tables */ class cLootProbab { -public: + public: cItem m_Item; - int m_MinAmount; - int m_MaxAmount; - int m_Weight; -} ; + int m_MinAmount; + int m_MaxAmount; + int m_Weight; +}; |