Correct structureddata structs ;)

This commit is contained in:
momo5502 2016-02-07 12:29:43 +01:00
parent 0a54d940bb
commit 43e756f5c0
3 changed files with 38 additions and 38 deletions

View File

@ -5,7 +5,7 @@ namespace Components
StructuredData* StructuredData::Singleton = nullptr; StructuredData* StructuredData::Singleton = nullptr;
int StructuredData::IndexCount[StructuredData::ENUM_MAX]; int StructuredData::IndexCount[StructuredData::ENUM_MAX];
Game::structuredDataEnumIndex_t* StructuredData::Indices[StructuredData::ENUM_MAX]; Game::StructuredDataEnumEntry* StructuredData::Indices[StructuredData::ENUM_MAX];
std::vector<StructuredData::EnumEntry> StructuredData::Entries[StructuredData::ENUM_MAX]; std::vector<StructuredData::EnumEntry> StructuredData::Entries[StructuredData::ENUM_MAX];
void StructuredData::AddPlayerDataEntry(StructuredData::PlayerDataType type, int index, std::string name) void StructuredData::AddPlayerDataEntry(StructuredData::PlayerDataType type, int index, std::string name)
@ -24,11 +24,11 @@ namespace Components
StructuredData::Entries[type].push_back({ name, index }); StructuredData::Entries[type].push_back({ name, index });
} }
void StructuredData::PatchPlayerDataEnum(Game::structuredDataDef_t* data, StructuredData::PlayerDataType type, std::vector<StructuredData::EnumEntry>& entries) void StructuredData::PatchPlayerDataEnum(Game::StructuredDataDefSet* data, StructuredData::PlayerDataType type, std::vector<StructuredData::EnumEntry>& entries)
{ {
if (!data || !data->data || type >= StructuredData::ENUM_MAX) return; if (!data || !data->data || type >= StructuredData::ENUM_MAX) return;
Game::structuredDataEnum_t* dataEnum = &data->data->enums[type]; Game::StructuredDataEnum* dataEnum = &data->data->enums[type];
if (StructuredData::IndexCount[type]) if (StructuredData::IndexCount[type])
{ {
@ -53,8 +53,8 @@ namespace Components
StructuredData::IndexCount[type] = dataEnum->numIndices + entries.size(); StructuredData::IndexCount[type] = dataEnum->numIndices + entries.size();
// Allocate new entries // Allocate new entries
StructuredData::Indices[type] = StructuredData::GetSingleton()->MemAllocator.AllocateArray<Game::structuredDataEnumIndex_t>(StructuredData::IndexCount[type]); StructuredData::Indices[type] = StructuredData::GetSingleton()->MemAllocator.AllocateArray<Game::StructuredDataEnumEntry>(StructuredData::IndexCount[type]);
memcpy(StructuredData::Indices[type], dataEnum->indices, sizeof(Game::structuredDataEnumIndex_t) * dataEnum->numIndices); memcpy(StructuredData::Indices[type], dataEnum->indices, sizeof(Game::StructuredDataEnumEntry) * dataEnum->numIndices);
for (unsigned int i = 0; i < entries.size(); i++) for (unsigned int i = 0; i < entries.size(); i++)
{ {
@ -76,7 +76,7 @@ namespace Components
for (unsigned int j = dataEnum->numIndices + i; j > pos && j < static_cast<unsigned int>(StructuredData::IndexCount[type]); j--) for (unsigned int j = dataEnum->numIndices + i; j > pos && j < static_cast<unsigned int>(StructuredData::IndexCount[type]); j--)
{ {
memcpy(&StructuredData::Indices[type][j], &StructuredData::Indices[type][j - 1], sizeof(Game::structuredDataEnumIndex_t)); memcpy(&StructuredData::Indices[type][j], &StructuredData::Indices[type][j - 1], sizeof(Game::StructuredDataEnumEntry));
} }
StructuredData::Indices[type][pos].index = entries[i].statOffset + lastIndex; StructuredData::Indices[type][pos].index = entries[i].statOffset + lastIndex;
@ -88,7 +88,7 @@ namespace Components
dataEnum->indices = StructuredData::Indices[type]; dataEnum->indices = StructuredData::Indices[type];
} }
void StructuredData::DumpDataDef(Game::structuredDataDef_t* dataDef) void StructuredData::DumpDataDef(Game::StructuredDataDefSet* dataDef)
{ {
if (!dataDef || !dataDef->data) return; if (!dataDef || !dataDef->data) return;
@ -123,7 +123,7 @@ namespace Components
if (filename == "mp/playerdata.def") if (filename == "mp/playerdata.def")
{ {
Game::structuredDataDef_t* data = AssetHandler::FindOriginalAsset(Game::XAssetType::ASSET_TYPE_STRUCTUREDDATADEF, filename.data()).structuredData; Game::StructuredDataDefSet* data = AssetHandler::FindOriginalAsset(Game::XAssetType::ASSET_TYPE_STRUCTUREDDATADEF, filename.data()).structuredData;
header.structuredData = data; header.structuredData = data;
if (data) if (data)

View File

@ -34,14 +34,14 @@ namespace Components
int statOffset; int statOffset;
}; };
static void DumpDataDef(Game::structuredDataDef_t* dataDef); static void DumpDataDef(Game::StructuredDataDefSet* dataDef);
static void PatchPlayerDataEnum(Game::structuredDataDef_t* data, PlayerDataType type, std::vector<EnumEntry>& entries); static void PatchPlayerDataEnum(Game::StructuredDataDefSet* data, PlayerDataType type, std::vector<EnumEntry>& entries);
static StructuredData* GetSingleton(); static StructuredData* GetSingleton();
Utils::Memory::Allocator MemAllocator; Utils::Memory::Allocator MemAllocator;
static int IndexCount[ENUM_MAX]; static int IndexCount[ENUM_MAX];
static Game::structuredDataEnumIndex_t* Indices[ENUM_MAX]; static Game::StructuredDataEnumEntry* Indices[ENUM_MAX];
static std::vector<EnumEntry> Entries[ENUM_MAX]; static std::vector<EnumEntry> Entries[ENUM_MAX];
static StructuredData* Singleton; static StructuredData* Singleton;

View File

@ -1157,83 +1157,83 @@ namespace Game
STRUCTURED_DATA_ENUMARR = 7, STRUCTURED_DATA_ENUMARR = 7,
STRUCTURED_DATA_FLOAT = 8, STRUCTURED_DATA_FLOAT = 8,
STRUCTURED_DATA_SHORT = 9 STRUCTURED_DATA_SHORT = 9
} structuredDataType_t; } StructuredDataType;
typedef struct typedef struct
{ {
structuredDataType_t type; StructuredDataType type;
union union
{ {
int index; int index;
}; };
int offset; int offset;
} structuredDataItem_t; } StructuredDataItem;
typedef struct typedef struct
{ {
const char* name; const char* name;
structuredDataItem_t item; StructuredDataItem item;
} structuredDataChild_t; } StructuredDataStructProperty;
typedef struct typedef struct
{ {
int numChildren; int numProperties;
structuredDataChild_t* children; StructuredDataStructProperty* property;
int unknown1; int unknown1;
int unknown2; int unknown2;
} structuredDataStruct_t; } StructuredDataStruct;
typedef struct typedef struct
{ {
int enumIndex; int enumIndex;
structuredDataItem_t item; StructuredDataItem item;
} structuredDataEnumArray_t; } StructuredDataEnumedArray;
typedef struct typedef struct
{ {
const char* key; const char* key;
int index; int index;
} structuredDataEnumIndex_t; } StructuredDataEnumEntry;
typedef struct typedef struct
{ {
int numIndices; int numIndices;
int unknown; int unknown;
structuredDataEnumIndex_t* indices; StructuredDataEnumEntry* indices;
} structuredDataEnum_t; } StructuredDataEnum;
typedef struct typedef struct
{ {
int numItems; int numItems;
structuredDataItem_t item; StructuredDataItem item;
} structuredDataIndexedArray_t; } StructuredDataIndexedArray;
typedef struct typedef struct
{ {
int version; int version;
unsigned int hash; unsigned int hash;
int numEnums; int numEnums;
structuredDataEnum_t* enums; StructuredDataEnum* enums;
int numStructs; int numStructs;
structuredDataStruct_t* structs; StructuredDataStruct* structs;
int numIndexedArrays; int numIndexedArrays;
structuredDataIndexedArray_t* indexedArrays; StructuredDataIndexedArray* indexedArrays;
int numEnumArrays; int numEnumArrays;
structuredDataEnumArray_t* enumArrays; StructuredDataEnumedArray* enumArrays;
structuredDataItem_t rootItem; StructuredDataItem rootItem;
} structuredData_t; } StructuredDataDef;
typedef struct typedef struct
{ {
const char* name; const char* name;
int unknown; int count;
structuredData_t* data; StructuredDataDef* data;
} structuredDataDef_t; } StructuredDataDefSet;
typedef struct typedef struct
{ {
structuredData_t* data; StructuredDataDef* data;
structuredDataItem_t* item; StructuredDataItem* item;
int offset; int offset;
int error; int error;
} structuredDataFindState_t; } structuredDataFindState_t;
@ -1602,7 +1602,7 @@ namespace Game
MaterialVertexDeclaration *vertexDecl; MaterialVertexDeclaration *vertexDecl;
MaterialVertexShader *vertexShader; MaterialVertexShader *vertexShader;
MaterialPixelShader *pixelShader; MaterialPixelShader *pixelShader;
structuredDataDef_t* structuredData; StructuredDataDefSet* structuredData;
XModel* model; XModel* model;
PhysPreset* physPreset; PhysPreset* physPreset;
PhysCollmap* physCollmap; PhysCollmap* physCollmap;