diff options
author | Mattes D <github@xoft.cz> | 2020-04-03 08:57:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-03 08:57:01 +0200 |
commit | 01b8ed5295875262a91b60af878bf2a18c1b7aae (patch) | |
tree | 52171974791a7529a3a69f9fe20d906158765954 /src/Item.h | |
parent | Update Core (diff) | |
download | cuberite-01b8ed5295875262a91b60af878bf2a18c1b7aae.tar cuberite-01b8ed5295875262a91b60af878bf2a18c1b7aae.tar.gz cuberite-01b8ed5295875262a91b60af878bf2a18c1b7aae.tar.bz2 cuberite-01b8ed5295875262a91b60af878bf2a18c1b7aae.tar.lz cuberite-01b8ed5295875262a91b60af878bf2a18c1b7aae.tar.xz cuberite-01b8ed5295875262a91b60af878bf2a18c1b7aae.tar.zst cuberite-01b8ed5295875262a91b60af878bf2a18c1b7aae.zip |
Diffstat (limited to 'src/Item.h')
-rw-r--r-- | src/Item.h | 63 |
1 files changed, 8 insertions, 55 deletions
diff --git a/src/Item.h b/src/Item.h index 306e36b0a..175f044b5 100644 --- a/src/Item.h +++ b/src/Item.h @@ -37,17 +37,7 @@ class cItem { public: /** Creates an empty item */ - cItem(void) : - m_ItemType(E_ITEM_EMPTY), - m_ItemCount(0), - m_ItemDamage(0), - m_CustomName(""), - m_RepairCost(0), - m_FireworkItem(), - m_ItemColor() - { - } - + cItem(void); /** Creates an item of the specified type, by default 1 piece with no damage and no enchantments */ cItem( @@ -57,27 +47,7 @@ public: const AString & a_Enchantments = "", const AString & a_CustomName = "", const AStringVector & a_LoreTable = {} - ) : - m_ItemType (a_ItemType), - m_ItemCount (a_ItemCount), - m_ItemDamage (a_ItemDamage), - m_Enchantments(a_Enchantments), - m_CustomName (a_CustomName), - m_LoreTable (a_LoreTable), - m_RepairCost (0), - m_FireworkItem(), - m_ItemColor() - { - if (!IsValidItem(m_ItemType)) - { - if ((m_ItemType != E_BLOCK_AIR) && (m_ItemType != E_ITEM_EMPTY)) - { - LOGWARNING("%s: creating an invalid item type (%d), resetting to empty.", __FUNCTION__, a_ItemType); - } - Empty(); - } - } - + ); // 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 @@ -88,31 +58,14 @@ public: #endif + /** Empties the item and frees up any dynamic storage used by the internals. */ + void Empty(void); - void Empty(void) - { - m_ItemType = E_ITEM_EMPTY; - m_ItemCount = 0; - m_ItemDamage = 0; - m_Enchantments.Clear(); - m_CustomName = ""; - m_LoreTable.clear(); - m_RepairCost = 0; - m_FireworkItem.EmptyData(); - m_ItemColor.Clear(); - } - - - void Clear(void) - { - m_ItemType = E_ITEM_EMPTY; - m_ItemCount = 0; - m_ItemDamage = 0; - m_RepairCost = 0; - m_ItemColor.Clear(); - } - + /** Empties the item and frees up any dynamic storage used by the internals. + TODO: What is the usage difference? Merge with Empty()? */ + 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)); |