From 5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Tue, 12 Jun 2012 20:03:46 +0000 Subject: Updated the crafting recipes architecture to better support crafting hooks. Removed the old recipe file and implementation altogether. git-svn-id: http://mc-server.googlecode.com/svn/trunk@597 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cItem.h | 61 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 27 deletions(-) (limited to 'source/cItem.h') 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 cItems; -- cgit v1.2.3