StructuredDataDef Asset: Difference between revisions

From COD Engine Research
No edit summary
Therifboy (talk | contribs)
mNo edit summary
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
[[Category:Assets]]
[[Category:Assets]]
[[Category:MW2]]
[[Category:MW2]]
[[Category:MW3]]
[[Category:MW3]]
[[Category:Ghosts]]
[[Category:Ghosts]]
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, and Ghosts.
[[Category:AW]]
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.
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
enum DataType
enum StructuredDataTypeCategory
{
{
   STRUCTURED_DATA_INT = 0,
   DATA_INT = 0x0,
   STRUCTURED_DATA_BYTE = 1,
   DATA_BYTE = 0x1,
   STRUCTURED_DATA_BOOL = 2,
   DATA_BOOL = 0x2,
   STRUCTURED_DATA_STRING = 3,
   DATA_STRING = 0x3,
   STRUCTURED_DATA_ENUM = 4,
   DATA_ENUM = 0x4,
   STRUCTURED_DATA_STRUCT = 5,
   DATA_STRUCT = 0x5,
   STRUCTURED_DATA_INDEXEDARR = 6,
   DATA_INDEXED_ARRAY = 0x6,
   STRUCTURED_DATA_ENUMARR = 7,
   DATA_ENUM_ARRAY = 0x7,
   STRUCTURED_DATA_FLOAT = 8,
   DATA_FLOAT = 0x8,
   STRUCTURED_DATA_SHORT = 9
   DATA_SHORT = 0x9,
  DATA_COUNT = 0xA,
};
};


struct EnumEntry
#pragma pack(push,4)
struct StructuredDataEnumEntry
{
{
#ifdef IW6 // if it is Ghosts..
#ifdef IW6 // if it is Ghosts..
   ScriptString name;
   scr_string_t string;
  unsigned __int16 index;
#else
#else
   const char *name;
   const char *name;
#endif
   unsigned __int16 index;
   unsigned __int16 index;
  unsigned __int16 unused;
#endif
};
};
#pragma pack(pop)


struct DefinedEnum
struct StructuredDataEnum
{
{
   int entryCount;
   int entryCount;
   int unknown;
   int reservedEntryCount;
   EnumEntry *entries;
   StructuredDataEnumEntry *entries;
};
};


union TypeData
union StructuredDataTypeUnion
{
{
   int integer;
   unsigned int stringDataLength;
  int stringSize;
  int flags;
   int enumIndex;
   int enumIndex;
  int enumArrIndex;
  int indexedArrIndex;
   int structIndex;
   int structIndex;
  int indexedArrayIndex;
  int enumedArrayIndex;
};
struct StructuredDataType
{
  StructuredDataTypeCategory type;
  StructuredDataTypeUnion u;
};
};


#pragma pack(push,4)
#pragma pack(push,4)
struct StructureEntry
struct StructuredDataStructProperty
{
{
#ifdef IW6 // if it is Ghosts..
#if defined(IW6) || defined(S1) // if it is Ghosts or Advanced Warfare..
   ScriptString name;
   scr_string_t name;
#else
  const char *name;
#endif
#endif
   DataType type;
   StructuredDataType item;
  TypeData data;
   int offset;
   int index;
#ifndef IW4 // if not Modern Warfare 2..
#ifndef IW4 // if not Modern Warfare 2..
   int unknown;
   StructuredDataValidationType validation;
#endif
#endif
};
};
#pragma pack(pop)
#pragma pack(pop)


struct DefinedStructure
struct StructuredDataStruct
{
{
   int entryCount;
   int propertyCount;
   StructureEntry *entries;
   StructuredDataStructProperty *properties;
   int size;
   int size;
   int unknown;
   unsigned int bitOffset;
};
};


struct DefinedIndexedArray
struct StructuredDataIndexedArray
{
{
   int numItems;
   int arraySize;
   DataType type;
   StructuredDataType elementType;
  TypeData data;
   unsigned int elementSize;
   int size;
};
};


struct DefinedEnumArray
struct StructuredDataEnumedArray
{
{
   int enumIndex;
   int enumIndex;
   DataType type;
   StructuredDataType elementType;
  TypeData data;
   unsigned int elementSize;
   int size;
};
};


struct StructuredData
struct StructuredDataDef
{
{
   int version;
   int version;
   int hash;
   unsigned int formatChecksum;
   int enumCount;
   int enumCount;
   DefinedEnum *enums;
   StructuredDataEnum *enums;
   int structureCount;
   int structCount;
   DefinedStructure *structures;
   StructuredDataStruct *structs;
   int indexedArrCount;
   int indexedArrayCount;
   DefinedIndexedArray *indexedArrays;
   StructuredDataIndexedArray *indexedArrays;
   int enumArrayCount;
   int enumedArrayCount;
   DefinedEnumArray *enumArrays;
   StructuredDataEnumedArray *enumedArrays;
   int unknown1;
   StructuredDataType rootType;
  int unknown2;
   unsigned int size;
   int unknown3;
};
};


struct StructuredDataDef
struct StructuredDataDefSet
{
{
   const char *name;
   const char *name;
   int numEntries;
   unsigned int defCount;
   StructuredData *entries;
   StructuredDataDef *defs;
};
};
</syntaxhighlight>
</syntaxhighlight>
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.

Latest revision as of 14:45, 12 January 2015

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.