StructuredDataDef Asset: Difference between revisions

From COD Engine Research
No edit summary
No edit summary
Line 1: Line 1:
__NOTOC__
[[Category:Assets]]
[[Category:Assets]]
[[Category:MW2]]
[[Category:MW2]]
Line 19: Line 20:
};
};


#pragma pack(push,4)
struct EnumEntry
struct EnumEntry
{
{
#ifdef IW6 // if it is Ghosts..
#ifdef IW6 // if it is Ghosts..
   ScriptString name;
   ScriptString name;
  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 DefinedEnum
Line 47: Line 48:
   int indexedArrIndex;
   int indexedArrIndex;
   int structIndex;
   int structIndex;
};
struct StructureEntryItem
{
  DataType type;
  TypeData data;
  int index;
};
};


Line 54: Line 62:
#ifdef IW6 // if it is Ghosts..
#ifdef IW6 // if it is Ghosts..
   ScriptString name;
   ScriptString name;
#else
  const char *name;
#endif
#endif
   DataType type;
   StructureEntryItem item;
  TypeData data;
  int index;
#ifndef IW4 // if not Modern Warfare 2..
#ifndef IW4 // if not Modern Warfare 2..
   int unknown;
   int unknown;
Line 75: Line 83:
{
{
   int numItems;
   int numItems;
   DataType type;
   StructureEntryItem item;
  TypeData data;
  int size;
};
};


Line 83: Line 89:
{
{
   int enumIndex;
   int enumIndex;
   DataType type;
   StructureEntryItem item;
  TypeData data;
  int size;
};
};


Line 100: Line 104:
   int enumArrayCount;
   int enumArrayCount;
   DefinedEnumArray *enumArrays;
   DefinedEnumArray *enumArrays;
   int unknown1;
   StructureEntryItem rootItem;
  int unknown2;
  int unknown3;
};
};


Line 112: Line 114:
};
};
</syntaxhighlight>
</syntaxhighlight>
Notice that on Ghosts 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.
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.

Revision as of 18:10, 13 January 2014

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.

enum DataType
{
  STRUCTURED_DATA_INT = 0,
  STRUCTURED_DATA_BYTE = 1,
  STRUCTURED_DATA_BOOL = 2,
  STRUCTURED_DATA_STRING = 3,
  STRUCTURED_DATA_ENUM = 4,
  STRUCTURED_DATA_STRUCT = 5,
  STRUCTURED_DATA_INDEXEDARR = 6,
  STRUCTURED_DATA_ENUMARR = 7,
  STRUCTURED_DATA_FLOAT = 8,
  STRUCTURED_DATA_SHORT = 9
};

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

struct DefinedEnum
{
  int entryCount;
  int unknown;
  EnumEntry *entries;
};

union TypeData
{
  int integer;
  int stringSize;
  int flags;
  int enumIndex;
  int enumArrIndex;
  int indexedArrIndex;
  int structIndex;
};

struct StructureEntryItem
{
  DataType type;
  TypeData data;
  int index;
};

#pragma pack(push,4)
struct StructureEntry
{
#ifdef IW6 // if it is Ghosts..
  ScriptString name;
#else
  const char *name;
#endif
  StructureEntryItem item;
#ifndef IW4 // if not Modern Warfare 2..
  int unknown;
#endif
};
#pragma pack(pop)

struct DefinedStructure
{
  int entryCount;
  StructureEntry *entries;
  int size;
  int unknown;
};

struct DefinedIndexedArray
{
  int numItems;
  StructureEntryItem item;
};

struct DefinedEnumArray
{
  int enumIndex;
  StructureEntryItem item;
};

struct StructuredData
{
  int version;
  int hash;
  int enumCount;
  DefinedEnum *enums;
  int structureCount;
  DefinedStructure *structures;
  int indexedArrCount;
  DefinedIndexedArray *indexedArrays;
  int enumArrayCount;
  DefinedEnumArray *enumArrays;
  StructureEntryItem rootItem;
};

struct StructuredDataDef
{
  const char *name;
  int numEntries;
  StructuredData *entries;
};

Notice that on Ghosts 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.

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.