STU Legacy

From owdev
Jump to: navigation, search

Common Types

struct array_definition_t {
  uint64 count;
  uint64 offset;
}
struct reference_array_definition_t {
  uint64 count;
  uint64 indice_offset; // each is a uint32, count is this structure's count
  uint64 reference_offset; // each is a reference_array_entry_t, count is the highest indice_offset value.
}

struct reference_array_entry_t {
  uint64 key; // this can either be the local instance ID, or a key, it depends on source format. see notes on page.
  uint64 offset; // offset to the instance.
}
struct instance_info_t {
  uint32 crc32; // crc32 of the STU's name 
  uint32 next; // offset to next instance
}

struct record_t {
  uint64 padding;
  uint64 key;
}

Structure

struct header {
  uint32 magic;                 // DUTS if LE, STUD if BE
  uint32 version;               // 
  uint64 instance_table_offset; // points to an array_definition_t of instance_table*
}
 
struct instance_table {
  uint32 offset;           // points to STUD reference or STUD blob
  uint32 flags;            // 
  uint64 key;              // use this to identify STUD BLOB Versions, removed in 1.5.0.0
}

You must always parse the instance table first and parse the STUD via that. Each STUD BLOB starts with a instance_info_t, use that struct's ID to identify which blob it is.