diff options
author | lapayo94@gmail.com <lapayo94@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2011-12-21 22:05:18 +0100 |
---|---|---|
committer | lapayo94@gmail.com <lapayo94@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2011-12-21 22:05:18 +0100 |
commit | 0498a43d2115fa5b542527196ffa33feec7a3017 (patch) | |
tree | 33228f44bc4c14f37bf3ec59edef8b2ff004112e /source/packets/cPacket_ItemData.cpp | |
parent | - Crafting fixed in 1.0.0 (diff) | |
download | cuberite-0498a43d2115fa5b542527196ffa33feec7a3017.tar cuberite-0498a43d2115fa5b542527196ffa33feec7a3017.tar.gz cuberite-0498a43d2115fa5b542527196ffa33feec7a3017.tar.bz2 cuberite-0498a43d2115fa5b542527196ffa33feec7a3017.tar.lz cuberite-0498a43d2115fa5b542527196ffa33feec7a3017.tar.xz cuberite-0498a43d2115fa5b542527196ffa33feec7a3017.tar.zst cuberite-0498a43d2115fa5b542527196ffa33feec7a3017.zip |
Diffstat (limited to 'source/packets/cPacket_ItemData.cpp')
-rw-r--r-- | source/packets/cPacket_ItemData.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/source/packets/cPacket_ItemData.cpp b/source/packets/cPacket_ItemData.cpp new file mode 100644 index 000000000..60772d690 --- /dev/null +++ b/source/packets/cPacket_ItemData.cpp @@ -0,0 +1,59 @@ +#include "cPacket_ItemData.h"
+
+bool cPacket_ItemData::Parse(cSocket & a_Socket)
+{
+ m_Socket = a_Socket;
+
+ if( !ReadShort(m_ItemID) ) return false;
+
+ if( m_ItemID > -1 )
+ {
+ if( !ReadByte(m_ItemCount) ) return false;
+ if( !ReadShort(m_ItemUses) ) return false;
+
+ if(cItem::IsEnchantable((ENUM_ITEM_ID) m_ItemID))
+ {
+ if( !ReadShort(m_EnchantNums) ) return false;
+ if( m_EnchantNums > -1 )
+ {
+ //TODO Not implemented yet!
+ }
+ }
+
+ }
+ else
+ {
+ m_ItemCount = 0;
+ m_ItemUses = 0;
+ }
+
+ return true;
+}
+
+int cPacket_ItemData::GetSize(short a_ItemID)
+{
+ if(a_ItemID <= -1)
+ return 2;
+ if(cItem::IsEnchantable((ENUM_ITEM_ID) a_ItemID))
+ return 7;
+ return 5;
+}
+
+
+void cPacket_ItemData::AppendItem(char* a_Message, unsigned int &a_Iterator, cItem *a_Item)
+{
+ return AppendItem(a_Message, a_Iterator, a_Item->m_ItemID, a_Item->m_ItemCount, a_Item->m_ItemHealth);
+}
+
+void cPacket_ItemData::AppendItem(char* a_Message, unsigned int &a_Iterator, short a_ItemID, char a_Quantity, short a_Damage)
+{
+
+ AppendShort ( (short) a_ItemID, a_Message, a_Iterator );
+ if(a_ItemID > -1)
+ {
+ AppendByte ( a_Quantity, a_Message, a_Iterator );
+ AppendShort ( a_Damage, a_Message, a_Iterator );
+ if(cItem::IsEnchantable((ENUM_ITEM_ID) a_ItemID))
+ AppendShort ( (short) -1, a_Message, a_Iterator );
+ }
+}
\ No newline at end of file |