summaryrefslogtreecommitdiffstats
path: root/src/ByteBuffer.cpp
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-09-08 17:02:54 +0200
committerHowaner <franzi.moos@googlemail.com>2014-09-08 17:02:54 +0200
commit8f8693a71eb896ccc7c14c4033ae8d07dae27ac3 (patch)
tree8c9e19b4c5155eae5986943293a6cd8f77c8b831 /src/ByteBuffer.cpp
parentUpdated chunk sending to 1.8 (diff)
downloadcuberite-8f8693a71eb896ccc7c14c4033ae8d07dae27ac3.tar
cuberite-8f8693a71eb896ccc7c14c4033ae8d07dae27ac3.tar.gz
cuberite-8f8693a71eb896ccc7c14c4033ae8d07dae27ac3.tar.bz2
cuberite-8f8693a71eb896ccc7c14c4033ae8d07dae27ac3.tar.lz
cuberite-8f8693a71eb896ccc7c14c4033ae8d07dae27ac3.tar.xz
cuberite-8f8693a71eb896ccc7c14c4033ae8d07dae27ac3.tar.zst
cuberite-8f8693a71eb896ccc7c14c4033ae8d07dae27ac3.zip
Diffstat (limited to 'src/ByteBuffer.cpp')
-rw-r--r--src/ByteBuffer.cpp44
1 files changed, 44 insertions, 0 deletions
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;