StructuredDataDef Asset: Difference between revisions
No edit summary |
mNo edit summary |
||
| (4 intermediate revisions by 2 users not shown) | |||
| Line 4: | Line 4: | ||
[[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 | [[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 | 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) | #pragma pack(push,4) | ||
struct | struct StructuredDataEnumEntry | ||
{ | { | ||
#ifdef IW6 // if it is Ghosts.. | #ifdef IW6 // if it is Ghosts.. | ||
scr_string_t string; | |||
#else | #else | ||
const char *name; | const char *name; | ||
| Line 32: | Line 34: | ||
#pragma pack(pop) | #pragma pack(pop) | ||
struct | struct StructuredDataEnum | ||
{ | { | ||
int entryCount; | int entryCount; | ||
int | int reservedEntryCount; | ||
StructuredDataEnumEntry *entries; | |||
}; | }; | ||
union | union StructuredDataTypeUnion | ||
{ | { | ||
int | unsigned int stringDataLength; | ||
int enumIndex; | int enumIndex; | ||
int structIndex; | int structIndex; | ||
int indexedArrayIndex; | |||
int enumedArrayIndex; | |||
}; | }; | ||
struct | struct StructuredDataType | ||
{ | { | ||
StructuredDataTypeCategory type; | |||
StructuredDataTypeUnion u; | |||
}; | }; | ||
#pragma pack(push,4) | #pragma pack(push,4) | ||
struct | struct StructuredDataStructProperty | ||
{ | { | ||
# | #if defined(IW6) || defined(S1) // if it is Ghosts or Advanced Warfare.. | ||
scr_string_t name; | |||
#else | #else | ||
const char *name; | const char *name; | ||
#endif | #endif | ||
StructuredDataType item; | |||
int offset; | |||
#ifndef IW4 // if not Modern Warfare 2.. | #ifndef IW4 // if not Modern Warfare 2.. | ||
StructuredDataValidationType validation; | |||
#endif | #endif | ||
}; | }; | ||
#pragma pack(pop) | #pragma pack(pop) | ||
struct | struct StructuredDataStruct | ||
{ | { | ||
int | int propertyCount; | ||
StructuredDataStructProperty *properties; | |||
int size; | int size; | ||
int | unsigned int bitOffset; | ||
}; | }; | ||
struct | struct StructuredDataIndexedArray | ||
{ | { | ||
int | int arraySize; | ||
StructuredDataType elementType; | |||
unsigned int elementSize; | |||
}; | }; | ||
struct | struct StructuredDataEnumedArray | ||
{ | { | ||
int enumIndex; | int enumIndex; | ||
StructuredDataType elementType; | |||
unsigned int elementSize; | |||
}; | }; | ||
struct | struct StructuredDataDef | ||
{ | { | ||
int version; | int version; | ||
int | unsigned int formatChecksum; | ||
int enumCount; | int enumCount; | ||
StructuredDataEnum *enums; | |||
int | int structCount; | ||
StructuredDataStruct *structs; | |||
int | int indexedArrayCount; | ||
StructuredDataIndexedArray *indexedArrays; | |||
int | int enumedArrayCount; | ||
StructuredDataEnumedArray *enumedArrays; | |||
StructuredDataType rootType; | |||
unsigned int size; | |||
}; | }; | ||
struct | struct StructuredDataDefSet | ||
{ | { | ||
const char *name; | const char *name; | ||
int | unsigned int defCount; | ||
StructuredDataDef *defs; | |||
}; | }; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Notice that on Ghosts all strings were replaced with ScriptStrings, which caused EnumEntry to drop to 4 bytes. | 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/". | The official source format is currently unknown, however they still must be dumped for use. The structureddatadefs are defined at "raw/mp/". | ||
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.