diff options
author | bibo38 <bibo38@users.noreply.github.com> | 2016-10-12 14:38:45 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2016-10-12 14:38:45 +0200 |
commit | cb640ffea4a51a10db2e379ada8dc0487378ba09 (patch) | |
tree | 780ff243f439c9663b2f88e5df2805cc503f4f1d /src/ByteBuffer.cpp | |
parent | Fixed cProjectileEntity double destroy bug (#3397) (diff) | |
download | cuberite-cb640ffea4a51a10db2e379ada8dc0487378ba09.tar cuberite-cb640ffea4a51a10db2e379ada8dc0487378ba09.tar.gz cuberite-cb640ffea4a51a10db2e379ada8dc0487378ba09.tar.bz2 cuberite-cb640ffea4a51a10db2e379ada8dc0487378ba09.tar.lz cuberite-cb640ffea4a51a10db2e379ada8dc0487378ba09.tar.xz cuberite-cb640ffea4a51a10db2e379ada8dc0487378ba09.tar.zst cuberite-cb640ffea4a51a10db2e379ada8dc0487378ba09.zip |
Diffstat (limited to '')
-rw-r--r-- | src/ByteBuffer.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp index b5f862a73..6cfb66f9a 100644 --- a/src/ByteBuffer.cpp +++ b/src/ByteBuffer.cpp @@ -53,6 +53,16 @@ Unfortunately it is very slow, so it is disabled even for regular DEBUG builds. +static char ValueToHexDigit(UInt8 digit) +{ + ASSERT(digit < 16); + return "0123456789abcdef"[digit]; +} + + + + + #ifdef DEBUG_SINGLE_THREAD_ACCESS /** Simple RAII class that is used for checking that no two threads are using an object simultanously. @@ -517,6 +527,29 @@ bool cByteBuffer::ReadPosition64(int & a_BlockX, int & a_BlockY, int & a_BlockZ) +bool cByteBuffer::ReadUUID(AString & a_Value) +{ + CHECK_THREAD + + if (!ReadString(a_Value, 16)) + { + return false; + } + + a_Value.resize(32); + for (unsigned int i = 15; i < 16; i--) + { + a_Value[i * 2 + 1] = ValueToHexDigit(a_Value[i] & 0xf); + a_Value[i * 2] = ValueToHexDigit(static_cast<UInt8>(a_Value[i]) >> 4); + } + + return true; +} + + + + + bool cByteBuffer::WriteBEInt8(Int8 a_Value) { CHECK_THREAD |