summaryrefslogtreecommitdiffstats
path: root/src/Protocol
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-09-22 22:06:08 +0200
committerHowaner <franzi.moos@googlemail.com>2014-09-22 22:06:08 +0200
commitfc11818f4c9eaeb9eb1acab4fcc3c6776e6c2d00 (patch)
treef9e6ff0ef3ad3676e8c953d1147144ea585313e4 /src/Protocol
parentQtBiomeVisualiser: Implemented live-update for the generator setup. (diff)
downloadcuberite-fc11818f4c9eaeb9eb1acab4fcc3c6776e6c2d00.tar
cuberite-fc11818f4c9eaeb9eb1acab4fcc3c6776e6c2d00.tar.gz
cuberite-fc11818f4c9eaeb9eb1acab4fcc3c6776e6c2d00.tar.bz2
cuberite-fc11818f4c9eaeb9eb1acab4fcc3c6776e6c2d00.tar.lz
cuberite-fc11818f4c9eaeb9eb1acab4fcc3c6776e6c2d00.tar.xz
cuberite-fc11818f4c9eaeb9eb1acab4fcc3c6776e6c2d00.tar.zst
cuberite-fc11818f4c9eaeb9eb1acab4fcc3c6776e6c2d00.zip
Diffstat (limited to 'src/Protocol')
-rw-r--r--src/Protocol/Protocol18x.cpp10
-rw-r--r--src/Protocol/Protocol18x.h2
2 files changed, 6 insertions, 6 deletions
diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp
index fbeb845f8..a7ab3abb1 100644
--- a/src/Protocol/Protocol18x.cpp
+++ b/src/Protocol/Protocol18x.cpp
@@ -2091,7 +2091,7 @@ void cProtocol180::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer)
}
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, CursorY);
@@ -2165,7 +2165,7 @@ void cProtocol180::HandlePacketCreativeInventoryAction(cByteBuffer & a_ByteBuffe
{
HANDLE_READ(a_ByteBuffer, ReadBEShort, short, SlotNum);
cItem Item;
- if (!ReadItem(a_ByteBuffer, Item, a_ByteBuffer.GetReadableSpace()))
+ if (!ReadItem(a_ByteBuffer, Item))
{
return;
}
@@ -2418,7 +2418,7 @@ void cProtocol180::HandlePacketWindowClick(cByteBuffer & a_ByteBuffer)
HANDLE_READ(a_ByteBuffer, ReadBEShort, short, TransactionID);
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, Mode);
cItem Item;
- ReadItem(a_ByteBuffer, Item, a_ByteBuffer.GetReadableSpace());
+ ReadItem(a_ByteBuffer, Item);
// Convert Button, Mode, SlotNum and HeldItem into eClickAction:
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);
if (ItemType == -1)
@@ -2531,7 +2531,7 @@ bool cProtocol180::ReadItem(cByteBuffer & a_ByteBuffer, cItem & a_Item, size_t a
}
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
return true;
diff --git a/src/Protocol/Protocol18x.h b/src/Protocol/Protocol18x.h
index 59a5dd0b6..eb0253663 100644
--- a/src/Protocol/Protocol18x.h
+++ b/src/Protocol/Protocol18x.h
@@ -322,7 +322,7 @@ protected:
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 */
- 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. */
void ParseItemMetadata(cItem & a_Item, const AString & a_Metadata);