- Edited
I am trying to understand the godot binary serialization format.
It is documented here. https://docs.godotengine.org/en/stable/tutorials/misc/binary_serialization_api.html
it is the format of a binary file created with file.store_var() and read with file.get_var()
It is documented but I get different results from the documentation. For example this code:
file.store_var(1)creates this binary file (in hexadecimal)
08 00 00 00 02 00 00 00 01 00 00 00The first 4 bytes (08 00 00 00) are not documented [bytes 0-3]. the bytes 4-7 contain the header with an int that specify the type of data (2 in this case, it specify an integer in little endian encoding) the bytes 8-11 cointain the actual stored integer (1, in little endian encoding)
So what are these first 4 bytes? I think that they are not some sort of error correction because they remain the same if I change the stored int example:
file.store_var(1) file.store_var(2) file.store_var(3)binary file:
[unknown bytes] [int header] [actual integer] 08 00 00 00 02 00 00 00 01 00 00 00 08 00 00 00 02 00 00 00 02 00 00 00 08 00 00 00 02 00 00 00 03 00 00 00Another difference is that the integer is actually 4 bytes (32 bits) long, not 64 bits as the documentation says.