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

Method LogMetadata

Tools/ProtoProxy/Connection.cpp:2767–2855  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2765
2766
2767void cConnection::LogMetadata(const AString & a_Metadata, size_t a_IndentCount)
2768{
2769 AString Indent(a_IndentCount, ' ');
2770 int pos = 0;
2771 while (a_Metadata[pos] != 0x7f)
2772 {
2773 int Index = ((unsigned)((unsigned char)a_Metadata[pos])) & 0x1f; // Lower 5 bits = index
2774 int Type = ((unsigned)((unsigned char)a_Metadata[pos])) >> 5; // Upper 3 bits = type
2775 // int Length = 0;
2776 switch (Type)
2777 {
2778 case 0:
2779 {
2780 Log("%sbyte[%d] = %d", Indent.c_str(), Index, a_Metadata[pos + 1]);
2781 pos += 1;
2782 break;
2783 }
2784 case 1:
2785 {
2786 Log("%sshort[%d] = %d", Indent.c_str(), Index, (a_Metadata[pos + 1] << 8) | a_Metadata[pos + 2]);
2787 pos += 2;
2788 break;
2789 }
2790 case 2:
2791 {
2792 Log("%sint[%d] = %d", Indent.c_str(), Index, (a_Metadata[pos + 1] << 24) | (a_Metadata[pos + 2] << 16) | (a_Metadata[pos + 3] << 8) | a_Metadata[pos + 4]);
2793 pos += 4;
2794 break;
2795 }
2796 case 3:
2797 {
2798 Log("%sfloat[%d] = 0x%x", Indent.c_str(), Index, (a_Metadata[pos + 1] << 24) | (a_Metadata[pos + 2] << 16) | (a_Metadata[pos + 3] << 8) | a_Metadata[pos + 4]);
2799 pos += 4;
2800 break;
2801 }
2802 case 4: // UTF-8 string with VarInt length
2803 {
2804 cByteBuffer bb(10);
2805 int RestLen = (int)a_Metadata.size() - pos - 1;
2806 if (RestLen > 8)
2807 {
2808 RestLen = 8;
2809 }
2810 bb.Write(a_Metadata.data() + pos + 1, RestLen);
2811 UInt32 Length;
2812 int rs = bb.GetReadableSpace();
2813 bb.ReadVarInt(Length);
2814 rs = rs - bb.GetReadableSpace();
2815 Log("%sstring[%d] = \"%*s\"", Indent.c_str(), Index, Length, a_Metadata.c_str() + pos + rs + 1);
2816 pos += Length + rs + 2;
2817 break;
2818 }
2819 case 5:
2820 {
2821 int BytesLeft = a_Metadata.size() - pos - 1;
2822 cByteBuffer bb(BytesLeft);
2823 bb.Write(a_Metadata.data() + pos + 1, BytesLeft);
2824 AString ItemDesc;

Callers

nothing calls this directly

Calls 5

c_strMethod · 0.80
sizeMethod · 0.80
GetReadableSpaceMethod · 0.80
WriteMethod · 0.45
ReadVarIntMethod · 0.45

Tested by

no test coverage detected