From 8f8693a71eb896ccc7c14c4033ae8d07dae27ac3 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 8 Sep 2014 17:02:54 +0200 Subject: Fixed more 1.8 packets. --- src/ByteBuffer.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'src/ByteBuffer.cpp') diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp index 96556bf61..94684afb8 100644 --- a/src/ByteBuffer.cpp +++ b/src/ByteBuffer.cpp @@ -489,6 +489,24 @@ bool cByteBuffer::ReadLEInt(int & a_Value) +bool cByteBuffer::ReadPosition(int & a_BlockX, int & a_BlockY, int & a_BlockZ) +{ + Int64 Value; + if (!ReadBEInt64(Value)) + { + return false; + } + + a_BlockX = Value >> 38; + a_BlockY = Value << 26 >> 52; + a_BlockZ = Value << 38 >> 38; + return true; +} + + + + + bool cByteBuffer::WriteChar(char a_Value) { CHECK_THREAD; @@ -661,6 +679,15 @@ bool cByteBuffer::WriteLEInt(int a_Value) +bool cByteBuffer::WritePosition(int a_BlockX, int a_BlockY, int a_BlockZ) +{ + return WriteBEInt64(((Int64)a_BlockX & 0x3FFFFFF) << 38 | ((Int64)a_BlockY & 0xFFF) << 26 | ((Int64)a_BlockZ & 0x3FFFFFF)); +} + + + + + bool cByteBuffer::ReadBuf(void * a_Buffer, size_t a_Count) { CHECK_THREAD; @@ -792,6 +819,23 @@ bool cByteBuffer::SkipRead(size_t a_Count) +bool cByteBuffer::ReverseRead(size_t a_Count) +{ + CHECK_THREAD; + CheckValid(); + if (m_ReadPos < a_Count) + { + return false; + } + + m_ReadPos -= a_Count; + return true; +} + + + + + void cByteBuffer::ReadAll(AString & a_Data) { CHECK_THREAD; -- cgit v1.2.3