Untelo/Sandbox – User

From Bohemia Interactive Community
Jump to navigation Jump to search


Introduction

Structure

Header

 struct Header
 {
   uint8_t magic[4]; // "ALB1"
   uint32_t version;
   uint32_t unknown1;
   uint32_t unknown2;
 };

The header is followed by two tables containing the names of classes and fields.

 struct TagTables
 {
   TagTable fieldTable; // The id of the table is always 2, corresponding to "tags" in the field table.
   TagTable classTable; // The id of the table is always 3, corresponding to "classes" in the field table.
 };

The tag table contains a header similar to a field, but its type of pair does not match the usual meaning.

 struct TagTable
 {
   uint16_t id;
   FieldType type; // The type is always pair (0x0F).
 
   uint32_t size;
   TagTableEntry data[size];
 };

Each tag table entry contains an identifier and a string specifying the name of the tag. Note that the tag identifier does not correlate with the index of the entry in the table.

 struct TagTableEntry
 {
   uint16_t id;
   Field_string name;
 };

Field

The format uses fields prefixed with name and type. The name is given as an identifier corresponding to an entry in the tag table. The type is one of the value from the FieldType enumeration.

 enum FieldType : uint8_t
 {
   signed_char         = 0x01,
   unsigned_char       = 0x02,
   signed_short        = 0x03,
   unsigned_short      = 0x04,
   signed_int          = 0x05,
   unsigned_int        = 0x06,
   signed_long         = 0x07,
   unsigned_long       = 0x08,
   bool                = 0x09,
   float               = 0x0A,
   string              = 0x0B,
   array               = 0x0C,
   object              = 0x0D,
   object_pointer      = 0x0E,
   pair                = 0x0F,
   array_signed_short  = 0x10,
   array_signed_int    = 0x11,
   array_float         = 0x12,
   empty               = 0x13,
   double              = 0x14,
   array_double        = 0x15,
 };
 struct Field
 {
   uint16 tag; // Corresponds to an entry in the tag table.
   FieldType type;
   byte data[]; // Followed by polymorphic data blob which content is determined by the type field.
 };

Fundamental types

For fundamental C types, the field data contains only that value using the Microsoft x86 ABI. This means that the signed and unsigned long data types have a width of 32 bits, the same as signed and unsigned int.

All integers use little endian, and the floating point types conform to IEEE-754 binary32 and binary64 for float and double respectively.

String

The string data type is a length-prefixed non-null-terminated string, using a 16 bit length prefix:

 struct Field_string
 {
   uint16_t size;
   char data[size];
 };


Array

The array and object data types are both length-prefixed using a 32 bit length describing the size of the data blob, excluding the prefix.

The generic array data type contains an array of fields, their number given by a second size prefix.

 struct Field_array
 {
    uint32_t blobSize; // Size of the subsequent data blob.
 
    uint32_t size;
    Field data[size];
 };

Object and object pointer

The object data type contains a number of fields. The number of fields is not given, but the size of the data blob is used to determine the end of the object. Each object has an address field acting as a unique identifier. It is presumably the 32 bit runtime address of the object at the time of serialization. It is used for linking pointers in the object graph during deserialization.

 struct Field_object
 {
   uint32_t blobSize; // Size of the subsequent data blob.
 
   int16_t class; // Corresponds to an entry in the class table.
   uint32_t address;
 
   Field fields[]; // Arbitrary number of fields.
 };

The object pointer data type is a stripped down version of the header of the object data type. However it only contains the type and address of the object, with the address corresponding to an object somewhere in the graph.

 struct Field_object_pointer
 {
   int16_t class; // Corresponds to an entry in the class table.
   uint32_t address; // Corresponds to the address field of some object in the graph.
 };

Pair

The pair data type is simply holds two fields. It is primarily used by associative containers.

 struct Field_pair
 {
   Field first;
   Field second;
 };