MCPcopy Create free account
hub / github.com/cuberite/cuberite / WriteVarInt

Method WriteVarInt

src/ByteBuffer.cpp:608–624  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

606
607
608bool cByteBuffer::WriteVarInt(UInt32 a_Value)
609{
610 CHECK_THREAD;
611 CheckValid();
612
613 // A 32-bit integer can be encoded by at most 5 bytes:
614 unsigned char b[5];
615 int idx = 0;
616 do
617 {
618 b[idx] = (a_Value & 0x7f) | ((a_Value > 0x7f) ? 0x80 : 0x00);
619 a_Value = a_Value >> 7;
620 idx++;
621 } while (a_Value > 0);
622
623 return WriteBuf(b, idx);
624}
625
626
627

Callers 5

TestWriteMethod · 0.45
HandleClientHandshakeMethod · 0.45
ParseMetadataMethod · 0.45

Calls

no outgoing calls

Tested by 1

TestWriteMethod · 0.36