From 01b8ed5295875262a91b60af878bf2a18c1b7aae Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 3 Apr 2020 08:57:01 +0200 Subject: Pulled the BlockID and BlockInfo headers from Globals.h. (#4591) The BlockID.h file was removed from Globals.h and renamed to BlockType.h (main change) The BlockInfo.h file was removed from Globals.h (main change) The ENUM_BLOCK_ID and ENUM_ITEM_ID enum names were replaced with ENUM_BLOCK_TYPE and ENUM_ITEM_TYPE (cosmetics) The various enums, such as eDimension, eDamageType and eExplosionSource were moved from BlockType.h to Defines.h, together with the helper functions for converting between them and strings (StringToDimension et al.) (minor) Many inline functions were moved from headers to their respective cpp files, so that BlockType.h could be included only into the cpp file, rather than the header. That broke our tests a bit, since they pick bits and pieces out of the main code and provide stubs for the rest; they had to be re-stubbed and re-verified. eMonsterType values are no longer tied to E_ITEM_SPAWN_EGG_META_* values --- src/Item.h | 63 ++++++++------------------------------------------------------ 1 file changed, 8 insertions(+), 55 deletions(-) (limited to 'src/Item.h') 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)); -- cgit v1.2.3