From 43e756f5c086f2cc33f8be6f3162116258898490 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 7 Feb 2016 12:29:43 +0100 Subject: [PATCH] Correct structureddata structs ;) --- src/Components/Modules/StructuredData.cpp | 16 +++---- src/Components/Modules/StructuredData.hpp | 6 +-- src/Game/Structs.hpp | 54 +++++++++++------------ 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/Components/Modules/StructuredData.cpp b/src/Components/Modules/StructuredData.cpp index 20fd9f7f..04f334ca 100644 --- a/src/Components/Modules/StructuredData.cpp +++ b/src/Components/Modules/StructuredData.cpp @@ -5,7 +5,7 @@ namespace Components StructuredData* StructuredData::Singleton = nullptr; int StructuredData::IndexCount[StructuredData::ENUM_MAX]; - Game::structuredDataEnumIndex_t* StructuredData::Indices[StructuredData::ENUM_MAX]; + Game::StructuredDataEnumEntry* StructuredData::Indices[StructuredData::ENUM_MAX]; std::vector StructuredData::Entries[StructuredData::ENUM_MAX]; void StructuredData::AddPlayerDataEntry(StructuredData::PlayerDataType type, int index, std::string name) @@ -24,11 +24,11 @@ namespace Components StructuredData::Entries[type].push_back({ name, index }); } - void StructuredData::PatchPlayerDataEnum(Game::structuredDataDef_t* data, StructuredData::PlayerDataType type, std::vector& entries) + void StructuredData::PatchPlayerDataEnum(Game::StructuredDataDefSet* data, StructuredData::PlayerDataType type, std::vector& entries) { 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]) { @@ -53,8 +53,8 @@ namespace Components StructuredData::IndexCount[type] = dataEnum->numIndices + entries.size(); // Allocate new entries - StructuredData::Indices[type] = StructuredData::GetSingleton()->MemAllocator.AllocateArray(StructuredData::IndexCount[type]); - memcpy(StructuredData::Indices[type], dataEnum->indices, sizeof(Game::structuredDataEnumIndex_t) * dataEnum->numIndices); + StructuredData::Indices[type] = StructuredData::GetSingleton()->MemAllocator.AllocateArray(StructuredData::IndexCount[type]); + memcpy(StructuredData::Indices[type], dataEnum->indices, sizeof(Game::StructuredDataEnumEntry) * dataEnum->numIndices); 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(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; @@ -88,7 +88,7 @@ namespace Components dataEnum->indices = StructuredData::Indices[type]; } - void StructuredData::DumpDataDef(Game::structuredDataDef_t* dataDef) + void StructuredData::DumpDataDef(Game::StructuredDataDefSet* dataDef) { if (!dataDef || !dataDef->data) return; @@ -123,7 +123,7 @@ namespace Components 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; if (data) diff --git a/src/Components/Modules/StructuredData.hpp b/src/Components/Modules/StructuredData.hpp index fc5118b7..e720f1ba 100644 --- a/src/Components/Modules/StructuredData.hpp +++ b/src/Components/Modules/StructuredData.hpp @@ -34,14 +34,14 @@ namespace Components int statOffset; }; - static void DumpDataDef(Game::structuredDataDef_t* dataDef); - static void PatchPlayerDataEnum(Game::structuredDataDef_t* data, PlayerDataType type, std::vector& entries); + static void DumpDataDef(Game::StructuredDataDefSet* dataDef); + static void PatchPlayerDataEnum(Game::StructuredDataDefSet* data, PlayerDataType type, std::vector& entries); static StructuredData* GetSingleton(); Utils::Memory::Allocator MemAllocator; static int IndexCount[ENUM_MAX]; - static Game::structuredDataEnumIndex_t* Indices[ENUM_MAX]; + static Game::StructuredDataEnumEntry* Indices[ENUM_MAX]; static std::vector Entries[ENUM_MAX]; static StructuredData* Singleton; diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index fe1945c2..6d831dec 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -1157,83 +1157,83 @@ namespace Game STRUCTURED_DATA_ENUMARR = 7, STRUCTURED_DATA_FLOAT = 8, STRUCTURED_DATA_SHORT = 9 - } structuredDataType_t; + } StructuredDataType; typedef struct { - structuredDataType_t type; + StructuredDataType type; union { int index; }; int offset; - } structuredDataItem_t; + } StructuredDataItem; typedef struct { const char* name; - structuredDataItem_t item; - } structuredDataChild_t; + StructuredDataItem item; + } StructuredDataStructProperty; typedef struct { - int numChildren; - structuredDataChild_t* children; + int numProperties; + StructuredDataStructProperty* property; int unknown1; int unknown2; - } structuredDataStruct_t; + } StructuredDataStruct; typedef struct { int enumIndex; - structuredDataItem_t item; - } structuredDataEnumArray_t; + StructuredDataItem item; + } StructuredDataEnumedArray; typedef struct { const char* key; int index; - } structuredDataEnumIndex_t; + } StructuredDataEnumEntry; typedef struct { int numIndices; int unknown; - structuredDataEnumIndex_t* indices; - } structuredDataEnum_t; + StructuredDataEnumEntry* indices; + } StructuredDataEnum; typedef struct { int numItems; - structuredDataItem_t item; - } structuredDataIndexedArray_t; + StructuredDataItem item; + } StructuredDataIndexedArray; typedef struct { int version; unsigned int hash; int numEnums; - structuredDataEnum_t* enums; + StructuredDataEnum* enums; int numStructs; - structuredDataStruct_t* structs; + StructuredDataStruct* structs; int numIndexedArrays; - structuredDataIndexedArray_t* indexedArrays; + StructuredDataIndexedArray* indexedArrays; int numEnumArrays; - structuredDataEnumArray_t* enumArrays; - structuredDataItem_t rootItem; - } structuredData_t; + StructuredDataEnumedArray* enumArrays; + StructuredDataItem rootItem; + } StructuredDataDef; typedef struct { const char* name; - int unknown; - structuredData_t* data; - } structuredDataDef_t; + int count; + StructuredDataDef* data; + } StructuredDataDefSet; typedef struct { - structuredData_t* data; - structuredDataItem_t* item; + StructuredDataDef* data; + StructuredDataItem* item; int offset; int error; } structuredDataFindState_t; @@ -1602,7 +1602,7 @@ namespace Game MaterialVertexDeclaration *vertexDecl; MaterialVertexShader *vertexShader; MaterialPixelShader *pixelShader; - structuredDataDef_t* structuredData; + StructuredDataDefSet* structuredData; XModel* model; PhysPreset* physPreset; PhysCollmap* physCollmap;