StructuredDataDef Asset

From COD Engine Research
Jump to: navigation, search

The structureddatadef asset stores information for data structures and enums used by the game. This asset is only used on Modern Warfare 2, Modern Warfare 3, Ghosts and Advanced Warfare.

enum StructuredDataTypeCategory
{
  DATA_INT = 0x0,
  DATA_BYTE = 0x1,
  DATA_BOOL = 0x2,
  DATA_STRING = 0x3,
  DATA_ENUM = 0x4,
  DATA_STRUCT = 0x5,
  DATA_INDEXED_ARRAY = 0x6,
  DATA_ENUM_ARRAY = 0x7,
  DATA_FLOAT = 0x8,
  DATA_SHORT = 0x9,
  DATA_COUNT = 0xA,
};
 
#pragma pack(push,4)
struct StructuredDataEnumEntry
{
#ifdef IW6 // if it is Ghosts..
  scr_string_t string;
#else
  const char *name;
#endif
  unsigned __int16 index;
};
#pragma pack(pop)
 
struct StructuredDataEnum
{
  int entryCount;
  int reservedEntryCount;
  StructuredDataEnumEntry *entries;
};
 
union StructuredDataTypeUnion
{
  unsigned int stringDataLength;
  int enumIndex;
  int structIndex;
  int indexedArrayIndex;
  int enumedArrayIndex;
};
 
struct StructuredDataType
{
  StructuredDataTypeCategory type;
  StructuredDataTypeUnion u;
};
 
#pragma pack(push,4)
struct StructuredDataStructProperty
{
#if defined(IW6) || defined(S1) // if it is Ghosts or Advanced Warfare..
  scr_string_t name;
#else
  const char *name;
#endif
  StructuredDataType item;
  int offset;
#ifndef IW4 // if not Modern Warfare 2..
  StructuredDataValidationType validation;
#endif
};
#pragma pack(pop)
 
struct StructuredDataStruct
{
  int propertyCount;
  StructuredDataStructProperty *properties;
  int size;
  unsigned int bitOffset;
};
 
struct StructuredDataIndexedArray
{
  int arraySize;
  StructuredDataType elementType;
  unsigned int elementSize;
};
 
struct StructuredDataEnumedArray
{
  int enumIndex;
  StructuredDataType elementType;
  unsigned int elementSize;
};
 
struct StructuredDataDef
{
  int version;
  unsigned int formatChecksum;
  int enumCount;
  StructuredDataEnum *enums;
  int structCount;
  StructuredDataStruct *structs;
  int indexedArrayCount;
  StructuredDataIndexedArray *indexedArrays;
  int enumedArrayCount;
  StructuredDataEnumedArray *enumedArrays;
  StructuredDataType rootType;
  unsigned int size;
};
 
struct StructuredDataDefSet
{
  const char *name;
  unsigned int defCount;
  StructuredDataDef *defs;
};

Notice that on Ghosts and Advanced Warfare all strings were replaced with ScriptStrings, which caused EnumEntry to drop to 4 bytes.

Source Format

The official source format is currently unknown, however they still must be dumped for use. The structureddatadefs are defined at "raw/mp/".

First enums must be dumped. These are very simple with each DefinedEnum an individual enum and EnumEntry (holding the name and enum index value), a value in the enum.

Structures are the second and last item to be dumped. Each DefinedStructure is a structure to be used, and each StructureEntry is an item in the structure. The "index" in the StructureEntryItem for each item is the byte offset of the item in the structure. If the entry item has a "ENUM" or "STRUCT" type then the "data" will be an integer with the index of the enum or struct to use in this StructuredData. If the entry item has a "INDEXEDARR" or "ENUMARR" type then the "data" will be an integer with the index of the "indexedArray" or "enumArray" to use. The array item will then have the type of the element to use. It is possible for an "indexedArray" or "enumArray" to also have a type of "INDEXEDARR" or "ENUMARR" in which case it will be a double array. An "indexedArray" will contain the number of items in the array while the "enumArray" will contain the index for the enum to use for this array. The array will have 1 element for each element in the array, and members will be referenced by their enum value.