-
Notifications
You must be signed in to change notification settings - Fork 0
/
MinecraftBufferCommon.bt
115 lines (102 loc) · 2.19 KB
/
MinecraftBufferCommon.bt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//------------------------------------------------
//--- 010 Editor v10.0 Binary Template
//
// File: MinecraftBufferCommon
// Authors: MrNikes
// Version: 0.0.1
// Purpose: Minecraft Buffer
// Category: Misc
// File Mask:
// ID Bytes:
// History:
//------------------------------------------------
ubyte read_varint_size()
{
local int pos = FTell();
local ubyte size = 0;
local ubyte i = 0;
while(true)
{
i = ReadUByte(pos + size);
size++;
if (!(i & 0x80))
{
break;
}
}
return size;
}
typedef struct(ubyte size)
{
ubyte raw[size];
} Varint <read=ReadVarInt>;
uint64 FromVarint(Varint& n)
{
local uint64 value = 0;
local ubyte i = 0;
local ubyte pos = 0;
while(true)
{
i = n.raw[pos];
value |= (uint64)(i & 0x7F) << (pos * 7);
pos++;
if (!(i & 0x80))
{
break;
}
}
return value;
}
string ReadVarInt(Varint& n)
{
string s;
SPrintf(s,"varint %Ld", FromVarint(n));
return s;
}
typedef struct {
local ubyte size = read_varint_size();
Varint length(size) <fgcolor=cDkAqua>;
local int64 value = FromVarint(length);
} VarType <read=ReadVarType>;
string ReadVarType(VarType& n)
{
string s;
SPrintf(s,"%Ld", n.value);
return s;
}
typedef struct {
local ubyte size = read_varint_size();
Varint length(size) <fgcolor=cDkAqua>;
local int64 len = FromVarint(length);
byte value[len];
} VarBytes;
typedef struct {
local ubyte size = read_varint_size();
Varint length(size) <fgcolor=cDkAqua>;
local int64 len = FromVarint(length);
int value[len];
} VarIntArray;
typedef struct {
local ubyte size = read_varint_size();
Varint length(size) <fgcolor=cDkAqua>;
local int64 len = FromVarint(length);
int64 value[len];
} VarLongArray;
typedef struct {
byte value;
} VarBoolean <read=ReadVarBoolean>;
string ReadVarBoolean(VarBoolean& n)
{
if (n.value == 0) {
return "false";
}
return "true";
}
typedef struct {
VarType length;
byte String[length.value];
} VarString <read=ReadVarString>;
string ReadVarString(VarString& n)
{
return n.String;
}