Missed a class in r94 ;) Sorry guys :D
git-svn-id: http://mc-server.googlecode.com/svn/trunk@95 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
02f05f7496
commit
0498a43d21
59
source/packets/cPacket_ItemData.cpp
Normal file
59
source/packets/cPacket_ItemData.cpp
Normal file
@ -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 );
|
||||
}
|
||||
}
|
37
source/packets/cPacket_ItemData.h
Normal file
37
source/packets/cPacket_ItemData.h
Normal file
@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include "PacketID.h"
|
||||
#include "cPacket.h"
|
||||
#include "cItem.h"
|
||||
|
||||
class cPacket_ItemData : public cPacket
|
||||
{
|
||||
public:
|
||||
cPacket_ItemData()
|
||||
: m_ItemID( 0 )
|
||||
, m_ItemCount( 0 )
|
||||
, m_ItemUses( 0 )
|
||||
, m_EnchantNums(-1)
|
||||
{
|
||||
}
|
||||
|
||||
bool Parse(cSocket & a_Socket);
|
||||
|
||||
virtual cPacket* Clone() const { return new cPacket_ItemData(*this); }
|
||||
|
||||
void AppendItem(char* a_Message, unsigned int &a_Iterator, short a_ItemID, char a_Quantity, short a_Damage);
|
||||
|
||||
void AppendItem(char* a_Message, unsigned int &a_Iterator, cItem *a_Item);
|
||||
|
||||
int GetSize(short a_ItemID);
|
||||
|
||||
|
||||
// Below = item
|
||||
short m_ItemID; // if this is -1 the next stuff dont exist
|
||||
char m_ItemCount;
|
||||
short m_ItemUses;
|
||||
|
||||
short m_EnchantNums;
|
||||
|
||||
static unsigned int c_Size; // Minimal size ( +1+1 = max)
|
||||
};
|
Loading…
Reference in New Issue
Block a user