Binary serialization API
Packet specification
The packet is designed to be always padded to 4 bytes. All values are little-endian-encoded. All packets have a 4-byte header representing an integer, specifying the type of data:
Following this is the actual packet contents, which varies for each type of packet. Note that this assumes Godot is compiled with single-precision floats, which is the default. If Godot was compiled with double-precision floats, the length of “Float” fields within data structures should be 8, and the offset should be . The “float” type itself always uses double precision.
1:
Offset | Len | Type | Description |
---|
4 | 4 | Integer | 0 for False, 1 for True |
Offset | Len | Type | Description |
---|
4 | 8 | Integer | 64-bit signed integer |
3:
Offset | Len | Type | Description |
---|
4 | 4 | Float | IEE 754 32-Bits Float |
Offset | Len | Type | Description |
---|
4 | 4 | Integer | String length (in bytes) |
8 | X | Bytes | UTF-8 encoded string |
This field is padded to 4 bytes.
5:
Offset | Len | Type | Description |
---|
4 | 4 | Float | X coordinate |
8 | 4 | Float | Y coordinate |
Offset | Len | Type | Description |
---|
4 | 4 | Float | X coordinate |
8 | 4 | Float | Y coordinate |
12 | 4 | Float | X size |
16 | 4 | Float | Y size |
7:
Offset | Len | Type | Description |
---|
4 | 4 | Float | X coordinate |
8 | 4 | Float | Y coordinate |
12 | 4 | Float | Z coordinate |
Offset | Len | Type | Description |
---|
4 | 4 | Float | The X component of the X column vector, accessed via [0][0] |
8 | 4 | Float | The Y component of the X column vector, accessed via [0][1] |
12 | 4 | Float | The X component of the Y column vector, accessed via [1][0] |
16 | 4 | Float | The Y component of the Y column vector, accessed via [1][1] |
20 | 4 | Float | The X component of the origin vector, accessed via [2][0] |
24 | 4 | Float | The Y component of the origin vector, accessed via [2][1] |
10:
Offset | Len | Type | Description |
---|
4 | 4 | Float | Imaginary X |
8 | 4 | Float | Imaginary Y |
12 | 4 | Float | Imaginary Z |
16 | 4 | Float | Real W |
Offset | Len | Type | Description |
---|
4 | 4 | Float | X coordinate |
8 | 4 | Float | Y coordinate |
12 | 4 | Float | Z coordinate |
16 | 4 | Float | X size |
20 | 4 | Float | Y size |
24 | 4 | Float | Z size |
12:
Offset | Len | Type | Description |
---|
4 | 4 | Float | The X component of the X column vector, accessed via [0][0] |
8 | 4 | Float | The Y component of the X column vector, accessed via [0][1] |
12 | 4 | Float | The Z component of the X column vector, accessed via [0][2] |
16 | 4 | Float | The X component of the Y column vector, accessed via [1][0] |
20 | 4 | Float | The Y component of the Y column vector, accessed via [1][1] |
24 | 4 | Float | The Z component of the Y column vector, accessed via [1][2] |
28 | 4 | Float | The X component of the Z column vector, accessed via [2][0] |
32 | 4 | Float | The Y component of the Z column vector, accessed via [2][1] |
36 | 4 | Float | The Z component of the Z column vector, accessed via [2][2] |
Offset | Len | Type | Description |
---|
4 | 4 | Float | The X component of the X column vector, accessed via [0][0] |
8 | 4 | Float | The Y component of the X column vector, accessed via [0][1] |
12 | 4 | Float | The Z component of the X column vector, accessed via [0][2] |
16 | 4 | Float | The X component of the Y column vector, accessed via [1][0] |
20 | 4 | Float | The Y component of the Y column vector, accessed via [1][1] |
24 | 4 | Float | The Z component of the Y column vector, accessed via [1][2] |
28 | 4 | Float | The X component of the Z column vector, accessed via [2][0] |
32 | 4 | Float | The Y component of the Z column vector, accessed via [2][1] |
36 | 4 | Float | The Z component of the Z column vector, accessed via [2][2] |
40 | 4 | Float | The X component of the origin vector, accessed via [3][0] |
44 | 4 | Float | The Y component of the origin vector, accessed via [3][1] |
48 | 4 | Float | The Z component of the origin vector, accessed via [3][2] |
14:
Offset | Len | Type | Description |
---|
4 | 4 | Float | Red (typically 0..1, can be above 1 for overbright colors) |
8 | 4 | Float | Green (typically 0..1, can be above 1 for overbright colors) |
12 | 4 | Float | Blue (typically 0..1, can be above 1 for overbright colors) |
16 | 4 | Float | Alpha (0..1) |
Offset | Len | Type | Description |
---|
4 | 4 | Integer | String length, or new format (val&0x80000000!=0 and NameCount=val&0x7FFFFFFF) |
For old format:
Offset | Len | Type | Description |
---|
8 | X | Bytes | UTF-8 encoded string |
For new format:
Offset | Len | Type | Description |
---|
4 | 4 | Integer | Sub-name count |
8 | 4 | Integer | Flags (absolute: val&1 != 0 ) |
For each Name and Sub-Name
Every name string is padded to 4 bytes.
16: (unsupported)
17: Object (unsupported)
Offset | Len | Type | Description |
---|
4 | 4 | Integer | val&0x7FFFFFFF = elements, val&0x80000000 = shared (bool) |
Then what follows is, for amount of “elements”, pairs of key and value, one after the other, using this same format.
19:
Offset | Len | Type | Description |
---|
4 | 4 | Integer | val&0x7FFFFFFF = elements, val&0x80000000 = shared (bool) |
Offset | Len | Type | Description |
---|
4 | 4 | Integer | Array length (Bytes) |
8..8+length | 1 | Byte | Byte (0..255) |
The array data is padded to 4 bytes.
21:
Offset | Len | Type | Description |
---|
4 | 4 | Integer | Array length (Integers) |
8..8+length*4 | 4 | Integer | 32-bit signed integer |
Offset | Len | Type | Description |
---|
4 | 4 | Integer | Array length (Floats) |
8..8+length*4 | 4 | Integer | 32-bits IEEE 754 float |
23:
Offset | Len | Type | Description |
---|
4 | 4 | Integer | Array length (Strings) |
For each String:
Offset | Len | Type | Description |
---|
X+0 | 4 | Integer | String length |
X+4 | X | Bytes | UTF-8 encoded string |
Every string is padded to 4 bytes.
Offset | Len | Type | Description |
---|
4 | 4 | Integer | Array length |
8..8+length8 | 4 | Float | X coordinate |
8..12+length8 | 4 | Float | Y coordinate |
25:
Offset | Len | Type | Description |
---|
4 | 4 | Integer | Array length |
8..8+length16 | 4 | Float | Red (typically 0..1, can be above 1 for overbright colors) |
8..12+length16 | 4 | Float | Green (typically 0..1, can be above 1 for overbright colors) |
8..16+length16 | 4 | Float | Blue (typically 0..1, can be above 1 for overbright colors) |
8..20+length16 | 4 | Float | Alpha (0..1) |