Hotfixed 1.8 item reading.
This commit is contained in:
parent
83588fb0aa
commit
fc11818f4c
@ -2091,7 +2091,7 @@ void cProtocol180::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cItem Item;
|
cItem Item;
|
||||||
ReadItem(a_ByteBuffer, Item, a_ByteBuffer.GetReadableSpace() - 3);
|
ReadItem(a_ByteBuffer, Item, 3);
|
||||||
|
|
||||||
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, CursorX);
|
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, CursorX);
|
||||||
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, CursorY);
|
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, CursorY);
|
||||||
@ -2165,7 +2165,7 @@ void cProtocol180::HandlePacketCreativeInventoryAction(cByteBuffer & a_ByteBuffe
|
|||||||
{
|
{
|
||||||
HANDLE_READ(a_ByteBuffer, ReadBEShort, short, SlotNum);
|
HANDLE_READ(a_ByteBuffer, ReadBEShort, short, SlotNum);
|
||||||
cItem Item;
|
cItem Item;
|
||||||
if (!ReadItem(a_ByteBuffer, Item, a_ByteBuffer.GetReadableSpace()))
|
if (!ReadItem(a_ByteBuffer, Item))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2418,7 +2418,7 @@ void cProtocol180::HandlePacketWindowClick(cByteBuffer & a_ByteBuffer)
|
|||||||
HANDLE_READ(a_ByteBuffer, ReadBEShort, short, TransactionID);
|
HANDLE_READ(a_ByteBuffer, ReadBEShort, short, TransactionID);
|
||||||
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, Mode);
|
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, Mode);
|
||||||
cItem Item;
|
cItem Item;
|
||||||
ReadItem(a_ByteBuffer, Item, a_ByteBuffer.GetReadableSpace());
|
ReadItem(a_ByteBuffer, Item);
|
||||||
|
|
||||||
// Convert Button, Mode, SlotNum and HeldItem into eClickAction:
|
// Convert Button, Mode, SlotNum and HeldItem into eClickAction:
|
||||||
eClickAction Action;
|
eClickAction Action;
|
||||||
@ -2510,7 +2510,7 @@ void cProtocol180::SendData(const char * a_Data, size_t a_Size)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cProtocol180::ReadItem(cByteBuffer & a_ByteBuffer, cItem & a_Item, size_t a_MetadataSize)
|
bool cProtocol180::ReadItem(cByteBuffer & a_ByteBuffer, cItem & a_Item, size_t a_RemainingBytes)
|
||||||
{
|
{
|
||||||
HANDLE_PACKET_READ(a_ByteBuffer, ReadBEShort, short, ItemType);
|
HANDLE_PACKET_READ(a_ByteBuffer, ReadBEShort, short, ItemType);
|
||||||
if (ItemType == -1)
|
if (ItemType == -1)
|
||||||
@ -2531,7 +2531,7 @@ bool cProtocol180::ReadItem(cByteBuffer & a_ByteBuffer, cItem & a_Item, size_t a
|
|||||||
}
|
}
|
||||||
|
|
||||||
AString Metadata;
|
AString Metadata;
|
||||||
if (!a_ByteBuffer.ReadString(Metadata, a_MetadataSize) || (Metadata.size() == 0) || (Metadata[0] == 0))
|
if (!a_ByteBuffer.ReadString(Metadata, a_ByteBuffer.GetReadableSpace() - a_RemainingBytes) || (Metadata.size() == 0) || (Metadata[0] == 0))
|
||||||
{
|
{
|
||||||
// No metadata
|
// No metadata
|
||||||
return true;
|
return true;
|
||||||
|
@ -322,7 +322,7 @@ protected:
|
|||||||
void SendCompass(const cWorld & a_World);
|
void SendCompass(const cWorld & a_World);
|
||||||
|
|
||||||
/** Reads an item out of the received data, sets a_Item to the values read. Returns false if not enough received data */
|
/** Reads an item out of the received data, sets a_Item to the values read. Returns false if not enough received data */
|
||||||
virtual bool ReadItem(cByteBuffer & a_ByteBuffer, cItem & a_Item, size_t a_MetadataSize = 1);
|
virtual bool ReadItem(cByteBuffer & a_ByteBuffer, cItem & a_Item, size_t a_RemainingBytes = 0);
|
||||||
|
|
||||||
/** Parses item metadata as read by ReadItem(), into the item enchantments. */
|
/** Parses item metadata as read by ReadItem(), into the item enchantments. */
|
||||||
void ParseItemMetadata(cItem & a_Item, const AString & a_Metadata);
|
void ParseItemMetadata(cItem & a_Item, const AString & a_Metadata);
|
||||||
|
Loading…
Reference in New Issue
Block a user