Files
cuberite-2a/source/packets/cPacket_AddToInventory.cpp
T

31 lines
731 B
C++
Raw Normal View History

#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
2011-10-03 18:41:19 +00:00
#include "cPacket_AddToInventory.h"
2011-12-21 20:42:34 +00:00
#include "cPacket_WholeInventory.h"
#include "../cItem.h"
2011-12-21 20:42:34 +00:00
#include "cPacket_ItemData.h"
2011-10-03 18:41:19 +00:00
2011-10-03 18:41:19 +00:00
bool cPacket_AddToInventory::Send( cSocket & a_Socket )
{
unsigned int TotalSize = c_Size;
2011-12-21 20:42:34 +00:00
cPacket_ItemData Item;
2011-12-22 16:30:40 +00:00
TotalSize += Item.GetSize((short) m_ItemType);
2011-12-21 20:42:34 +00:00
2011-10-03 18:41:19 +00:00
char* Message = new char[TotalSize];
unsigned int i = 0;
2011-12-21 20:42:34 +00:00
AppendByte ( (char) m_PacketID, Message, i );
2011-12-22 16:30:40 +00:00
Item.AppendItem(Message, i, (short) m_ItemType, m_Count, this->m_Life);
2011-10-03 18:41:19 +00:00
bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) );
delete [] Message;
return RetVal;
}