diff options
author | peterbell10 <peterbell10@live.co.uk> | 2017-08-25 14:43:18 +0200 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2017-08-25 14:43:18 +0200 |
commit | f4f2fc7c3d76eb3dc5a91c5eefb36c10597d6cb7 (patch) | |
tree | 70139b1ad7ed221e4b75c3a9e247b337de68eb07 /src/Protocol/Packetizer.cpp | |
parent | compile.sh update. Fixed -d and -n, intelligent thread choice (#3960) (diff) | |
download | cuberite-f4f2fc7c3d76eb3dc5a91c5eefb36c10597d6cb7.tar cuberite-f4f2fc7c3d76eb3dc5a91c5eefb36c10597d6cb7.tar.gz cuberite-f4f2fc7c3d76eb3dc5a91c5eefb36c10597d6cb7.tar.bz2 cuberite-f4f2fc7c3d76eb3dc5a91c5eefb36c10597d6cb7.tar.lz cuberite-f4f2fc7c3d76eb3dc5a91c5eefb36c10597d6cb7.tar.xz cuberite-f4f2fc7c3d76eb3dc5a91c5eefb36c10597d6cb7.tar.zst cuberite-f4f2fc7c3d76eb3dc5a91c5eefb36c10597d6cb7.zip |
Diffstat (limited to 'src/Protocol/Packetizer.cpp')
-rw-r--r-- | src/Protocol/Packetizer.cpp | 53 |
1 files changed, 3 insertions, 50 deletions
diff --git a/src/Protocol/Packetizer.cpp b/src/Protocol/Packetizer.cpp index 0a84d4678..5cae1fad5 100644 --- a/src/Protocol/Packetizer.cpp +++ b/src/Protocol/Packetizer.cpp @@ -5,46 +5,7 @@ #include "Globals.h" #include "Packetizer.h" - - - - - -/** Converts the hex digit character to its value. */ -static UInt8 HexDigitValue(char a_Character) -{ - switch (a_Character) - { - case '0': return 0; - case '1': return 1; - case '2': return 2; - case '3': return 3; - case '4': return 4; - case '5': return 5; - case '6': return 6; - case '7': return 7; - case '8': return 8; - case '9': return 9; - case 'a': return 10; - case 'b': return 11; - case 'c': return 12; - case 'd': return 13; - case 'e': return 14; - case 'f': return 15; - case 'A': return 10; - case 'B': return 11; - case 'C': return 12; - case 'D': return 13; - case 'E': return 14; - case 'F': return 15; - default: - { - LOGWARNING("Bad hex digit: %c", a_Character); - ASSERT(!"Bad hex digit"); - return 0; - } - } -} +#include "UUID.h" @@ -80,18 +41,10 @@ void cPacketizer::WriteFPInt(double a_Value) -void cPacketizer::WriteUUID(const AString & a_UUID) +void cPacketizer::WriteUUID(const cUUID & a_UUID) { - if (a_UUID.length() != 32) - { - LOGWARNING("%s: Attempt to send a bad uuid (length isn't 32): %s", __FUNCTION__, a_UUID.c_str()); - ASSERT(!"Wrong uuid length!"); - return; - } - - for (size_t i = 0; i < 32; i += 2) + for (auto val : a_UUID.ToRaw()) { - auto val = static_cast<UInt8>(HexDigitValue(a_UUID[i]) << 4 | HexDigitValue(a_UUID[i + 1])); VERIFY(m_Out.WriteBEUInt8(val)); } } |