summaryrefslogtreecommitdiffstats
path: root/src/ByteBuffer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ByteBuffer.cpp')
-rw-r--r--src/ByteBuffer.cpp46
1 files changed, 45 insertions, 1 deletions
diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp
index 96556bf61..851c63858 100644
--- a/src/ByteBuffer.cpp
+++ b/src/ByteBuffer.cpp
@@ -267,7 +267,7 @@ size_t cByteBuffer::GetReadableSpace(void) const
}
// Single readable space partition:
ASSERT(m_WritePos >= m_ReadPos);
- return m_WritePos - m_ReadPos ;
+ return m_WritePos - m_ReadPos;
}
@@ -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;