diff --git a/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp b/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp index 31597d9f..1beb111a 100644 --- a/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp +++ b/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp @@ -71,7 +71,7 @@ namespace IW4 void ObjLoader::LoadImageData(ISearchPath* searchPath, Zone* zone) { - auto* assetPool = dynamic_cast(zone->GetPools()); + auto* assetPool = dynamic_cast(zone->m_pools.get()); if (assetPool && assetPool->m_image != nullptr) { diff --git a/src/ObjLoading/Game/T6/ObjLoaderT6.cpp b/src/ObjLoading/Game/T6/ObjLoaderT6.cpp index a6af175e..eddc055e 100644 --- a/src/ObjLoading/Game/T6/ObjLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/ObjLoaderT6.cpp @@ -107,7 +107,7 @@ namespace T6 void ObjLoader::LoadReferencedContainersForZone(ISearchPath* searchPath, Zone* zone) const { - auto* assetPoolT6 = dynamic_cast(zone->GetPools()); + auto* assetPoolT6 = dynamic_cast(zone->m_pools.get()); const int zoneNameHash = CommonT6::Com_HashKey(zone->m_name.c_str(), 64); LoadCommonIPaks(searchPath, zone); @@ -197,7 +197,7 @@ namespace T6 void ObjLoader::LoadImageData(ISearchPath* searchPath, Zone* zone) { - auto* assetPoolT6 = dynamic_cast(zone->GetPools()); + auto* assetPoolT6 = dynamic_cast(zone->m_pools.get()); if (assetPoolT6 && assetPoolT6->m_image != nullptr) { diff --git a/src/ObjWriting/Game/IW4/ZoneDumperIW4.cpp b/src/ObjWriting/Game/IW4/ZoneDumperIW4.cpp index 46565cbf..3c85e336 100644 --- a/src/ObjWriting/Game/IW4/ZoneDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/ZoneDumperIW4.cpp @@ -26,7 +26,7 @@ bool ZoneDumper::DumpZone(Zone* zone, const std::string& basePath) const dumper.DumpPool(zone, assetPools->poolName.get(), basePath); \ } - const auto* assetPools = dynamic_cast(zone->GetPools()); + const auto* assetPools = dynamic_cast(zone->m_pools.get()); // DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset) // DUMP_ASSET_POOL(AssetDumperPhysCollmap, m_phys_collmap) diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.cpp index 430f3e4d..8720d55a 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.cpp @@ -1450,7 +1450,7 @@ namespace T6 std::stringstream ss; bool first = true; - for(auto i = 0u; i < _countof(WeaponFullDef::notetrackSoundMapKeys); i++) + for (auto i = 0u; i < _countof(WeaponFullDef::notetrackSoundMapKeys); i++) { const auto& key = m_get_scr_string(keys[i]); const auto& value = m_get_scr_string(values[i]); @@ -1634,10 +1634,11 @@ void AssetDumperWeapon::DumpAsset(Zone* zone, XAssetInfo* asse InfoStringFromWeaponConverter converter(fullDef, weapon_fields, _countof(weapon_fields), [asset](const scr_string_t scrStr) -> std::string { - if (scrStr >= asset->m_script_strings.size()) + assert(scrStr < asset->m_zone->m_script_strings.size()); + if (scrStr >= asset->m_zone->m_script_strings.size()) return ""; - return asset->m_script_strings[scrStr]; + return asset->m_zone->m_script_strings[scrStr]; }); const auto infoString = converter.Convert(); diff --git a/src/ObjWriting/Game/T6/ZoneDumperT6.cpp b/src/ObjWriting/Game/T6/ZoneDumperT6.cpp index b76bba84..c227903f 100644 --- a/src/ObjWriting/Game/T6/ZoneDumperT6.cpp +++ b/src/ObjWriting/Game/T6/ZoneDumperT6.cpp @@ -29,7 +29,7 @@ bool ZoneDumper::DumpZone(Zone* zone, const std::string& basePath) const dumper.DumpPool(zone, assetPools->poolName, basePath); \ } - const auto assetPools = dynamic_cast(zone->GetPools()); + const auto assetPools = dynamic_cast(zone->m_pools.get()); // DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset); // DUMP_ASSET_POOL(AssetDumperPhysConstraints, m_phys_constraints); diff --git a/src/Unlinker/ContentLister/ContentPrinter.cpp b/src/Unlinker/ContentLister/ContentPrinter.cpp index 04a21f08..9350f381 100644 --- a/src/Unlinker/ContentLister/ContentPrinter.cpp +++ b/src/Unlinker/ContentLister/ContentPrinter.cpp @@ -7,7 +7,7 @@ ContentPrinter::ContentPrinter(Zone* zone) void ContentPrinter::PrintContent() const { - const auto* pools = m_zone->GetPools(); + const auto* pools = m_zone->m_pools.get(); printf("Zone '%s' (%s)\n", m_zone->m_name.c_str(), m_zone->m_game->GetName().c_str()); puts("Content:"); diff --git a/src/Unlinker/Game/IW4/ZoneDefWriterIW4.cpp b/src/Unlinker/Game/IW4/ZoneDefWriterIW4.cpp index 47e68c65..3e8281dc 100644 --- a/src/Unlinker/Game/IW4/ZoneDefWriterIW4.cpp +++ b/src/Unlinker/Game/IW4/ZoneDefWriterIW4.cpp @@ -15,7 +15,7 @@ namespace IW4 { void WriteContent() const { - const auto* pools = dynamic_cast(m_zone->GetPools()); + const auto* pools = dynamic_cast(m_zone->m_pools.get()); assert(pools); if (!pools) diff --git a/src/Unlinker/Game/T6/ZoneDefWriterT6.cpp b/src/Unlinker/Game/T6/ZoneDefWriterT6.cpp index 63e6e584..6e71bda2 100644 --- a/src/Unlinker/Game/T6/ZoneDefWriterT6.cpp +++ b/src/Unlinker/Game/T6/ZoneDefWriterT6.cpp @@ -52,7 +52,7 @@ namespace T6 void WriteContent() const { - const auto* pools = dynamic_cast(m_zone->GetPools()); + const auto* pools = dynamic_cast(m_zone->m_pools.get()); assert(pools); if (!pools) @@ -91,7 +91,7 @@ namespace T6 WriteMetaData(META_DATA_KEY_GAME, "t6"); EmptyLine(); - auto* assetPoolT6 = dynamic_cast(m_zone->GetPools()); + auto* assetPoolT6 = dynamic_cast(m_zone->m_pools.get()); if (assetPoolT6 && !assetPoolT6->m_key_value_pairs->m_asset_lookup.empty()) { diff --git a/src/ZoneCodeGenerator/Generating/Templates/Loading/ArrayPointer.stg b/src/ZoneCodeGenerator/Generating/Templates/Loading/ArrayPointer.stg index f4b7bc7c..c5abc87b 100644 --- a/src/ZoneCodeGenerator/Generating/Templates/Loading/ArrayPointer.stg +++ b/src/ZoneCodeGenerator/Generating/Templates/Loading/ArrayPointer.stg @@ -40,12 +40,7 @@ $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference) $\n$ varScriptString = $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$ -$if(!member.IsReusable)$ LoadScriptStringArray(true, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$); -$else$ -LoadScriptStringArrayRealloc(true, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$);$\n$ -$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ = varScriptString; -$endif$ %> @@ -75,11 +70,6 @@ if($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(referen else { $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->ConvertOffsetToPointer($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$); - $if(member.IsScriptString)$ - varScriptString = $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$; - LoadScriptStringArrayRealloc(false, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$); - $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ = varScriptString; - $endif$ }$\\$ $endif$ >> @@ -129,7 +119,7 @@ $endif$ %> LoadPointerArrayMethod_Asset(context, type, structure) ::= << -$LoaderClassName(structure)$ loader(m_script_string_provider, m_zone, m_stream); +$LoaderClassName(structure)$ loader(m_zone, m_stream); AddDependency(loader.Load($TypePtrVarName(type)$)); >> diff --git a/src/ZoneCodeGenerator/Generating/Templates/Loading/SinglePointer.stg b/src/ZoneCodeGenerator/Generating/Templates/Loading/SinglePointer.stg index 2c516f73..ba28e9c3 100644 --- a/src/ZoneCodeGenerator/Generating/Templates/Loading/SinglePointer.stg +++ b/src/ZoneCodeGenerator/Generating/Templates/Loading/SinglePointer.stg @@ -38,7 +38,7 @@ $endif$ >> LoadSinglePointerAsset(context, structure, member, reference) ::= << -$LoaderClassName(member.StructureType)$ loader(m_script_string_provider, m_zone, m_stream); +$LoaderClassName(member.StructureType)$ loader(m_zone, m_stream); AddDependency(loader.Load(&$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$)); >> diff --git a/src/ZoneCodeGenerator/Generating/Templates/ZoneLoad.stg b/src/ZoneCodeGenerator/Generating/Templates/ZoneLoad.stg index c55ae98f..7e48c99b 100644 --- a/src/ZoneCodeGenerator/Generating/Templates/ZoneLoad.stg +++ b/src/ZoneCodeGenerator/Generating/Templates/ZoneLoad.stg @@ -12,7 +12,7 @@ import "Loading/PointerArray.stg" // Loading common LoaderClassName(asset) ::= "Loader_$asset.Type.Name$" -HeaderConstructor(context) ::= "$LoaderClassName(context.Asset)$(IZoneScriptStringProvider* scriptStringProvider, Zone* zone, IZoneInputStream* stream);" +HeaderConstructor(context) ::= "$LoaderClassName(context.Asset)$(Zone* zone, IZoneInputStream* stream);" HeaderTempPtrLoadMethodDeclaration(structure) ::= "void LoadPtr_$structure.Type.Name$(bool atStreamStart);" HeaderArrayLoadMethodDeclaration(type) ::= "void LoadArray_$SafeTypeName(type)$(bool atStreamStart, size_t count);" @@ -290,8 +290,8 @@ var$type.Name$Ptr = nullptr; >> ConstructorMethod(context) ::= << -$LoaderClassName(context.Asset)$::$LoaderClassName(context.Asset)$(IZoneScriptStringProvider* scriptStringProvider, Zone* zone, IZoneInputStream* stream) - : AssetLoader($context.Asset.AssetEnumEntry.Name$, scriptStringProvider, zone, stream)$\\$ +$LoaderClassName(context.Asset)$::$LoaderClassName(context.Asset)$(Zone* zone, IZoneInputStream* stream) + : AssetLoader($context.Asset.AssetEnumEntry.Name$, zone, stream)$\\$ $if(context.HasActions)$, m_actions(zone)$endif$ { m_asset_info = nullptr; diff --git a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp index 4b12db59..176a609c 100644 --- a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp +++ b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp @@ -97,12 +97,12 @@ const std::string GameAssetPoolIW4::ASSET_TYPE_NAMES[] ASSET_TYPE_ADDON_MAP_ENTS, AddonMapEnts, addonMapEnts, m_addon_map_ents */ -GameAssetPoolIW4::GameAssetPoolIW4(const int priority) +GameAssetPoolIW4::GameAssetPoolIW4(Zone* zone, const int priority) + : ZoneAssetPools(zone), + m_priority(priority) { assert(_countof(ASSET_TYPE_NAMES) == ASSET_TYPE_COUNT); - m_priority = priority; - m_phys_preset = nullptr; m_phys_collmap = nullptr; m_xanim_parts = nullptr; @@ -258,9 +258,7 @@ void GameAssetPoolIW4::InitPoolDynamic(const asset_type_t type) #undef CASE_INIT_POOL_STATIC } -XAssetInfoGeneric* GameAssetPoolIW4::AddAsset(asset_type_t type, std::string name, void* asset, - std::vector& scriptStrings, - std::vector& dependencies) +XAssetInfoGeneric* GameAssetPoolIW4::AddAssetToPool(asset_type_t type, std::string name, void* asset, std::vector& dependencies) { XAsset xAsset{}; @@ -271,7 +269,7 @@ XAssetInfoGeneric* GameAssetPoolIW4::AddAsset(asset_type_t type, std::string nam case assetType: \ { \ assert((poolName) != nullptr); \ - auto* assetInfo = (poolName)->AddAsset(std::move(name), xAsset.header.headerName, scriptStrings, dependencies); \ + auto* assetInfo = (poolName)->AddAsset(std::move(name), xAsset.header.headerName, m_zone, dependencies); \ if(assetInfo) \ { \ m_assets_in_order.push_back(assetInfo); \ @@ -394,13 +392,3 @@ const std::string& GameAssetPoolIW4::GetAssetTypeName(const asset_type_t assetTy return ASSET_TYPE_INVALID; } - -IZoneAssetPools::iterator GameAssetPoolIW4::begin() const -{ - return m_assets_in_order.begin(); -} - -IZoneAssetPools::iterator GameAssetPoolIW4::end() const -{ - return m_assets_in_order.end(); -} diff --git a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h index 18c286ce..1d100d76 100644 --- a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h +++ b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h @@ -2,18 +2,20 @@ #include -#include "Pool/IZoneAssetPools.h" +#include "Pool/ZoneAssetPools.h" #include "Pool/AssetPool.h" #include "IW4.h" -class GameAssetPoolIW4 final : public IZoneAssetPools +class GameAssetPoolIW4 final : public ZoneAssetPools { int m_priority; - std::vector m_assets_in_order; static const std::string ASSET_TYPE_INVALID; static const std::string ASSET_TYPE_NAMES[]; +protected: + XAssetInfoGeneric* AddAssetToPool(asset_type_t type, std::string name, void* asset, std::vector& dependencies) override; + public: std::unique_ptr> m_phys_preset; std::unique_ptr> m_phys_collmap; @@ -51,18 +53,12 @@ public: std::unique_ptr> m_vehicle; std::unique_ptr> m_addon_map_ents; - explicit GameAssetPoolIW4(int priority); + GameAssetPoolIW4(Zone* zone, int priority); ~GameAssetPoolIW4() override = default; void InitPoolStatic(asset_type_t type, size_t capacity) override; void InitPoolDynamic(asset_type_t type) override; - XAssetInfoGeneric* AddAsset(asset_type_t type, std::string name, void* asset, - std::vector& scriptStrings, - std::vector& dependencies) override; XAssetInfoGeneric* GetAsset(asset_type_t type, std::string name) const override; const std::string& GetAssetTypeName(asset_type_t assetType) const override; - - iterator begin() const override; - iterator end() const override; }; diff --git a/src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp b/src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp index 0ec3c407..9c7a7209 100644 --- a/src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp +++ b/src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp @@ -70,12 +70,12 @@ const std::string GameAssetPoolT6::ASSET_TYPE_NAMES[] "zbarrier" }; -GameAssetPoolT6::GameAssetPoolT6(const int priority) +GameAssetPoolT6::GameAssetPoolT6(Zone* zone, const int priority) + : ZoneAssetPools(zone), + m_priority(priority) { assert(_countof(ASSET_TYPE_NAMES) == ASSET_TYPE_COUNT); - m_priority = priority; - m_phys_preset = nullptr; m_phys_constraints = nullptr; m_destructible_def = nullptr; @@ -195,57 +195,57 @@ void GameAssetPoolT6::InitPoolStatic(const asset_type_t type, const size_t capac break; \ } - switch(type) + switch (type) { - CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset); - CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints, PhysConstraints); - CASE_INIT_POOL_STATIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def, DestructibleDef); - CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts); - CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel, XModel); - CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material, Material); - CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet); - CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image, GfxImage); - CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound_bank, SndBank); - CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch, SndPatch); - CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t); - CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap_t); - CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld); - CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp); - CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp); - CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts); - CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld); - CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef); - CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font, Font_s); - CASE_INIT_POOL_STATIC(ASSET_TYPE_FONTICON, m_font_icon, FontIcon); - CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList); - CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t); - CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry); - CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon, WeaponVariantDef); - CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT, m_attachment, WeaponAttachment); - CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique, WeaponAttachmentUnique); - CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON_CAMO, m_camo, WeaponCamo); - CASE_INIT_POOL_STATIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, SndDriverGlobals); - CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx, FxEffectDef); - CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable); - 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_XGLOBALS, m_xglobals, XGlobals); - CASE_INIT_POOL_STATIC(ASSET_TYPE_DDL, m_ddl, ddlRoot_t); - CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSES, m_glasses, Glasses); - CASE_INIT_POOL_STATIC(ASSET_TYPE_EMBLEMSET, m_emblem_set, EmblemSet); - CASE_INIT_POOL_STATIC(ASSET_TYPE_SCRIPTPARSETREE, m_script, ScriptParseTree); - CASE_INIT_POOL_STATIC(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs, KeyValuePairs); - CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLEDEF, m_vehicle, VehicleDef); - CASE_INIT_POOL_STATIC(ASSET_TYPE_MEMORYBLOCK, m_memory_block, MemoryBlock); - CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts); - CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer, TracerDef); - CASE_INIT_POOL_STATIC(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts, SkinnedVertsDef); - CASE_INIT_POOL_STATIC(ASSET_TYPE_QDB, m_qdb, Qdb); - CASE_INIT_POOL_STATIC(ASSET_TYPE_SLUG, m_slug, Slug); - CASE_INIT_POOL_STATIC(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table, FootstepTableDef); - CASE_INIT_POOL_STATIC(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table, FootstepFXTableDef); - CASE_INIT_POOL_STATIC(ASSET_TYPE_ZBARRIER, m_zbarrier, ZBarrierDef); + CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset); + CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints, PhysConstraints); + CASE_INIT_POOL_STATIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def, DestructibleDef); + CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts); + CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel, XModel); + CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material, Material); + CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet); + CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image, GfxImage); + CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound_bank, SndBank); + CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch, SndPatch); + CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t); + CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap_t); + CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld); + CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp); + CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp); + CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts); + CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld); + CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef); + CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font, Font_s); + CASE_INIT_POOL_STATIC(ASSET_TYPE_FONTICON, m_font_icon, FontIcon); + CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList); + CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t); + CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry); + CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon, WeaponVariantDef); + CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT, m_attachment, WeaponAttachment); + CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique, WeaponAttachmentUnique); + CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON_CAMO, m_camo, WeaponCamo); + CASE_INIT_POOL_STATIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, SndDriverGlobals); + CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx, FxEffectDef); + CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable); + 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_XGLOBALS, m_xglobals, XGlobals); + CASE_INIT_POOL_STATIC(ASSET_TYPE_DDL, m_ddl, ddlRoot_t); + CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSES, m_glasses, Glasses); + CASE_INIT_POOL_STATIC(ASSET_TYPE_EMBLEMSET, m_emblem_set, EmblemSet); + CASE_INIT_POOL_STATIC(ASSET_TYPE_SCRIPTPARSETREE, m_script, ScriptParseTree); + CASE_INIT_POOL_STATIC(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs, KeyValuePairs); + CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLEDEF, m_vehicle, VehicleDef); + CASE_INIT_POOL_STATIC(ASSET_TYPE_MEMORYBLOCK, m_memory_block, MemoryBlock); + CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts); + CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer, TracerDef); + CASE_INIT_POOL_STATIC(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts, SkinnedVertsDef); + CASE_INIT_POOL_STATIC(ASSET_TYPE_QDB, m_qdb, Qdb); + CASE_INIT_POOL_STATIC(ASSET_TYPE_SLUG, m_slug, Slug); + CASE_INIT_POOL_STATIC(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table, FootstepTableDef); + CASE_INIT_POOL_STATIC(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table, FootstepFXTableDef); + CASE_INIT_POOL_STATIC(ASSET_TYPE_ZBARRIER, m_zbarrier, ZBarrierDef); default: assert(type >= 0 && type < ASSET_TYPE_COUNT); @@ -267,57 +267,57 @@ void GameAssetPoolT6::InitPoolDynamic(const asset_type_t type) break; \ } - switch(type) + switch (type) { - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints, PhysConstraints); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def, DestructibleDef); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel, XModel); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material, Material); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image, GfxImage); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound_bank, SndBank); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch, SndPatch); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap_t); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font, Font_s); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONTICON, m_font_icon, FontIcon); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon, WeaponVariantDef); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT, m_attachment, WeaponAttachment); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique, WeaponAttachmentUnique); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON_CAMO, m_camo, WeaponCamo); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, SndDriverGlobals); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx, FxEffectDef); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable); - 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_XGLOBALS, m_xglobals, XGlobals); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DDL, m_ddl, ddlRoot_t); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GLASSES, m_glasses, Glasses); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_EMBLEMSET, m_emblem_set, EmblemSet); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SCRIPTPARSETREE, m_script, ScriptParseTree); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs, KeyValuePairs); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLEDEF, m_vehicle, VehicleDef); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MEMORYBLOCK, m_memory_block, MemoryBlock); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer, TracerDef); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts, SkinnedVertsDef); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_QDB, m_qdb, Qdb); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SLUG, m_slug, Slug); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table, FootstepTableDef); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table, FootstepFXTableDef); - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ZBARRIER, m_zbarrier, ZBarrierDef); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints, PhysConstraints); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def, DestructibleDef); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel, XModel); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material, Material); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image, GfxImage); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound_bank, SndBank); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch, SndPatch); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap_t); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font, Font_s); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONTICON, m_font_icon, FontIcon); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon, WeaponVariantDef); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT, m_attachment, WeaponAttachment); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique, WeaponAttachmentUnique); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON_CAMO, m_camo, WeaponCamo); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, SndDriverGlobals); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx, FxEffectDef); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable); + 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_XGLOBALS, m_xglobals, XGlobals); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DDL, m_ddl, ddlRoot_t); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GLASSES, m_glasses, Glasses); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_EMBLEMSET, m_emblem_set, EmblemSet); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SCRIPTPARSETREE, m_script, ScriptParseTree); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs, KeyValuePairs); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLEDEF, m_vehicle, VehicleDef); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MEMORYBLOCK, m_memory_block, MemoryBlock); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer, TracerDef); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts, SkinnedVertsDef); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_QDB, m_qdb, Qdb); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SLUG, m_slug, Slug); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table, FootstepTableDef); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table, FootstepFXTableDef); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ZBARRIER, m_zbarrier, ZBarrierDef); default: assert(type >= 0 && type < ASSET_TYPE_COUNT); @@ -327,7 +327,7 @@ void GameAssetPoolT6::InitPoolDynamic(const asset_type_t type) #undef CASE_INIT_POOL_STATIC } -XAssetInfoGeneric* GameAssetPoolT6::AddAsset(asset_type_t type, std::string name, void* asset, std::vector& scriptStrings, std::vector& dependencies) +XAssetInfoGeneric* GameAssetPoolT6::AddAssetToPool(asset_type_t type, std::string name, void* asset, std::vector& dependencies) { XAsset xAsset{}; @@ -338,7 +338,7 @@ XAssetInfoGeneric* GameAssetPoolT6::AddAsset(asset_type_t type, std::string name case assetType: \ { \ assert((poolName) != nullptr); \ - auto* assetInfo = (poolName)->AddAsset(std::move(name), xAsset.header.headerName, scriptStrings, dependencies); \ + auto* assetInfo = (poolName)->AddAsset(std::move(name), xAsset.header.headerName, m_zone, dependencies); \ if(assetInfo) \ { \ m_assets_in_order.push_back(assetInfo); \ @@ -346,57 +346,57 @@ XAssetInfoGeneric* GameAssetPoolT6::AddAsset(asset_type_t type, std::string name return assetInfo; \ } - switch(xAsset.type) + switch (xAsset.type) { - CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset, physPreset); - CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints, physConstraints); - CASE_ADD_TO_POOL(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def, destructibleDef); - CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts, parts); - CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel, model); - CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material, material); - CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, techniqueSet); - CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image, image); - CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound_bank, sound); - CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_PATCH, m_sound_patch, soundPatch); - CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap); - CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap); - CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world, comWorld); - CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, gameWorldSp); - CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, gameWorldMp); - CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents, mapEnts); - CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world, gfxWorld); - CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, lightDef); - CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font, font); - CASE_ADD_TO_POOL(ASSET_TYPE_FONTICON, m_font_icon, fontIcon); - CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list, menuList); - CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def, menu); - CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, localize); - CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon, weapon); - CASE_ADD_TO_POOL(ASSET_TYPE_ATTACHMENT, m_attachment, attachment); - CASE_ADD_TO_POOL(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique, attachmentUnique); - CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON_CAMO, m_camo, weaponCamo); - CASE_ADD_TO_POOL(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, sndDriverGlobals); - CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx, fx); - CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, impactFx); - 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_XGLOBALS, m_xglobals, xGlobals); - CASE_ADD_TO_POOL(ASSET_TYPE_DDL, m_ddl, ddlRoot); - CASE_ADD_TO_POOL(ASSET_TYPE_GLASSES, m_glasses, glasses); - CASE_ADD_TO_POOL(ASSET_TYPE_EMBLEMSET, m_emblem_set, emblemSet); - CASE_ADD_TO_POOL(ASSET_TYPE_SCRIPTPARSETREE, m_script, scriptParseTree); - CASE_ADD_TO_POOL(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs, keyValuePairs); - CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLEDEF, m_vehicle, vehicleDef); - CASE_ADD_TO_POOL(ASSET_TYPE_MEMORYBLOCK, m_memory_block, memoryBlock); - CASE_ADD_TO_POOL(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, addonMapEnts); - CASE_ADD_TO_POOL(ASSET_TYPE_TRACER, m_tracer, tracerDef); - CASE_ADD_TO_POOL(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts, skinnedVertsDef); - CASE_ADD_TO_POOL(ASSET_TYPE_QDB, m_qdb, qdb); - CASE_ADD_TO_POOL(ASSET_TYPE_SLUG, m_slug, slug); - CASE_ADD_TO_POOL(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table, footstepTableDef); - CASE_ADD_TO_POOL(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table, footstepFXTableDef); - CASE_ADD_TO_POOL(ASSET_TYPE_ZBARRIER, m_zbarrier, zbarrierDef); + CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset, physPreset); + CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints, physConstraints); + CASE_ADD_TO_POOL(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def, destructibleDef); + CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts, parts); + CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel, model); + CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material, material); + CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, techniqueSet); + CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image, image); + CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound_bank, sound); + CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_PATCH, m_sound_patch, soundPatch); + CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap); + CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap); + CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world, comWorld); + CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, gameWorldSp); + CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, gameWorldMp); + CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents, mapEnts); + CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world, gfxWorld); + CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, lightDef); + CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font, font); + CASE_ADD_TO_POOL(ASSET_TYPE_FONTICON, m_font_icon, fontIcon); + CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list, menuList); + CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def, menu); + CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, localize); + CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon, weapon); + CASE_ADD_TO_POOL(ASSET_TYPE_ATTACHMENT, m_attachment, attachment); + CASE_ADD_TO_POOL(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique, attachmentUnique); + CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON_CAMO, m_camo, weaponCamo); + CASE_ADD_TO_POOL(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, sndDriverGlobals); + CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx, fx); + CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, impactFx); + 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_XGLOBALS, m_xglobals, xGlobals); + CASE_ADD_TO_POOL(ASSET_TYPE_DDL, m_ddl, ddlRoot); + CASE_ADD_TO_POOL(ASSET_TYPE_GLASSES, m_glasses, glasses); + CASE_ADD_TO_POOL(ASSET_TYPE_EMBLEMSET, m_emblem_set, emblemSet); + CASE_ADD_TO_POOL(ASSET_TYPE_SCRIPTPARSETREE, m_script, scriptParseTree); + CASE_ADD_TO_POOL(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs, keyValuePairs); + CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLEDEF, m_vehicle, vehicleDef); + CASE_ADD_TO_POOL(ASSET_TYPE_MEMORYBLOCK, m_memory_block, memoryBlock); + CASE_ADD_TO_POOL(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, addonMapEnts); + CASE_ADD_TO_POOL(ASSET_TYPE_TRACER, m_tracer, tracerDef); + CASE_ADD_TO_POOL(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts, skinnedVertsDef); + CASE_ADD_TO_POOL(ASSET_TYPE_QDB, m_qdb, qdb); + CASE_ADD_TO_POOL(ASSET_TYPE_SLUG, m_slug, slug); + CASE_ADD_TO_POOL(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table, footstepTableDef); + CASE_ADD_TO_POOL(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table, footstepFXTableDef); + CASE_ADD_TO_POOL(ASSET_TYPE_ZBARRIER, m_zbarrier, zbarrierDef); default: assert(false); @@ -420,55 +420,55 @@ XAssetInfoGeneric* GameAssetPoolT6::GetAsset(const asset_type_t type, std::strin switch (type) { - CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset); - CASE_GET_ASSET(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints); - CASE_GET_ASSET(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def); - CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts); - CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel); - CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material); - CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set); - CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image); - CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound_bank); - CASE_GET_ASSET(ASSET_TYPE_SOUND_PATCH, m_sound_patch); - CASE_GET_ASSET(ASSET_TYPE_CLIPMAP, m_clip_map); - CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_PVS, m_clip_map); - CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world); - CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp); - CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp); - CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents); - CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world); - CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def); - CASE_GET_ASSET(ASSET_TYPE_FONT, m_font); - CASE_GET_ASSET(ASSET_TYPE_FONTICON, m_font_icon); - CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list); - CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def); - CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize); - CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon); - CASE_GET_ASSET(ASSET_TYPE_ATTACHMENT, m_attachment); - CASE_GET_ASSET(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique); - CASE_GET_ASSET(ASSET_TYPE_WEAPON_CAMO, m_camo); - CASE_GET_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals); - CASE_GET_ASSET(ASSET_TYPE_FX, m_fx); - CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table); - 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_XGLOBALS, m_xglobals); - CASE_GET_ASSET(ASSET_TYPE_DDL, m_ddl); - CASE_GET_ASSET(ASSET_TYPE_GLASSES, m_glasses); - CASE_GET_ASSET(ASSET_TYPE_EMBLEMSET, m_emblem_set); - CASE_GET_ASSET(ASSET_TYPE_SCRIPTPARSETREE, m_script); - CASE_GET_ASSET(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs); - CASE_GET_ASSET(ASSET_TYPE_VEHICLEDEF, m_vehicle); - CASE_GET_ASSET(ASSET_TYPE_MEMORYBLOCK, m_memory_block); - CASE_GET_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents); - CASE_GET_ASSET(ASSET_TYPE_TRACER, m_tracer); - CASE_GET_ASSET(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts); - CASE_GET_ASSET(ASSET_TYPE_QDB, m_qdb); - CASE_GET_ASSET(ASSET_TYPE_SLUG, m_slug); - CASE_GET_ASSET(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table); - CASE_GET_ASSET(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table); - CASE_GET_ASSET(ASSET_TYPE_ZBARRIER, m_zbarrier); + CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset); + CASE_GET_ASSET(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints); + CASE_GET_ASSET(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def); + CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts); + CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel); + CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material); + CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set); + CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image); + CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound_bank); + CASE_GET_ASSET(ASSET_TYPE_SOUND_PATCH, m_sound_patch); + CASE_GET_ASSET(ASSET_TYPE_CLIPMAP, m_clip_map); + CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_PVS, m_clip_map); + CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world); + CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp); + CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp); + CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents); + CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world); + CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def); + CASE_GET_ASSET(ASSET_TYPE_FONT, m_font); + CASE_GET_ASSET(ASSET_TYPE_FONTICON, m_font_icon); + CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list); + CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def); + CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize); + CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon); + CASE_GET_ASSET(ASSET_TYPE_ATTACHMENT, m_attachment); + CASE_GET_ASSET(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique); + CASE_GET_ASSET(ASSET_TYPE_WEAPON_CAMO, m_camo); + CASE_GET_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals); + CASE_GET_ASSET(ASSET_TYPE_FX, m_fx); + CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table); + 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_XGLOBALS, m_xglobals); + CASE_GET_ASSET(ASSET_TYPE_DDL, m_ddl); + CASE_GET_ASSET(ASSET_TYPE_GLASSES, m_glasses); + CASE_GET_ASSET(ASSET_TYPE_EMBLEMSET, m_emblem_set); + CASE_GET_ASSET(ASSET_TYPE_SCRIPTPARSETREE, m_script); + CASE_GET_ASSET(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs); + CASE_GET_ASSET(ASSET_TYPE_VEHICLEDEF, m_vehicle); + CASE_GET_ASSET(ASSET_TYPE_MEMORYBLOCK, m_memory_block); + CASE_GET_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents); + CASE_GET_ASSET(ASSET_TYPE_TRACER, m_tracer); + CASE_GET_ASSET(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts); + CASE_GET_ASSET(ASSET_TYPE_QDB, m_qdb); + CASE_GET_ASSET(ASSET_TYPE_SLUG, m_slug); + CASE_GET_ASSET(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table); + CASE_GET_ASSET(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table); + CASE_GET_ASSET(ASSET_TYPE_ZBARRIER, m_zbarrier); default: assert(false); @@ -487,13 +487,3 @@ const std::string& GameAssetPoolT6::GetAssetTypeName(const asset_type_t assetTyp return ASSET_TYPE_INVALID; } - -IZoneAssetPools::iterator GameAssetPoolT6::begin() const -{ - return m_assets_in_order.begin(); -} - -IZoneAssetPools::iterator GameAssetPoolT6::end() const -{ - return m_assets_in_order.end(); -} diff --git a/src/ZoneCommon/Game/T6/GameAssetPoolT6.h b/src/ZoneCommon/Game/T6/GameAssetPoolT6.h index 321ca0ce..13e6ac13 100644 --- a/src/ZoneCommon/Game/T6/GameAssetPoolT6.h +++ b/src/ZoneCommon/Game/T6/GameAssetPoolT6.h @@ -1,17 +1,19 @@ #pragma once -#include "Pool/IZoneAssetPools.h" +#include "Pool/ZoneAssetPools.h" #include "Pool/AssetPool.h" #include "T6.h" -class GameAssetPoolT6 final : public IZoneAssetPools +class GameAssetPoolT6 final : public ZoneAssetPools { int m_priority; - std::vector m_assets_in_order; static const std::string ASSET_TYPE_INVALID; static const std::string ASSET_TYPE_NAMES[]; +protected: + XAssetInfoGeneric* AddAssetToPool(asset_type_t type, std::string name, void* asset, std::vector& dependencies) override; + public: AssetPool* m_phys_preset; AssetPool* m_phys_constraints; @@ -62,16 +64,12 @@ public: AssetPool* m_footstep_fx_table; AssetPool* m_zbarrier; - explicit GameAssetPoolT6(int priority); + GameAssetPoolT6(Zone* zone, int priority); ~GameAssetPoolT6() override; void InitPoolStatic(asset_type_t type, size_t capacity) override; void InitPoolDynamic(asset_type_t type) override; - XAssetInfoGeneric* AddAsset(asset_type_t type, std::string name, void* asset, std::vector& scriptStrings, std::vector& dependencies) override; XAssetInfoGeneric* GetAsset(asset_type_t type, std::string name) const override; const std::string& GetAssetTypeName(asset_type_t assetType) const override; - - iterator begin() const override; - iterator end() const override; }; diff --git a/src/ZoneCommon/Pool/AssetPool.h b/src/ZoneCommon/Pool/AssetPool.h index 4abec139..c1e5f0e0 100644 --- a/src/ZoneCommon/Pool/AssetPool.h +++ b/src/ZoneCommon/Pool/AssetPool.h @@ -1,9 +1,13 @@ #pragma once -#include "XAssetInfo.h" #include #include +#include "XAssetInfo.h" +#include "zone/Zone.h" + +class Zone; + template class AssetPool { @@ -43,7 +47,7 @@ public: virtual ~AssetPool() = default; - virtual XAssetInfo* AddAsset(std::string name, T* asset, std::vector& scriptStrings, std::vector& dependencies) = 0; + virtual XAssetInfo* AddAsset(std::string name, T* asset, Zone* zone, std::vector& dependencies) = 0; XAssetInfo* GetAsset(const std::string& name) { diff --git a/src/ZoneCommon/Pool/AssetPoolDynamic.h b/src/ZoneCommon/Pool/AssetPoolDynamic.h index 186a205b..b13f7465 100644 --- a/src/ZoneCommon/Pool/AssetPoolDynamic.h +++ b/src/ZoneCommon/Pool/AssetPoolDynamic.h @@ -40,12 +40,12 @@ public: m_asset_lookup.clear(); } - XAssetInfo* AddAsset(std::string name, T* asset, std::vector& scriptStrings, std::vector& dependencies) override + XAssetInfo* AddAsset(std::string name, T* asset, Zone* zone, std::vector& dependencies) override { auto* newInfo = new XAssetInfo(); newInfo->m_type = m_type; newInfo->m_name = std::move(name); - newInfo->m_script_strings = std::move(scriptStrings); + newInfo->m_zone = zone; newInfo->m_dependencies = std::move(dependencies); T* newAsset = new T(); diff --git a/src/ZoneCommon/Pool/AssetPoolStatic.h b/src/ZoneCommon/Pool/AssetPoolStatic.h index 2853c815..04a41e32 100644 --- a/src/ZoneCommon/Pool/AssetPoolStatic.h +++ b/src/ZoneCommon/Pool/AssetPoolStatic.h @@ -81,7 +81,7 @@ public: m_capacity = 0; } - XAssetInfo* AddAsset(std::string name, T* asset, std::vector& scriptStrings, std::vector& dependencies) override + XAssetInfo* AddAsset(std::string name, T* asset, Zone* zone, std::vector& dependencies) override { if(m_free == nullptr) { @@ -96,7 +96,7 @@ public: poolSlot->m_info->m_type = m_type; poolSlot->m_info->m_name = std::move(name); poolSlot->m_info->m_ptr = &poolSlot->m_entry; - poolSlot->m_info->m_script_strings = std::move(scriptStrings); + poolSlot->m_info->m_zone = zone; poolSlot->m_info->m_dependencies = std::move(dependencies); m_asset_lookup[poolSlot->m_info->m_name] = poolSlot->m_info; diff --git a/src/ZoneCommon/Pool/IZoneAssetPools.h b/src/ZoneCommon/Pool/IZoneAssetPools.h deleted file mode 100644 index 455daed2..00000000 --- a/src/ZoneCommon/Pool/IZoneAssetPools.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include "XAssetInfo.h" -#include "Zone/ZoneTypes.h" -#include -#include - -class IZoneAssetPools -{ -public: - using iterator = std::vector::const_iterator; - - virtual ~IZoneAssetPools() = default; - - virtual XAssetInfoGeneric* AddAsset(asset_type_t type, std::string name, void* asset, std::vector& scriptStrings, std::vector& dependencies) = 0; - virtual XAssetInfoGeneric* GetAsset(asset_type_t type, std::string name) const = 0; - virtual const std::string& GetAssetTypeName(asset_type_t assetType) const = 0; - - virtual void InitPoolStatic(asset_type_t type, size_t capacity) = 0; - virtual void InitPoolDynamic(asset_type_t type) = 0; - - virtual iterator begin() const = 0; - virtual iterator end() const = 0; -}; diff --git a/src/ZoneCommon/Pool/XAssetInfo.h b/src/ZoneCommon/Pool/XAssetInfo.h index 1d06593d..c7a2e70a 100644 --- a/src/ZoneCommon/Pool/XAssetInfo.h +++ b/src/ZoneCommon/Pool/XAssetInfo.h @@ -2,12 +2,16 @@ #include #include +#include "Zone/Zone.h" + +class Zone; + class XAssetInfoGeneric { public: int m_type = -1; std::string m_name; - std::vector m_script_strings; + Zone* m_zone; std::vector m_dependencies; void* m_ptr; }; diff --git a/src/ZoneCommon/Pool/ZoneAssetPools.cpp b/src/ZoneCommon/Pool/ZoneAssetPools.cpp new file mode 100644 index 00000000..3bf5a67c --- /dev/null +++ b/src/ZoneCommon/Pool/ZoneAssetPools.cpp @@ -0,0 +1,27 @@ +#include "ZoneAssetPools.h" + +ZoneAssetPools::ZoneAssetPools(Zone* zone) + : m_zone(zone) +{ +} + +XAssetInfoGeneric* ZoneAssetPools::AddAsset(const asset_type_t type, std::string name, void* asset, std::vector& dependencies) +{ + auto* assetInfo = AddAssetToPool(type, std::move(name), asset, dependencies); + if(assetInfo) + { + m_assets_in_order.push_back(assetInfo); + } + + return assetInfo; +} + +ZoneAssetPools::iterator ZoneAssetPools::begin() const +{ + return m_assets_in_order.begin(); +} + +ZoneAssetPools::iterator ZoneAssetPools::end() const +{ + return m_assets_in_order.end(); +} diff --git a/src/ZoneCommon/Pool/ZoneAssetPools.h b/src/ZoneCommon/Pool/ZoneAssetPools.h new file mode 100644 index 00000000..0adf74ba --- /dev/null +++ b/src/ZoneCommon/Pool/ZoneAssetPools.h @@ -0,0 +1,35 @@ +#pragma once + +#include "XAssetInfo.h" +#include "Zone/ZoneTypes.h" +#include "Zone/Zone.h" +#include +#include + +class Zone; +class XAssetInfoGeneric; + +class ZoneAssetPools +{ +protected: + Zone* m_zone; + std::vector m_assets_in_order; + + virtual XAssetInfoGeneric* AddAssetToPool(asset_type_t type, std::string name, void* asset, std::vector& dependencies) = 0; + +public: + using iterator = std::vector::const_iterator; + + explicit ZoneAssetPools(Zone* zone); + virtual ~ZoneAssetPools() = default; + + XAssetInfoGeneric* AddAsset(asset_type_t type, std::string name, void* asset, std::vector& dependencies); + virtual XAssetInfoGeneric* GetAsset(asset_type_t type, std::string name) const = 0; + virtual const std::string& GetAssetTypeName(asset_type_t assetType) const = 0; + + virtual void InitPoolStatic(asset_type_t type, size_t capacity) = 0; + virtual void InitPoolDynamic(asset_type_t type) = 0; + + iterator begin() const; + iterator end() const; +}; diff --git a/src/ZoneCommon/Zone/Zone.cpp b/src/ZoneCommon/Zone/Zone.cpp index d72e4f98..88a6b226 100644 --- a/src/ZoneCommon/Zone/Zone.cpp +++ b/src/ZoneCommon/Zone/Zone.cpp @@ -1,28 +1,21 @@ #include "Zone.h" -Zone::Zone(std::string name, const zone_priority_t priority, IZoneAssetPools* pools, IGame* game) +Zone::Zone(std::string name, const zone_priority_t priority, IGame* game) + : m_memory(std::make_unique()), + m_registered(false), + m_name(std::move(name)), + m_priority(priority), + m_language(GameLanguage::LANGUAGE_NONE), + m_game(game) { - m_name = std::move(name); - m_priority = priority; - m_pools = pools; - m_game = game; - m_language = GameLanguage::LANGUAGE_NONE; - m_memory = new ZoneMemory(); - m_registered = false; } Zone::~Zone() { - if(m_registered) + if (m_registered) { m_game->RemoveZone(this); } - - delete m_pools; - m_pools = nullptr; - - delete m_memory; - m_memory = nullptr; } void Zone::Register() @@ -34,12 +27,7 @@ void Zone::Register() } } -IZoneAssetPools* Zone::GetPools() const -{ - return m_pools; -} - ZoneMemory* Zone::GetMemory() const { - return m_memory; + return m_memory.get(); } diff --git a/src/ZoneCommon/Zone/Zone.h b/src/ZoneCommon/Zone/Zone.h index 59c5b6cd..66c2635a 100644 --- a/src/ZoneCommon/Zone/Zone.h +++ b/src/ZoneCommon/Zone/Zone.h @@ -1,19 +1,22 @@ #pragma once +#include + #include "ZoneTypes.h" -#include "Pool/IZoneAssetPools.h" +#include "Pool/ZoneAssetPools.h" #include "Game/IGame.h" #include "Game/GameLanguage.h" #include "Zone/XBlock.h" #include "ZoneMemory.h" #include +#include class IGame; +class ZoneAssetPools; class Zone { - IZoneAssetPools* m_pools; std::vector m_blocks; - ZoneMemory* m_memory; + std::unique_ptr m_memory; bool m_registered; @@ -22,12 +25,13 @@ public: zone_priority_t m_priority; GameLanguage m_language; IGame* m_game; + std::vector m_script_strings; + std::unique_ptr m_pools; - Zone(std::string name, zone_priority_t priority, IZoneAssetPools* pools, IGame* game); + Zone(std::string name, zone_priority_t priority, IGame* game); ~Zone(); void Register(); - IZoneAssetPools* GetPools() const; ZoneMemory* GetMemory() const; }; diff --git a/src/ZoneCommon/Zone/ZoneTypes.h b/src/ZoneCommon/Zone/ZoneTypes.h index 083d0b9b..8566a5e8 100644 --- a/src/ZoneCommon/Zone/ZoneTypes.h +++ b/src/ZoneCommon/Zone/ZoneTypes.h @@ -12,11 +12,15 @@ typedef uint32_t scr_string_t; typedef uint64_t xchunk_size_t; typedef uint64_t xblock_size_t; typedef uint64_t zone_pointer_t; + +constexpr uint16_t SCR_STRING_MAX = UINT32_MAX; #elif _WIN32 typedef uint16_t scr_string_t; typedef uint32_t xchunk_size_t; typedef uint32_t xblock_size_t; typedef uint32_t zone_pointer_t; + +constexpr uint16_t SCR_STRING_MAX = UINT16_MAX; #endif typedef int block_t; diff --git a/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp b/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp index 14b31fb5..c133cfe0 100644 --- a/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp +++ b/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp @@ -50,6 +50,8 @@ ContentLoader::ContentLoader() void ContentLoader::LoadScriptStringList(const bool atStreamStart) { + assert(m_zone->m_script_strings.empty()); + m_stream->PushBlock(XFILE_BLOCK_VIRTUAL); if (atStreamStart) @@ -67,16 +69,18 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart) { if (varScriptStringList->strings[i]) { - m_script_strings.emplace_back(varScriptStringList->strings[i]); + m_zone->m_script_strings.emplace_back(varScriptStringList->strings[i]); } else { - m_script_strings.emplace_back(""); + m_zone->m_script_strings.emplace_back(""); } } } m_stream->PopBlock(); + + assert(m_zone->m_script_strings.size() <= SCR_STRING_MAX + 1); } void ContentLoader::LoadXAsset(const bool atStreamStart) @@ -84,7 +88,7 @@ void ContentLoader::LoadXAsset(const bool atStreamStart) #define LOAD_ASSET(type_index, typeName, headerEntry) \ case type_index: \ { \ - Loader_##typeName loader(this, m_zone, m_stream); \ + Loader_##typeName loader(m_zone, m_stream); \ loader.Load(&varXAsset->header.headerEntry); \ break; \ } @@ -155,7 +159,7 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count for (asset_type_t assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++) { - m_zone->GetPools()->InitPoolDynamic(assetType); + m_zone->m_pools->InitPoolDynamic(assetType); } for (size_t index = 0; index < count; index++) @@ -189,15 +193,3 @@ void ContentLoader::Load(Zone* zone, IZoneInputStream* stream) m_stream->PopBlock(); } - -std::string& ContentLoader::GetZoneScriptString(const scr_string_t scrString) -{ - assert(scrString >= 0 && scrString < m_script_strings.size()); - - if (scrString >= m_script_strings.size()) - { - return m_script_strings[0]; - } - - return m_script_strings[scrString]; -} diff --git a/src/ZoneLoading/Game/IW4/ContentLoaderIW4.h b/src/ZoneLoading/Game/IW4/ContentLoaderIW4.h index 27483eea..9bc87a89 100644 --- a/src/ZoneLoading/Game/IW4/ContentLoaderIW4.h +++ b/src/ZoneLoading/Game/IW4/ContentLoaderIW4.h @@ -2,13 +2,11 @@ #include "Loading/ContentLoaderBase.h" #include "Loading/IContentLoadingEntryPoint.h" #include "Game/IW4/IW4.h" -#include "Loading/IZoneScriptStringProvider.h" namespace IW4 { - class ContentLoader final : public ContentLoaderBase, public IContentLoadingEntryPoint, public IZoneScriptStringProvider + class ContentLoader final : public ContentLoaderBase, public IContentLoadingEntryPoint { - std::vector m_script_strings; XAsset* varXAsset; ScriptStringList* varScriptStringList; @@ -21,6 +19,5 @@ namespace IW4 ContentLoader(); void Load(Zone* zone, IZoneInputStream* stream) override; - std::string& GetZoneScriptString(scr_string_t scrString) override; }; } diff --git a/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp b/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp index f4959200..43e1ab7a 100644 --- a/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp +++ b/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp @@ -204,7 +204,8 @@ public: return nullptr; // Create new zone - auto* zone = new Zone(fileName, 0, new GameAssetPoolIW4(0), &g_GameIW4); + auto* zone = new Zone(fileName, 0, &g_GameIW4); + zone->m_pools = std::make_unique(zone, 0); zone->m_language = GetZoneLanguage(fileName); // File is supported. Now setup all required steps for loading this file. diff --git a/src/ZoneLoading/Game/T6/ContentLoaderT6.cpp b/src/ZoneLoading/Game/T6/ContentLoaderT6.cpp index d8e9138f..4d28f06b 100644 --- a/src/ZoneLoading/Game/T6/ContentLoaderT6.cpp +++ b/src/ZoneLoading/Game/T6/ContentLoaderT6.cpp @@ -63,6 +63,8 @@ ContentLoader::ContentLoader() void ContentLoader::LoadScriptStringList(const bool atStreamStart) { + assert(m_zone->m_script_strings.empty()); + m_stream->PushBlock(XFILE_BLOCK_VIRTUAL); if (atStreamStart) @@ -80,16 +82,18 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart) { if (varScriptStringList->strings[i]) { - m_script_strings.emplace_back(varScriptStringList->strings[i]); + m_zone->m_script_strings.emplace_back(varScriptStringList->strings[i]); } else { - m_script_strings.emplace_back(""); + m_zone->m_script_strings.emplace_back(""); } } } m_stream->PopBlock(); + + assert(m_zone->m_script_strings.size() <= SCR_STRING_MAX + 1); } void ContentLoader::LoadXAsset(const bool atStreamStart) @@ -97,7 +101,7 @@ void ContentLoader::LoadXAsset(const bool atStreamStart) #define LOAD_ASSET(type_index, typeName, headerEntry) \ case type_index: \ { \ - Loader_##typeName loader(this, m_zone, m_stream); \ + Loader_##typeName loader(m_zone, m_stream); \ loader.Load(&varXAsset->header.headerEntry); \ break; \ } @@ -177,7 +181,7 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count for (asset_type_t assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++) { - m_zone->GetPools()->InitPoolDynamic(assetType); + m_zone->m_pools->InitPoolDynamic(assetType); } for (size_t index = 0; index < count; index++) @@ -220,15 +224,3 @@ void ContentLoader::Load(Zone* zone, IZoneInputStream* stream) m_stream->PopBlock(); } - -std::string& ContentLoader::GetZoneScriptString(const scr_string_t scrString) -{ - assert(scrString >= 0 && scrString < m_script_strings.size()); - - if (scrString >= m_script_strings.size()) - { - return m_script_strings[0]; - } - - return m_script_strings[scrString]; -} diff --git a/src/ZoneLoading/Game/T6/ContentLoaderT6.h b/src/ZoneLoading/Game/T6/ContentLoaderT6.h index 2f3437fd..273baa35 100644 --- a/src/ZoneLoading/Game/T6/ContentLoaderT6.h +++ b/src/ZoneLoading/Game/T6/ContentLoaderT6.h @@ -2,13 +2,11 @@ #include "Loading/ContentLoaderBase.h" #include "Loading/IContentLoadingEntryPoint.h" #include "Game/T6/T6.h" -#include "Loading/IZoneScriptStringProvider.h" namespace T6 { - class ContentLoader final : public ContentLoaderBase, public IContentLoadingEntryPoint, public IZoneScriptStringProvider + class ContentLoader final : public ContentLoaderBase, public IContentLoadingEntryPoint { - std::vector m_script_strings; XAsset* varXAsset; ScriptStringList* varScriptStringList; @@ -21,6 +19,5 @@ namespace T6 ContentLoader(); void Load(Zone* zone, IZoneInputStream* stream) override; - std::string& GetZoneScriptString(scr_string_t scrString) override; }; } diff --git a/src/ZoneLoading/Game/T6/ZoneLoaderFactoryT6.cpp b/src/ZoneLoading/Game/T6/ZoneLoaderFactoryT6.cpp index c7de86ba..2875d78d 100644 --- a/src/ZoneLoading/Game/T6/ZoneLoaderFactoryT6.cpp +++ b/src/ZoneLoading/Game/T6/ZoneLoaderFactoryT6.cpp @@ -238,7 +238,8 @@ public: return nullptr; // Create new zone - auto* zone = new Zone(fileName, 0, new GameAssetPoolT6(0), &g_GameT6); + auto* zone = new Zone(fileName, 0, &g_GameT6); + zone->m_pools = std::make_unique(zone, 0); zone->m_language = GetZoneLanguage(fileName); // File is supported. Now setup all required steps for loading this file. diff --git a/src/ZoneLoading/Loading/AssetLoader.cpp b/src/ZoneLoading/Loading/AssetLoader.cpp index 0aab1eec..de1db403 100644 --- a/src/ZoneLoading/Loading/AssetLoader.cpp +++ b/src/ZoneLoading/Loading/AssetLoader.cpp @@ -1,10 +1,12 @@ #include "AssetLoader.h" #include -AssetLoader::AssetLoader(const asset_type_t assetType, IZoneScriptStringProvider* scriptStringProvider, Zone* zone, IZoneInputStream* stream) +AssetLoader::AssetLoader(const asset_type_t assetType, Zone* zone, IZoneInputStream* stream) + : ContentLoaderBase(zone, stream), + m_asset_type(assetType), + varScriptString(nullptr) { m_asset_type = assetType; - m_script_string_provider = scriptStringProvider; m_zone = zone; m_stream = stream; varScriptString = nullptr; @@ -16,7 +18,7 @@ void AssetLoader::AddDependency(XAssetInfoGeneric* assetInfo) return; const auto existingEntry = std::find(m_dependencies.begin(), m_dependencies.end(), assetInfo); - if(existingEntry != m_dependencies.end()) + if (existingEntry != m_dependencies.end()) { return; } @@ -26,31 +28,12 @@ void AssetLoader::AddDependency(XAssetInfoGeneric* assetInfo) scr_string_t AssetLoader::UseScriptString(const scr_string_t scrString) { - std::string& scrStringValue = m_script_string_provider->GetZoneScriptString(scrString); + assert(scrString < m_zone->m_script_strings.size()); - scr_string_t scriptStringIndex = 0; - for(auto& existingScriptString : m_used_script_strings) - { - if(existingScriptString == scrStringValue) - { - return scriptStringIndex; - } + if (scrString >= m_zone->m_script_strings.size()) + return 0u; - scriptStringIndex++; - } - - scriptStringIndex = static_cast(m_used_script_strings.size()); - - // If an asset uses script strings make sure that script string 0 is always empty - if(scriptStringIndex == 0 && !scrStringValue.empty()) - { - m_used_script_strings.emplace_back(""); - scriptStringIndex++; - } - - m_used_script_strings.push_back(scrStringValue); - - return scriptStringIndex; + return scrString; } void AssetLoader::LoadScriptStringArray(const bool atStreamStart, const size_t count) @@ -68,31 +51,12 @@ void AssetLoader::LoadScriptStringArray(const bool atStreamStart, const size_t c } } -void AssetLoader::LoadScriptStringArrayRealloc(const bool atStreamStart, const size_t count) -{ - assert(varScriptString != nullptr); - - if (atStreamStart) - m_stream->Load(varScriptString, count); - - auto* scriptStringsNew = static_cast(m_zone->GetMemory()->Alloc(sizeof scr_string_t * count)); - memcpy_s(scriptStringsNew, sizeof scr_string_t * count, varScriptString, sizeof scr_string_t * count); - varScriptString = scriptStringsNew; - - auto* ptr = varScriptString; - for (size_t index = 0; index < count; index++) - { - *ptr = UseScriptString(*ptr); - ptr++; - } -} - XAssetInfoGeneric* AssetLoader::LinkAsset(std::string name, void* asset) { - return m_zone->GetPools()->AddAsset(m_asset_type, std::move(name), asset, m_used_script_strings, m_dependencies);; + return m_zone->m_pools->AddAsset(m_asset_type, std::move(name), asset, m_dependencies); } XAssetInfoGeneric* AssetLoader::GetAssetInfo(std::string name) const { - return m_zone->GetPools()->GetAsset(m_asset_type, std::move(name)); + return m_zone->m_pools->GetAsset(m_asset_type, std::move(name)); } diff --git a/src/ZoneLoading/Loading/AssetLoader.h b/src/ZoneLoading/Loading/AssetLoader.h index e2d32188..b8410a63 100644 --- a/src/ZoneLoading/Loading/AssetLoader.h +++ b/src/ZoneLoading/Loading/AssetLoader.h @@ -1,28 +1,22 @@ #pragma once #include "Pool/XAssetInfo.h" #include "ContentLoaderBase.h" -#include "IZoneScriptStringProvider.h" class AssetLoader : public ContentLoaderBase { asset_type_t m_asset_type; - std::vector m_used_script_strings; - std::vector m_dependencies; protected: - IZoneScriptStringProvider* m_script_string_provider; - scr_string_t* varScriptString; - AssetLoader(asset_type_t assetType, IZoneScriptStringProvider* scriptStringProvider, Zone* zone, IZoneInputStream* stream); + AssetLoader(asset_type_t assetType, Zone* zone, IZoneInputStream* stream); void AddDependency(XAssetInfoGeneric* assetInfo); scr_string_t UseScriptString(scr_string_t scrString); void LoadScriptStringArray(bool atStreamStart, size_t count); - void LoadScriptStringArrayRealloc(bool atStreamStart, size_t count); XAssetInfoGeneric* LinkAsset(std::string name, void* asset); diff --git a/src/ZoneLoading/Loading/ContentLoaderBase.cpp b/src/ZoneLoading/Loading/ContentLoaderBase.cpp index f67342b0..b3c4e83b 100644 --- a/src/ZoneLoading/Loading/ContentLoaderBase.cpp +++ b/src/ZoneLoading/Loading/ContentLoaderBase.cpp @@ -5,11 +5,17 @@ const void* ContentLoaderBase::PTR_FOLLOWING = reinterpret_cast(-1); const void* ContentLoaderBase::PTR_INSERT = reinterpret_cast(-2); ContentLoaderBase::ContentLoaderBase() + : varXString(nullptr), + m_zone(nullptr), + m_stream(nullptr) { - varXString = nullptr; +} - m_zone = nullptr; - m_stream = nullptr; +ContentLoaderBase::ContentLoaderBase(Zone* zone, IZoneInputStream* stream) + : varXString(nullptr), + m_zone(zone), + m_stream(stream) +{ } void ContentLoaderBase::LoadXString(const bool atStreamStart) const @@ -19,9 +25,9 @@ void ContentLoaderBase::LoadXString(const bool atStreamStart) const if (atStreamStart) m_stream->Load(varXString); - if(*varXString != nullptr) + if (*varXString != nullptr) { - if(*varXString == PTR_FOLLOWING) + if (*varXString == PTR_FOLLOWING) { *varXString = m_stream->Alloc(alignof(const char)); m_stream->LoadNullTerminated(const_cast(*varXString)); @@ -37,12 +43,12 @@ void ContentLoaderBase::LoadXStringArray(const bool atStreamStart, const size_t { assert(varXString != nullptr); - if(atStreamStart) + if (atStreamStart) m_stream->Load(varXString, count); - for(size_t index = 0; index < count; index++) + for (size_t index = 0; index < count; index++) { LoadXString(false); varXString++; } -} \ No newline at end of file +} diff --git a/src/ZoneLoading/Loading/ContentLoaderBase.h b/src/ZoneLoading/Loading/ContentLoaderBase.h index 5014fb78..122b706b 100644 --- a/src/ZoneLoading/Loading/ContentLoaderBase.h +++ b/src/ZoneLoading/Loading/ContentLoaderBase.h @@ -15,6 +15,7 @@ protected: IZoneInputStream* m_stream; ContentLoaderBase(); + ContentLoaderBase(Zone* zone, IZoneInputStream* stream); void LoadXString(bool atStreamStart) const; void LoadXStringArray(bool atStreamStart, size_t count); diff --git a/src/ZoneLoading/Loading/IZoneScriptStringProvider.h b/src/ZoneLoading/Loading/IZoneScriptStringProvider.h deleted file mode 100644 index 199a773d..00000000 --- a/src/ZoneLoading/Loading/IZoneScriptStringProvider.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include "Zone/ZoneTypes.h" -#include - -class IZoneScriptStringProvider -{ -public: - virtual std::string& GetZoneScriptString(scr_string_t scrString) = 0; -};