From dab398d5d663332527e57a7e239d223f33f4eb77 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 30 Oct 2013 23:24:46 +0100 Subject: Added 1.7 to protocol recognizer. The 1.7 protocol currently only reports server description and playercount. --- source/Protocol/Protocol.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source/Protocol/Protocol.h') diff --git a/source/Protocol/Protocol.h b/source/Protocol/Protocol.h index 5071f5961..466cf874b 100644 --- a/source/Protocol/Protocol.h +++ b/source/Protocol/Protocol.h @@ -186,6 +186,27 @@ protected: WriteInt(a_Vector.y); WriteInt(a_Vector.z); } + + void WriteVarInt(UInt32 a_Value) + { + // A 32-bit integer can be encoded by at most 5 bytes: + unsigned char b[5]; + int idx = 0; + do + { + b[idx] = (a_Value & 0x7f) | ((a_Value > 0x7f) ? 0x80 : 0x00); + a_Value = a_Value >> 7; + idx++; + } while (a_Value > 0); + + SendData((const char *)b, idx); + } + + void WriteVarUTF8String(const AString & a_String) + { + WriteVarInt(a_String.size()); + SendData(a_String.data(), a_String.size()); + } } ; -- cgit v1.2.3