diff --git a/src/ZoneCode.lua b/src/ZoneCode.lua index bb933222..86d66855 100644 --- a/src/ZoneCode.lua +++ b/src/ZoneCode.lua @@ -34,7 +34,7 @@ ZoneCode.Assets = { "RawFile", "StringTable", "LeaderboardDef", - -- "StructuredDataDefSet", + "StructuredDataDefSet", "TracerDef", -- "VehicleDef", -- "AddonMapEnts" diff --git a/src/ZoneCode/Game/IW4/IW4_Commands.txt b/src/ZoneCode/Game/IW4/IW4_Commands.txt index 397df02a..d94eb612 100644 --- a/src/ZoneCode/Game/IW4/IW4_Commands.txt +++ b/src/ZoneCode/Game/IW4/IW4_Commands.txt @@ -34,7 +34,7 @@ asset FxImpactTable ASSET_TYPE_IMPACT_FX; asset RawFile ASSET_TYPE_RAWFILE; asset StringTable ASSET_TYPE_STRINGTABLE; asset LeaderboardDef ASSET_TYPE_LEADERBOARD; -// asset StructuredDataDefSet ASSET_TYPE_STRUCTURED_DATA_DEF; +asset StructuredDataDefSet ASSET_TYPE_STRUCTURED_DATA_DEF; asset TracerDef ASSET_TYPE_TRACER; // asset VehicleDef ASSET_TYPE_VEHICLE; // asset AddonMapEnts ASSET_TYPE_ADDON_MAP_ENTS; @@ -665,6 +665,33 @@ use LbColumnDef; set string name; set string statName; +// ========================================= +// StructuredDataDefSet +// ========================================= +use StructuredDataDefSet; +set string name; +set name name; +set count defs defCount; + +// StructuredDataDef +use StructuredDataDef; +set count enums enumCount; +set count structs structCount; +set count indexedArrays indexedArrayCount; +set count enumedArrays enumedArrayCount; + +// StructuredDataEnum +set count StructuredDataEnum::entries entryCount; + +// StructuredDataEnumEntry +set string StructuredDataEnumEntry::string; + +// StructuredDataStruct +set count StructuredDataStruct::properties propertyCount; + +// StructuredDataStructProperty +set string StructuredDataStructProperty::name; + // ========================================= // TracerDef // ========================================= diff --git a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp index d4485e7d..11a2616a 100644 --- a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp +++ b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp @@ -135,7 +135,7 @@ GameAssetPoolIW4::GameAssetPoolIW4(const int priority) m_raw_file = nullptr; m_string_table = nullptr; m_leaderboard = nullptr; - // m_structed_data_def_set = nullptr; + m_structed_data_def_set = nullptr; m_tracer = nullptr; // m_vehicle = nullptr; // m_addon_map_ents = nullptr; @@ -188,7 +188,7 @@ void GameAssetPoolIW4::InitPoolStatic(const asset_type_t type, const size_t capa CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile); CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable); CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard, LeaderboardDef); - // CASE_INIT_POOL_STATIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, StructuredDataDefSet); + CASE_INIT_POOL_STATIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, StructuredDataDefSet); CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer, TracerDef); // CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE, m_vehicle, VehicleDef); // CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts); @@ -248,7 +248,7 @@ void GameAssetPoolIW4::InitPoolDynamic(const asset_type_t type) CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard, LeaderboardDef); - // CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, StructuredDataDefSet); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, StructuredDataDefSet); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer, TracerDef); // CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE, m_vehicle, VehicleDef); // CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts); @@ -317,7 +317,7 @@ XAssetInfoGeneric* GameAssetPoolIW4::AddAsset(asset_type_t type, std::string nam CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file, rawfile); CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table, stringTable); CASE_ADD_TO_POOL(ASSET_TYPE_LEADERBOARD, m_leaderboard, leaderboardDef); - // CASE_ADD_TO_POOL(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, structuredDataDefSet); + CASE_ADD_TO_POOL(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, structuredDataDefSet); CASE_ADD_TO_POOL(ASSET_TYPE_TRACER, m_tracer, tracerDef); // CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLE, m_vehicle, vehDef); // CASE_ADD_TO_POOL(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, addonMapEnts); @@ -377,7 +377,7 @@ XAssetInfoGeneric* GameAssetPoolIW4::GetAsset(const asset_type_t type, std::stri CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file); CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table); CASE_GET_ASSET(ASSET_TYPE_LEADERBOARD, m_leaderboard); - // CASE_GET_ASSET(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set); + CASE_GET_ASSET(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set); CASE_GET_ASSET(ASSET_TYPE_TRACER, m_tracer); // CASE_GET_ASSET(ASSET_TYPE_VEHICLE, m_vehicle); // CASE_GET_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents); diff --git a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h index e0b2d3b8..87b8eafc 100644 --- a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h +++ b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h @@ -47,7 +47,7 @@ public: std::unique_ptr> m_raw_file; std::unique_ptr> m_string_table; std::unique_ptr> m_leaderboard; - // std::unique_ptr> m_structed_data_def_set; + std::unique_ptr> m_structed_data_def_set; std::unique_ptr> m_tracer; // std::unique_ptr> m_vehicle; // std::unique_ptr> m_addon_map_ents; diff --git a/src/ZoneCommon/Game/IW4/IW4_Assets.h b/src/ZoneCommon/Game/IW4/IW4_Assets.h index 41c7a8f6..733a2a86 100644 --- a/src/ZoneCommon/Game/IW4/IW4_Assets.h +++ b/src/ZoneCommon/Game/IW4/IW4_Assets.h @@ -106,7 +106,7 @@ namespace IW4 struct RawFile; struct StringTable; struct LeaderboardDef; - // struct StructuredDataDefSet; + struct StructuredDataDefSet; struct TracerDef; // struct VehicleDef; // struct AddonMapEnts; @@ -146,7 +146,7 @@ namespace IW4 RawFile* rawfile; StringTable* stringTable; LeaderboardDef* leaderboardDef; - // StructuredDataDefSet* structuredDataDefSet; + StructuredDataDefSet* structuredDataDefSet; TracerDef* tracerDef; // VehicleDef* vehDef; // AddonMapEnts* addonMapEnts; @@ -1693,6 +1693,101 @@ namespace IW4 float colors[5][4]; }; + 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, + }; + + struct __declspec(align(4)) StructuredDataEnumEntry + { + const char* string; + unsigned __int16 index; + }; + + 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; + }; + + struct StructuredDataStructProperty + { + const char* name; + StructuredDataType type; + unsigned int offset; + }; + + 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; + }; + #ifndef __zonecodegenerator } #endif diff --git a/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp b/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp index 9aaee703..6cd9cdfc 100644 --- a/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp +++ b/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp @@ -34,7 +34,7 @@ #include "Game/IW4/XAssets/sndcurve/sndcurve_load_db.h" //#include "Game/IW4/XAssets/snddriverglobals/snddriverglobals_load_db.h" #include "Game/IW4/XAssets/stringtable/stringtable_load_db.h" -//#include "Game/IW4/XAssets/structureddatadefset/structureddatadefset_load_db.h" +#include "Game/IW4/XAssets/structureddatadefset/structureddatadefset_load_db.h" #include "Game/IW4/XAssets/tracerdef/tracerdef_load_db.h" //#include "Game/IW4/XAssets/vehicledef/vehicledef_load_db.h" //#include "Game/IW4/XAssets/weaponcompletedef/weaponcompletedef_load_db.h" @@ -136,8 +136,8 @@ void ContentLoaderIW4::LoadXAsset(const bool atStreamStart) LOAD_ASSET(ASSET_TYPE_RAWFILE, RawFile, rawfile); LOAD_ASSET(ASSET_TYPE_STRINGTABLE, StringTable, stringTable); LOAD_ASSET(ASSET_TYPE_LEADERBOARD, LeaderboardDef, leaderboardDef); - // LOAD_ASSET(ASSET_TYPE_STRUCTURED_DATA_DEF, StructuredDataDefSet, structuredDataDefSet); - LOAD_ASSET(ASSET_TYPE_TRACER, TracerDef, tracerDef); + LOAD_ASSET(ASSET_TYPE_STRUCTURED_DATA_DEF, StructuredDataDefSet, structuredDataDefSet); + LOAD_ASSET(ASSET_TYPE_TRACER, TracerDef, tracerDef); // LOAD_ASSET(ASSET_TYPE_VEHICLE, VehicleDef, vehDef); // LOAD_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, AddonMapEnts, addonMapEnts);