summaryrefslogtreecommitdiffstats
path: root/source/ByteBuffer.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-10-28 20:57:03 +0100
committermadmaxoft <github@xoft.cz>2013-10-28 20:57:03 +0100
commitdfefdcf7f1cb1c7a741bb2deb82b7fb9634657b1 (patch)
tree3cc9621b2bd0e6852da5ab9695d9b0a8cf460241 /source/ByteBuffer.cpp
parentcByteBuffer: Added the VarInt and VarUTF8String type reading and writing. (diff)
downloadcuberite-dfefdcf7f1cb1c7a741bb2deb82b7fb9634657b1.tar
cuberite-dfefdcf7f1cb1c7a741bb2deb82b7fb9634657b1.tar.gz
cuberite-dfefdcf7f1cb1c7a741bb2deb82b7fb9634657b1.tar.bz2
cuberite-dfefdcf7f1cb1c7a741bb2deb82b7fb9634657b1.tar.lz
cuberite-dfefdcf7f1cb1c7a741bb2deb82b7fb9634657b1.tar.xz
cuberite-dfefdcf7f1cb1c7a741bb2deb82b7fb9634657b1.tar.zst
cuberite-dfefdcf7f1cb1c7a741bb2deb82b7fb9634657b1.zip
Diffstat (limited to 'source/ByteBuffer.cpp')
-rw-r--r--source/ByteBuffer.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/source/ByteBuffer.cpp b/source/ByteBuffer.cpp
index 78cc1385e..6659b4dd4 100644
--- a/source/ByteBuffer.cpp
+++ b/source/ByteBuffer.cpp
@@ -39,11 +39,11 @@ public:
{
cByteBuffer buf(50);
buf.Write("\x05\xac\x02\x00", 4);
- UInt64 v1;
+ UInt32 v1;
ASSERT(buf.ReadVarInt(v1) && (v1 == 5));
- UInt64 v2;
+ UInt32 v2;
ASSERT(buf.ReadVarInt(v2) && (v2 == 300));
- UInt64 v3;
+ UInt32 v3;
ASSERT(buf.ReadVarInt(v3) && (v3 == 0));
}
@@ -374,11 +374,11 @@ bool cByteBuffer::ReadBEUTF16String16(AString & a_Value)
-bool cByteBuffer::ReadVarInt(UInt64 & a_Value)
+bool cByteBuffer::ReadVarInt(UInt32 & a_Value)
{
CHECK_THREAD;
CheckValid();
- UInt64 Value = 0;
+ UInt32 Value = 0;
int Shift = 0;
unsigned char b = 0;
do
@@ -400,7 +400,7 @@ bool cByteBuffer::ReadVarUTF8String(AString & a_Value)
{
CHECK_THREAD;
CheckValid();
- UInt64 Size = 0;
+ UInt32 Size = 0;
if (!ReadVarInt(Size))
{
return false;
@@ -534,13 +534,13 @@ bool cByteBuffer::WriteBEUTF16String16(const AString & a_Value)
-bool cByteBuffer::WriteVarInt(UInt64 a_Value)
+bool cByteBuffer::WriteVarInt(UInt32 a_Value)
{
CHECK_THREAD;
CheckValid();
- // A 64-bit integer can be encoded by at most 10 bytes:
- unsigned char b[10];
+ // A 32-bit integer can be encoded by at most 5 bytes:
+ unsigned char b[5];
int idx = 0;
do
{