diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-06-12 22:03:46 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-06-12 22:03:46 +0200 |
commit | 5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e (patch) | |
tree | dffb59765b1325e416cd79a7d20030b62178e4b7 /source/cItem.h | |
parent | Fixed an error (diff) | |
download | cuberite-5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e.tar cuberite-5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e.tar.gz cuberite-5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e.tar.bz2 cuberite-5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e.tar.lz cuberite-5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e.tar.xz cuberite-5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e.tar.zst cuberite-5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e.zip |
Diffstat (limited to 'source/cItem.h')
-rw-r--r-- | source/cItem.h | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/source/cItem.h b/source/cItem.h index 4311cc3f0..28eed0d42 100644 --- a/source/cItem.h +++ b/source/cItem.h @@ -12,34 +12,41 @@ namespace Json -class cItem //tolua_export
-{ //tolua_export
+// tolua_begin
+class cItem
+{
public:
- cItem( ENUM_ITEM_ID a_ItemID = E_ITEM_EMPTY, char a_ItemCount = 0, short a_ItemHealth = 0 ) //tolua_export
+ cItem( ENUM_ITEM_ID a_ItemID = E_ITEM_EMPTY, char a_ItemCount = 0, short a_ItemHealth = 0 )
: m_ItemID ( a_ItemID )
, m_ItemCount ( a_ItemCount )
, m_ItemHealth ( a_ItemHealth )
- { //tolua_export
+ {
if(!IsValidItem( m_ItemID ) ) m_ItemID = E_ITEM_EMPTY;
- } //tolua_export
- void Empty() //tolua_export
- { //tolua_export
+ }
+ void Empty()
+ {
+ m_ItemID = E_ITEM_EMPTY;
+ m_ItemCount = 0;
+ m_ItemHealth = 0;
+ }
+ void Clear(void)
+ {
m_ItemID = E_ITEM_EMPTY;
m_ItemCount = 0;
m_ItemHealth = 0;
- } //tolua_export
- bool IsEmpty(void) const //tolua_export
- { //tolua_export
+ }
+ bool IsEmpty(void) const
+ {
return (m_ItemID <= 0 || m_ItemCount <= 0);
- } //tolua_export
- bool Equals( cItem & a_Item ) const //tolua_export
- { //tolua_export
+ }
+ bool Equals( cItem & a_Item ) const
+ {
return ( (m_ItemID == a_Item.m_ItemID) && (m_ItemHealth == a_Item.m_ItemHealth) );
- } //tolua_export
+ }
- //TODO Sorry for writing the functions in the header. But somehow it doesn´t worked when I put them into the cpp File :s
+ // 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()
+ inline int GetMaxDuration(void) const
{
switch(m_ItemID)
{
@@ -74,31 +81,31 @@ public: }
}
- //Damages a weapon. Returns true when destroyed
- inline bool DamageItem() {
- if(HasDuration())
+ // Damages a weapon / tool. Returns true when destroyed
+ inline bool DamageItem()
+ {
+ if (HasDuration())
{
m_ItemHealth++;
-
if(m_ItemHealth >= GetMaxDuration())
return true;
-
}
return false;
}
inline bool HasDuration() { return GetMaxDuration() > 0; }
- void GetJson( Json::Value & a_OutValue ) const; //tolua_export
- void FromJson( const Json::Value & a_Value ); //tolua_export
+ void GetJson( Json::Value & a_OutValue ) const;
+ void FromJson( const Json::Value & a_Value );
static bool IsEnchantable(ENUM_ITEM_ID item);
- ENUM_ITEM_ID m_ItemID; //tolua_export
- char m_ItemCount; //tolua_export
- short m_ItemHealth; //tolua_export
+ ENUM_ITEM_ID m_ItemID;
+ char m_ItemCount;
+ short m_ItemHealth;
-}; //tolua_export
+};
+// tolua_end
typedef std::vector<cItem> cItems;
|