summaryrefslogtreecommitdiffstats
path: root/source/Item.h
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-01-12 05:46:01 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-01-12 05:46:01 +0100
commit43e684071933adef93040e8d4b830d5c6b71cf9a (patch)
tree014e5300feb1cdbbb8f24e4e42594eeb841f0be2 /source/Item.h
parentFixed rclk in doublechests (diff)
downloadcuberite-43e684071933adef93040e8d4b830d5c6b71cf9a.tar
cuberite-43e684071933adef93040e8d4b830d5c6b71cf9a.tar.gz
cuberite-43e684071933adef93040e8d4b830d5c6b71cf9a.tar.bz2
cuberite-43e684071933adef93040e8d4b830d5c6b71cf9a.tar.lz
cuberite-43e684071933adef93040e8d4b830d5c6b71cf9a.tar.xz
cuberite-43e684071933adef93040e8d4b830d5c6b71cf9a.tar.zst
cuberite-43e684071933adef93040e8d4b830d5c6b71cf9a.zip
Diffstat (limited to '')
-rw-r--r--source/Item.h51
1 files changed, 20 insertions, 31 deletions
diff --git a/source/Item.h b/source/Item.h
index 812ba247d..2a8df9b33 100644
--- a/source/Item.h
+++ b/source/Item.h
@@ -16,48 +16,51 @@ namespace Json
class cItem
{
public:
- cItem(short a_ItemType = E_ITEM_EMPTY, char a_ItemCount = 0, short a_ItemHealth = 0)
+ cItem(short a_ItemType = E_ITEM_EMPTY, char a_ItemCount = 0, short a_ItemDamage = 0)
: m_ItemType (a_ItemType)
, m_ItemCount (a_ItemCount)
- , m_ItemHealth(a_ItemHealth)
+ , m_ItemDamage(a_ItemDamage)
{
- if (!IsValidItem( m_ItemID ) ) m_ItemID = E_ITEM_EMPTY;
+ if (!IsValidItem(m_ItemType))
+ {
+ m_ItemType = E_ITEM_EMPTY;
+ }
}
void Empty()
{
- m_ItemID = E_ITEM_EMPTY;
+ m_ItemType = E_ITEM_EMPTY;
m_ItemCount = 0;
- m_ItemHealth = 0;
+ m_ItemDamage = 0;
}
void Clear(void)
{
- m_ItemID = E_ITEM_EMPTY;
+ m_ItemType = E_ITEM_EMPTY;
m_ItemCount = 0;
- m_ItemHealth = 0;
+ m_ItemDamage = 0;
}
bool IsEmpty(void) const
{
- return (m_ItemID <= 0 || m_ItemCount <= 0);
+ return (m_ItemType <= 0 || m_ItemCount <= 0);
}
bool IsEqual(const cItem & a_Item) const
{
- return (IsSameType(a_Item) && (m_ItemHealth == a_Item.m_ItemHealth));
+ return (IsSameType(a_Item) && (m_ItemDamage == a_Item.m_ItemDamage));
}
bool IsSameType(const cItem & a_Item) const
{
- return (m_ItemID == a_Item.m_ItemID) || (IsEmpty() && a_Item.IsEmpty());
+ return (m_ItemType == a_Item.m_ItemType) || (IsEmpty() && a_Item.IsEmpty());
}
// TODO Sorry for writing the functions in the header. But somehow it doesn´t worked when I put them into the cpp File :s
inline int GetMaxDuration(void) const
{
- switch(m_ItemID)
+ switch (m_ItemType)
{
case 256: return 251;
case 257: return 251;
@@ -90,13 +93,13 @@ public:
}
}
- // Damages a weapon / tool. Returns true when destroyed
+ /// Damages a weapon / tool. Returns true when destroyed
inline bool DamageItem()
{
if (HasDuration())
{
- m_ItemHealth++;
- if(m_ItemHealth >= GetMaxDuration())
+ m_ItemDamage++;
+ if (m_ItemDamage >= GetMaxDuration())
return true;
}
return false;
@@ -111,23 +114,9 @@ public:
static bool IsEnchantable(short a_ItemType);
- // tolua_end
- union
- {
- // tolua_begin
- short m_ItemID; // OBSOLETE, use m_ItemType instead
- short m_ItemType;
- // tolua_end
- } ;
- char m_ItemCount; // tolua_export
- union
- {
- // tolua_begin
- short m_ItemHealth; // OBSOLETE, use m_ItemDamage instead
- short m_ItemDamage;
- // tolua_end
- } ;
- // tolua_begin
+ short m_ItemType;
+ char m_ItemCount;
+ short m_ItemDamage;
};
// tolua_end