summaryrefslogtreecommitdiffstats
path: root/src/ByteBuffer.cpp
diff options
context:
space:
mode:
authorMatyas Dolak <dolak@eset.cz>2015-01-21 12:12:22 +0100
committerMatyas Dolak <dolak@eset.cz>2015-01-21 12:12:22 +0100
commitadf3b3a56944dfa3a0204707e2ccc94c3a0d043c (patch)
treeb7500db51a336cf61ee9e5e840638e0c2505fdae /src/ByteBuffer.cpp
parentProtoProxy: Fixed warnings in Connection.cpp. (diff)
downloadcuberite-adf3b3a56944dfa3a0204707e2ccc94c3a0d043c.tar
cuberite-adf3b3a56944dfa3a0204707e2ccc94c3a0d043c.tar.gz
cuberite-adf3b3a56944dfa3a0204707e2ccc94c3a0d043c.tar.bz2
cuberite-adf3b3a56944dfa3a0204707e2ccc94c3a0d043c.tar.lz
cuberite-adf3b3a56944dfa3a0204707e2ccc94c3a0d043c.tar.xz
cuberite-adf3b3a56944dfa3a0204707e2ccc94c3a0d043c.tar.zst
cuberite-adf3b3a56944dfa3a0204707e2ccc94c3a0d043c.zip
Diffstat (limited to '')
-rw-r--r--src/ByteBuffer.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp
index e1e5867a9..f3dc44d91 100644
--- a/src/ByteBuffer.cpp
+++ b/src/ByteBuffer.cpp
@@ -348,8 +348,24 @@ bool cByteBuffer::ReadBEShort(short & a_Value)
CHECK_THREAD
CheckValid();
NEEDBYTES(2);
+ Int16 val;
+ ReadBuf(&val, 2);
+ val = ntohs(val);
+ a_Value = *(reinterpret_cast<short *>(&val));
+ return true;
+}
+
+
+
+
+
+bool cByteBuffer::ReadBEUInt16(UInt16 & a_Value)
+{
+ CHECK_THREAD
+ CheckValid();
+ NEEDBYTES(2);
ReadBuf(&a_Value, 2);
- a_Value = (short)ntohs((u_short)a_Value);
+ a_Value = ntohs(a_Value);
return true;
}
@@ -371,6 +387,20 @@ bool cByteBuffer::ReadBEInt(int & a_Value)
+bool cByteBuffer::ReadBEUInt32(UInt32 & a_Value)
+{
+ CHECK_THREAD
+ CheckValid();
+ NEEDBYTES(4);
+ ReadBuf(&a_Value, 4);
+ a_Value = ntohl(a_Value);
+ return true;
+}
+
+
+
+
+
bool cByteBuffer::ReadBEInt64(Int64 & a_Value)
{
CHECK_THREAD