diff --git a/src/ObjLoading/Asset/AssetCreationContext.cpp b/src/ObjLoading/Asset/AssetCreationContext.cpp index b06886e8..deb08b5a 100644 --- a/src/ObjLoading/Asset/AssetCreationContext.cpp +++ b/src/ObjLoading/Asset/AssetCreationContext.cpp @@ -65,8 +65,10 @@ std::unique_ptr GenericAssetRegistration::CreateXAssetInfo() AssetCreationContext::AssetCreationContext(Zone& zone, const AssetCreatorCollection* creators, const IgnoredAssetLookup* ignoredAssetLookup) : ZoneAssetCreationStateContainer(zone), m_zone(zone), + m_forced_asset_pools(ZoneAssetPools::CreateForGame(zone.m_game->GetId(), &zone, zone.m_priority)), m_creators(creators), - m_ignored_asset_lookup(ignoredAssetLookup) + m_ignored_asset_lookup(ignoredAssetLookup), + m_forced_load_depth(0u) { } @@ -78,10 +80,14 @@ XAssetInfoGeneric* AssetCreationContext::AddAssetGeneric(GenericAssetRegistratio const auto assetType = xAssetInfo->m_type; const auto* pAssetName = xAssetInfo->m_name.c_str(); - auto* addedAsset = m_zone.m_pools->AddAsset(std::move(xAssetInfo)); + XAssetInfoGeneric* addedAsset; + if (m_forced_load_depth > 0) + addedAsset = m_forced_asset_pools->AddAsset(std::move(xAssetInfo)); + else + addedAsset = m_zone.m_pools->AddAsset(std::move(xAssetInfo)); + if (addedAsset == nullptr) std::cerr << std::format("Failed to add asset of type \"{}\" to pool: \"{}\"\n", *m_zone.m_pools->GetAssetTypeName(assetType), pAssetName); - return addedAsset; } @@ -102,6 +108,16 @@ XAssetInfoGeneric* AssetCreationContext::LoadDependencyGeneric(const asset_type_ if (alreadyLoadedAsset) return alreadyLoadedAsset; + if (m_forced_load_depth > 0) + { + alreadyLoadedAsset = m_forced_asset_pools->GetAssetOrAssetReference(assetType, assetName); + if (alreadyLoadedAsset) + return alreadyLoadedAsset; + + // If we are already force loading an asset we should not load its dependencies + return LoadDefaultAssetDependency(assetType, std::format(",{}", assetName)); + } + if (m_ignored_asset_lookup->IsAssetIgnored(assetType, assetName)) return LoadDefaultAssetDependency(assetType, std::format(",{}", assetName)); @@ -121,9 +137,9 @@ XAssetInfoGeneric* AssetCreationContext::LoadDependencyGeneric(const asset_type_ return nullptr; } -IndirectAssetReference AssetCreationContext::LoadIndirectAssetReferenceGeneric(asset_type_t assetType, const std::string& assetName) +IndirectAssetReference AssetCreationContext::LoadIndirectAssetReferenceGeneric(const asset_type_t assetType, const std::string& assetName) { - auto* alreadyLoadedAsset = m_zone.m_pools->GetAssetOrAssetReference(assetType, assetName); + const auto* alreadyLoadedAsset = m_zone.m_pools->GetAssetOrAssetReference(assetType, assetName); if (alreadyLoadedAsset) return IndirectAssetReference(assetType, assetName); @@ -137,3 +153,44 @@ IndirectAssetReference AssetCreationContext::LoadIndirectAssetReferenceGeneric(a } return IndirectAssetReference(assetType, assetName); } + +XAssetInfoGeneric* AssetCreationContext::ForceLoadDependencyGeneric(const asset_type_t assetType, const std::string& assetName) +{ + auto* alreadyLoadedAsset = m_zone.m_pools->GetAssetOrAssetReference(assetType, assetName); + if (alreadyLoadedAsset && !alreadyLoadedAsset->IsReference()) + return alreadyLoadedAsset; + alreadyLoadedAsset = m_forced_asset_pools->GetAssetOrAssetReference(assetType, assetName); + if (alreadyLoadedAsset && !alreadyLoadedAsset->IsReference()) + return alreadyLoadedAsset; + + auto result = AssetCreationResult::NoAction(); + if (m_ignored_asset_lookup->IsAssetIgnored(assetType, assetName)) + { + // Load default asset to zone + if (!LoadDefaultAssetDependency(assetType, std::format(",{}", assetName))) + return nullptr; + + ++m_forced_load_depth; + + result = m_creators->CreateAsset(assetType, assetName, *this); + + assert(m_forced_load_depth > 0); + m_forced_load_depth = std::min(m_forced_load_depth - 1u, 0u); + } + else + result = m_creators->CreateAsset(assetType, assetName, *this); + + if (result.HasTakenAction()) + { + if (!result.HasFailed()) + return result.GetAssetInfo(); + + std::cerr << std::format("Could not load asset \"{}\" of type \"{}\"\n", assetName, *m_zone.m_pools->GetAssetTypeName(assetType)); + } + else + { + std::cerr << std::format("Missing asset \"{}\" of type \"{}\"\n", assetName, *m_zone.m_pools->GetAssetTypeName(assetType)); + } + + return nullptr; +} diff --git a/src/ObjLoading/Asset/AssetCreationContext.h b/src/ObjLoading/Asset/AssetCreationContext.h index 0dca991c..59c00098 100644 --- a/src/ObjLoading/Asset/AssetCreationContext.h +++ b/src/ObjLoading/Asset/AssetCreationContext.h @@ -65,12 +65,31 @@ class AssetCreationContext : public ZoneAssetCreationStateContainer IndirectAssetReference LoadIndirectAssetReferenceGeneric(asset_type_t assetType, const std::string& assetName); + /** + * \brief Loads an asset dependency like \c LoadDependency but guarantees that the returned asset is not a reference. + * If normally a reference would be created, the actual asset is loaded but a reference is added to the zone. + * \tparam AssetType The type of the asset + * \param assetName The name of the asset + * \return XAssetInfo of the asset that is guaranteed to not be a reference or \c nullptr + */ + template XAssetInfo* ForceLoadDependency(const std::string& assetName) + { + static_assert(std::is_base_of_v); + + return static_cast*>(ForceLoadDependencyGeneric(AssetType::EnumEntry, assetName)); + } + + XAssetInfoGeneric* ForceLoadDependencyGeneric(asset_type_t assetType, const std::string& assetName); + private: [[nodiscard]] XAssetInfoGeneric* LoadDefaultAssetDependency(asset_type_t assetType, const std::string& assetName); Zone& m_zone; + std::unique_ptr m_forced_asset_pools; const AssetCreatorCollection* m_creators; const IgnoredAssetLookup* m_ignored_asset_lookup; + + unsigned m_forced_load_depth; }; #include "AssetCreatorCollection.h" diff --git a/src/ObjLoading/Game/T6/Weapon/InfoStringLoaderWeaponT6.cpp b/src/ObjLoading/Game/T6/Weapon/InfoStringLoaderWeaponT6.cpp index d71ab521..a755a51f 100644 --- a/src/ObjLoading/Game/T6/Weapon/InfoStringLoaderWeaponT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/InfoStringLoaderWeaponT6.cpp @@ -262,7 +262,7 @@ namespace for (const auto& attachmentName : valueArray) { - auto* attachmentAssetInfo = m_context.LoadDependency(attachmentName); + auto* attachmentAssetInfo = m_context.ForceLoadDependency(attachmentName); if (attachmentAssetInfo == nullptr) { std::cerr << std::format("Failed to load attachment asset \"{}\"\n", attachmentName); @@ -314,7 +314,7 @@ namespace for (const auto& attachmentUniqueName : valueArray) { - auto* attachmentUniqueAssetInfo = m_context.LoadDependency(attachmentUniqueName); + auto* attachmentUniqueAssetInfo = m_context.ForceLoadDependency(attachmentUniqueName); if (attachmentUniqueAssetInfo == nullptr) { std::cerr << std::format("Failed to load attachment unique asset \"{}\"\n", attachmentUniqueName); diff --git a/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.cpp b/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.cpp index 0642b073..5c447d43 100644 --- a/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.cpp +++ b/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.cpp @@ -1,123 +1,57 @@ #include "GameAssetPoolIW3.h" #include "Pool/AssetPoolDynamic.h" -#include "Pool/AssetPoolStatic.h" #include #include using namespace IW3; -const char* GameAssetPoolIW3::ASSET_TYPE_NAMES[]{ - "xmodelpieces", "physpreset", "xanim", "xmodel", "material", "techniqueset", "image", "sound", "soundcurve", "loadedsound", - "clipmap", "clipmap", "comworld", "gameworldsp", "gameworldmp", "mapents", "gfxworld", "lightdef", "uimap", "font", - "menulist", "menu", "localize", "weapon", "snddriverglobals", "fx", "impactfx", "aitype", "mptype", "character", - "xmodelalias", "rawfile", "stringtable", -}; +namespace +{ + constexpr const char* ASSET_TYPE_NAMES[]{ + "xmodelpieces", "physpreset", "xanim", "xmodel", "material", "techniqueset", "image", "sound", "soundcurve", "loadedsound", + "clipmap", "clipmap", "comworld", "gameworldsp", "gameworldmp", "mapents", "gfxworld", "lightdef", "uimap", "font", + "menulist", "menu", "localize", "weapon", "snddriverglobals", "fx", "impactfx", "aitype", "mptype", "character", + "xmodelalias", "rawfile", "stringtable", + }; +} -GameAssetPoolIW3::GameAssetPoolIW3(Zone* zone, const int priority) +GameAssetPoolIW3::GameAssetPoolIW3(Zone* zone, const zone_priority_t priority) : ZoneAssetPools(zone), m_priority(priority) { static_assert(std::extent_v == ASSET_TYPE_COUNT); -} - -void GameAssetPoolIW3::InitPoolStatic(const asset_type_t type, const size_t capacity) -{ -#define CASE_INIT_POOL_STATIC(assetType, poolName) \ - case assetType: \ - { \ - if ((poolName) == nullptr && capacity > 0) \ - { \ - (poolName) = std::make_unique>(capacity, m_priority, (assetType)); \ - } \ - break; \ - } - - switch (type) - { - CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset) - CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts) - CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel) - CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material) - CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set) - CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image) - CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound) - CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve) - CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound) - CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map) - CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map) - CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world) - CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp) - CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp) - CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents) - CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world) - CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def) - CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font) - CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list) - CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def) - CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize) - CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon) - CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx) - CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table) - CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file) - CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table) - - default: - assert(type >= 0 && type < ASSET_TYPE_COUNT); - break; - } - -#undef CASE_INIT_POOL_STATIC -} - -void GameAssetPoolIW3::InitPoolDynamic(const asset_type_t type) -{ -#define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \ - case assetType: \ - { \ - if ((poolName) == nullptr) \ - { \ - (poolName) = std::make_unique>(m_priority, (assetType)); \ - } \ - break; \ - } - - switch (type) - { - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table) - - default: - assert(type >= 0 && type < ASSET_TYPE_COUNT); - break; - } -#undef CASE_INIT_POOL_STATIC +#define INIT_POOL(poolName) (poolName) = std::make_unique>(m_priority) + + INIT_POOL(m_phys_preset); + INIT_POOL(m_xanim_parts); + INIT_POOL(m_xmodel); + INIT_POOL(m_material); + INIT_POOL(m_technique_set); + INIT_POOL(m_image); + INIT_POOL(m_sound); + INIT_POOL(m_sound_curve); + INIT_POOL(m_loaded_sound); + INIT_POOL(m_clip_map); + INIT_POOL(m_com_world); + INIT_POOL(m_game_world_sp); + INIT_POOL(m_game_world_mp); + INIT_POOL(m_map_ents); + INIT_POOL(m_gfx_world); + INIT_POOL(m_gfx_light_def); + INIT_POOL(m_font); + INIT_POOL(m_menu_list); + INIT_POOL(m_menu_def); + INIT_POOL(m_localize); + INIT_POOL(m_weapon); + INIT_POOL(m_fx); + INIT_POOL(m_fx_impact_table); + INIT_POOL(m_raw_file); + INIT_POOL(m_string_table); + +#undef INIT_POOL } XAssetInfoGeneric* GameAssetPoolIW3::AddAssetToPool(std::unique_ptr xAssetInfo) @@ -125,7 +59,7 @@ XAssetInfoGeneric* GameAssetPoolIW3::AddAssetToPool(std::unique_ptrAddAsset(std::unique_ptr>( \ static_cast*>(xAssetInfo.release()))); \ } @@ -174,7 +108,7 @@ XAssetInfoGeneric* GameAssetPoolIW3::GetAsset(const asset_type_t type, const std #define CASE_GET_ASSET(assetType, poolName) \ case assetType: \ { \ - if ((poolName) != nullptr) \ + if (poolName) \ return (poolName)->GetAsset(std::move(name)); \ break; \ } diff --git a/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.h b/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.h index 062c7af2..8f6b3bf9 100644 --- a/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.h +++ b/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.h @@ -9,13 +9,6 @@ class GameAssetPoolIW3 final : public ZoneAssetPools { - int m_priority; - - static const char* ASSET_TYPE_NAMES[]; - -protected: - XAssetInfoGeneric* AddAssetToPool(std::unique_ptr xAssetInfo) override; - public: std::unique_ptr> m_phys_preset; std::unique_ptr> m_xanim_parts; @@ -46,17 +39,20 @@ class GameAssetPoolIW3 final : public ZoneAssetPools std::unique_ptr> m_raw_file; std::unique_ptr> m_string_table; - GameAssetPoolIW3(Zone* zone, int priority); + GameAssetPoolIW3(Zone* zone, zone_priority_t priority); ~GameAssetPoolIW3() override = default; - void InitPoolStatic(asset_type_t type, size_t capacity) override; - void InitPoolDynamic(asset_type_t type) override; - - _NODISCARD XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override; + [[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override; static std::optional AssetTypeNameByType(asset_type_t assetType); - _NODISCARD std::optional GetAssetTypeName(asset_type_t assetType) const override; + [[nodiscard]] std::optional GetAssetTypeName(asset_type_t assetType) const override; static asset_type_t AssetTypeCount(); - _NODISCARD asset_type_t GetAssetTypeCount() const override; + [[nodiscard]] asset_type_t GetAssetTypeCount() const override; + +protected: + XAssetInfoGeneric* AddAssetToPool(std::unique_ptr xAssetInfo) override; + +private: + zone_priority_t m_priority; }; diff --git a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp index c0d38a56..b8b55bf2 100644 --- a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp +++ b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp @@ -1,144 +1,69 @@ #include "GameAssetPoolIW4.h" #include "Pool/AssetPoolDynamic.h" -#include "Pool/AssetPoolStatic.h" #include #include using namespace IW4; -const char* GameAssetPoolIW4::ASSET_TYPE_NAMES[]{ - "physpreset", "physcollmap", "xanim", "xmodelsurfs", "xmodel", "material", "pixelshader", "vertexshader", "vertexdecl", "techniqueset", - "image", "sound", "soundcurve", "loadedsound", "clipmap", "clipmap", "comworld", "gameworldsp", "gameworldmp", "mapents", - "fxworld", "gfxworld", "lightdef", "uimap", "font", "menulist", "menu", "localize", "weapon", "snddriverglobals", - "fx", "impactfx", "aitype", "mptype", "character", "xmodelalias", "rawfile", "stringtable", "leaderboard", "structureddatadef", - "tracer", "vehicle", "addonmapents", -}; - -GameAssetPoolIW4::GameAssetPoolIW4(Zone* zone, const int priority) - : ZoneAssetPools(zone), - m_priority(priority) -{ - assert(std::extent_v == ASSET_TYPE_COUNT); -} - -void GameAssetPoolIW4::InitPoolStatic(const asset_type_t type, const size_t capacity) +namespace { -#define CASE_INIT_POOL_STATIC(assetType, poolName) \ - case assetType: \ - { \ - if ((poolName) == nullptr && capacity > 0) \ - { \ - (poolName) = std::make_unique>(capacity, m_priority, (assetType)); \ - } \ - break; \ - } - - switch (type) - { - CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset) - CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap) - CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts) - CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel) - CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material) - CASE_INIT_POOL_STATIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader) - CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader) - CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl) - CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set) - CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image) - CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound) - CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve) - CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound) - CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map) - CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_MP, m_clip_map) - CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world) - CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp) - CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp) - CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents) - CASE_INIT_POOL_STATIC(ASSET_TYPE_FXWORLD, m_fx_world) - CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world) - CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def) - CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font) - CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list) - CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def) - CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize) - CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon) - CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx) - CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table) - CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file) - CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table) - CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard) - CASE_INIT_POOL_STATIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set) - CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer) - CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE, m_vehicle) - CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents) - - default: - assert(type >= 0 && type < ASSET_TYPE_COUNT); - break; - } - -#undef CASE_INIT_POOL_STATIC + constexpr const char* ASSET_TYPE_NAMES[]{ + "physpreset", "physcollmap", "xanim", "xmodelsurfs", "xmodel", "material", "pixelshader", "vertexshader", + "vertexdecl", "techniqueset", "image", "sound", "soundcurve", "loadedsound", "clipmap", "clipmap", + "comworld", "gameworldsp", "gameworldmp", "mapents", "fxworld", "gfxworld", "lightdef", "uimap", + "font", "menulist", "menu", "localize", "weapon", "snddriverglobals", "fx", "impactfx", + "aitype", "mptype", "character", "xmodelalias", "rawfile", "stringtable", "leaderboard", "structureddatadef", + "tracer", "vehicle", "addonmapents", + }; } -void GameAssetPoolIW4::InitPoolDynamic(const asset_type_t type) +GameAssetPoolIW4::GameAssetPoolIW4(Zone* zone, const zone_priority_t priority) + : ZoneAssetPools(zone), + m_priority(priority) { -#define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \ - case assetType: \ - { \ - if ((poolName) == nullptr) \ - { \ - (poolName) = std::make_unique>(m_priority, (assetType)); \ - } \ - break; \ - } - - switch (type) - { - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_MP, m_clip_map) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FXWORLD, m_fx_world) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE, m_vehicle) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents) - - default: - assert(type >= 0 && type < ASSET_TYPE_COUNT); - break; - } - -#undef CASE_INIT_POOL_DYNAMIC + static_assert(std::extent_v == ASSET_TYPE_COUNT); + +#define INIT_POOL(poolName) (poolName) = std::make_unique>(m_priority) + + INIT_POOL(m_phys_preset); + INIT_POOL(m_phys_collmap); + INIT_POOL(m_xanim_parts); + INIT_POOL(m_xmodel); + INIT_POOL(m_material); + INIT_POOL(m_material_pixel_shader); + INIT_POOL(m_material_vertex_shader); + INIT_POOL(m_material_vertex_decl); + INIT_POOL(m_technique_set); + INIT_POOL(m_image); + INIT_POOL(m_sound); + INIT_POOL(m_sound_curve); + INIT_POOL(m_loaded_sound); + INIT_POOL(m_clip_map); + INIT_POOL(m_com_world); + INIT_POOL(m_game_world_sp); + INIT_POOL(m_game_world_mp); + INIT_POOL(m_map_ents); + INIT_POOL(m_fx_world); + INIT_POOL(m_gfx_world); + INIT_POOL(m_gfx_light_def); + INIT_POOL(m_font); + INIT_POOL(m_menu_list); + INIT_POOL(m_menu_def); + INIT_POOL(m_localize); + INIT_POOL(m_weapon); + INIT_POOL(m_fx); + INIT_POOL(m_fx_impact_table); + INIT_POOL(m_raw_file); + INIT_POOL(m_string_table); + INIT_POOL(m_leaderboard); + INIT_POOL(m_structed_data_def_set); + INIT_POOL(m_tracer); + INIT_POOL(m_vehicle); + INIT_POOL(m_addon_map_ents); + +#undef INIT_POOL } XAssetInfoGeneric* GameAssetPoolIW4::AddAssetToPool(std::unique_ptr xAssetInfo) @@ -146,7 +71,7 @@ XAssetInfoGeneric* GameAssetPoolIW4::AddAssetToPool(std::unique_ptrAddAsset(std::unique_ptr>( \ static_cast*>(xAssetInfo.release()))); \ } @@ -205,7 +130,7 @@ XAssetInfoGeneric* GameAssetPoolIW4::GetAsset(const asset_type_t type, const std #define CASE_GET_ASSET(assetType, poolName) \ case assetType: \ { \ - if ((poolName) != nullptr) \ + if (poolName) \ return (poolName)->GetAsset(name); \ break; \ } diff --git a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h index 7cb4079c..77c0f941 100644 --- a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h +++ b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h @@ -3,20 +3,11 @@ #include "Game/IW4/IW4.h" #include "Pool/AssetPool.h" #include "Pool/ZoneAssetPools.h" -#include "Utils/ClassUtils.h" #include class GameAssetPoolIW4 final : public ZoneAssetPools { - int m_priority; - - static constexpr const char* ASSET_TYPE_INVALID = "invalid_asset_type"; - static const char* ASSET_TYPE_NAMES[]; - -protected: - XAssetInfoGeneric* AddAssetToPool(std::unique_ptr xAssetInfo) override; - public: std::unique_ptr> m_phys_preset; std::unique_ptr> m_phys_collmap; @@ -54,17 +45,20 @@ class GameAssetPoolIW4 final : public ZoneAssetPools std::unique_ptr> m_vehicle; std::unique_ptr> m_addon_map_ents; - GameAssetPoolIW4(Zone* zone, int priority); + GameAssetPoolIW4(Zone* zone, zone_priority_t priority); ~GameAssetPoolIW4() override = default; - void InitPoolStatic(asset_type_t type, size_t capacity) override; - void InitPoolDynamic(asset_type_t type) override; - - _NODISCARD XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override; + [[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override; static std::optional AssetTypeNameByType(asset_type_t assetType); - _NODISCARD std::optional GetAssetTypeName(asset_type_t assetType) const override; + [[nodiscard]] std::optional GetAssetTypeName(asset_type_t assetType) const override; static asset_type_t AssetTypeCount(); - _NODISCARD asset_type_t GetAssetTypeCount() const override; + [[nodiscard]] asset_type_t GetAssetTypeCount() const override; + +protected: + XAssetInfoGeneric* AddAssetToPool(std::unique_ptr xAssetInfo) override; + +private: + zone_priority_t m_priority; }; diff --git a/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.cpp b/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.cpp index 87ff0f5e..4d22eff3 100644 --- a/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.cpp +++ b/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.cpp @@ -1,193 +1,114 @@ #include "GameAssetPoolIW5.h" #include "Pool/AssetPoolDynamic.h" -#include "Pool/AssetPoolStatic.h" #include #include using namespace IW5; -const char* GameAssetPoolIW5::ASSET_TYPE_NAMES[]{ - "physpreset", - "physcollmap", - "xanim", - "xmodelsurfs", - "xmodel", - "material", - "pixelshader", - "vertexshader", - "vertexdecl", - "techniqueset", - "image", - "sound", - "soundcurve", - "loadedsound", - "clipmap", - "comworld", - "glassworld", - "pathdata", - "vehicletrack", - "mapents", - "fxworld", - "gfxworld", - "lightdef", - "uimap", - "font", - "menulist", - "menu", - "localize", - "attachment", - "weapon", - "snddriverglobals", - "fx", - "impactfx", - "surfacefx", - "aitype", - "mptype", - "character", - "xmodelalias", - "rawfile", - "scriptfile", - "stringtable", - "leaderboard", - "structureddatadef", - "tracer", - "vehicle", - "addonmapents", -}; - -GameAssetPoolIW5::GameAssetPoolIW5(Zone* zone, const int priority) - : ZoneAssetPools(zone), - m_priority(priority) +namespace { - assert(std::extent_v == ASSET_TYPE_COUNT); + constexpr const char* ASSET_TYPE_NAMES[]{ + "physpreset", + "physcollmap", + "xanim", + "xmodelsurfs", + "xmodel", + "material", + "pixelshader", + "vertexshader", + "vertexdecl", + "techniqueset", + "image", + "sound", + "soundcurve", + "loadedsound", + "clipmap", + "comworld", + "glassworld", + "pathdata", + "vehicletrack", + "mapents", + "fxworld", + "gfxworld", + "lightdef", + "uimap", + "font", + "menulist", + "menu", + "localize", + "attachment", + "weapon", + "snddriverglobals", + "fx", + "impactfx", + "surfacefx", + "aitype", + "mptype", + "character", + "xmodelalias", + "rawfile", + "scriptfile", + "stringtable", + "leaderboard", + "structureddatadef", + "tracer", + "vehicle", + "addonmapents", + }; } -void GameAssetPoolIW5::InitPoolStatic(const asset_type_t type, const size_t capacity) -{ -#define CASE_INIT_POOL_STATIC(assetType, poolName) \ - case assetType: \ - { \ - if ((poolName) == nullptr && capacity > 0) \ - { \ - (poolName) = std::make_unique>(capacity, m_priority, (assetType)); \ - } \ - break; \ - } - - switch (type) - { - CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset) - CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap) - CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts) - CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs) - CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel) - CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material) - CASE_INIT_POOL_STATIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader) - CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader) - CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl) - CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set) - CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image) - CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound) - CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve) - CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound) - CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map) - CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world) - CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSWORLD, m_glass_world) - CASE_INIT_POOL_STATIC(ASSET_TYPE_PATHDATA, m_path_data) - CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track) - CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents) - CASE_INIT_POOL_STATIC(ASSET_TYPE_FXWORLD, m_fx_world) - CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world) - CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def) - CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font) - CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list) - CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def) - CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize) - CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT, m_attachment) - CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon) - CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx) - CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table) - CASE_INIT_POOL_STATIC(ASSET_TYPE_SURFACE_FX, m_surface_fx_table) - CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file) - CASE_INIT_POOL_STATIC(ASSET_TYPE_SCRIPTFILE, m_script_file) - CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table) - CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard) - CASE_INIT_POOL_STATIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set) - CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer) - CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE, m_vehicle) - CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents) - - default: - assert(type >= 0 && type < ASSET_TYPE_COUNT); - break; - } - -#undef CASE_INIT_POOL_STATIC -} - -void GameAssetPoolIW5::InitPoolDynamic(const asset_type_t type) +GameAssetPoolIW5::GameAssetPoolIW5(Zone* zone, const zone_priority_t priority) + : ZoneAssetPools(zone), + m_priority(priority) { -#define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \ - case assetType: \ - { \ - if ((poolName) == nullptr) \ - { \ - (poolName) = std::make_unique>(m_priority, (assetType)); \ - } \ - break; \ - } + static_assert(std::extent_v == ASSET_TYPE_COUNT); - switch (type) - { - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GLASSWORLD, m_glass_world) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PATHDATA, m_path_data) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FXWORLD, m_fx_world) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT, m_attachment) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SURFACE_FX, m_surface_fx_table) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SCRIPTFILE, m_script_file) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE, m_vehicle) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents) +#define INIT_POOL(poolName) (poolName) = std::make_unique>(m_priority) - default: - assert(type >= 0 && type < ASSET_TYPE_COUNT); - break; - } + INIT_POOL(m_phys_preset); + INIT_POOL(m_phys_collmap); + INIT_POOL(m_xanim_parts); + INIT_POOL(m_xmodel_surfs); + INIT_POOL(m_xmodel); + INIT_POOL(m_material); + INIT_POOL(m_material_pixel_shader); + INIT_POOL(m_material_vertex_shader); + INIT_POOL(m_material_vertex_decl); + INIT_POOL(m_technique_set); + INIT_POOL(m_image); + INIT_POOL(m_sound); + INIT_POOL(m_sound_curve); + INIT_POOL(m_loaded_sound); + INIT_POOL(m_clip_map); + INIT_POOL(m_com_world); + INIT_POOL(m_glass_world); + INIT_POOL(m_path_data); + INIT_POOL(m_vehicle_track); + INIT_POOL(m_map_ents); + INIT_POOL(m_fx_world); + INIT_POOL(m_gfx_world); + INIT_POOL(m_gfx_light_def); + INIT_POOL(m_font); + INIT_POOL(m_menu_list); + INIT_POOL(m_menu_def); + INIT_POOL(m_localize); + INIT_POOL(m_attachment); + INIT_POOL(m_weapon); + INIT_POOL(m_fx); + INIT_POOL(m_fx_impact_table); + INIT_POOL(m_surface_fx_table); + INIT_POOL(m_raw_file); + INIT_POOL(m_script_file); + INIT_POOL(m_string_table); + INIT_POOL(m_leaderboard); + INIT_POOL(m_structed_data_def_set); + INIT_POOL(m_tracer); + INIT_POOL(m_vehicle); + INIT_POOL(m_addon_map_ents); -#undef CASE_INIT_POOL_DYNAMIC +#undef INIT_POOL } XAssetInfoGeneric* GameAssetPoolIW5::AddAssetToPool(std::unique_ptr xAssetInfo) @@ -195,7 +116,7 @@ XAssetInfoGeneric* GameAssetPoolIW5::AddAssetToPool(std::unique_ptrAddAsset(std::unique_ptr>( \ static_cast*>(xAssetInfo.release()))); \ } @@ -258,8 +179,8 @@ XAssetInfoGeneric* GameAssetPoolIW5::GetAsset(const asset_type_t type, const std #define CASE_GET_ASSET(assetType, poolName) \ case assetType: \ { \ - if ((poolName) != nullptr) \ - return (poolName)->GetAsset(std::move(name)); \ + if (poolName) \ + return (poolName)->GetAsset(name); \ break; \ } diff --git a/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.h b/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.h index a12f4df4..0e40cfc7 100644 --- a/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.h +++ b/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.h @@ -8,14 +8,6 @@ class GameAssetPoolIW5 final : public ZoneAssetPools { - int m_priority; - - static constexpr const char* ASSET_TYPE_INVALID = "invalid_asset_type"; - static const char* ASSET_TYPE_NAMES[]; - -protected: - XAssetInfoGeneric* AddAssetToPool(std::unique_ptr xAssetInfo) override; - public: std::unique_ptr> m_phys_preset; std::unique_ptr> m_phys_collmap; @@ -58,17 +50,20 @@ class GameAssetPoolIW5 final : public ZoneAssetPools std::unique_ptr> m_vehicle; std::unique_ptr> m_addon_map_ents; - GameAssetPoolIW5(Zone* zone, int priority); + GameAssetPoolIW5(Zone* zone, zone_priority_t priority); ~GameAssetPoolIW5() override = default; - void InitPoolStatic(asset_type_t type, size_t capacity) override; - void InitPoolDynamic(asset_type_t type) override; - - _NODISCARD XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override; + [[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override; static std::optional AssetTypeNameByType(asset_type_t assetType); - _NODISCARD std::optional GetAssetTypeName(asset_type_t assetType) const override; + [[nodiscard]] std::optional GetAssetTypeName(asset_type_t assetType) const override; static asset_type_t AssetTypeCount(); - _NODISCARD asset_type_t GetAssetTypeCount() const override; + [[nodiscard]] asset_type_t GetAssetTypeCount() const override; + +protected: + XAssetInfoGeneric* AddAssetToPool(std::unique_ptr xAssetInfo) override; + +private: + zone_priority_t m_priority; }; diff --git a/src/ZoneCommon/Game/T5/GameAssetPoolT5.cpp b/src/ZoneCommon/Game/T5/GameAssetPoolT5.cpp index 097412ec..a820ea21 100644 --- a/src/ZoneCommon/Game/T5/GameAssetPoolT5.cpp +++ b/src/ZoneCommon/Game/T5/GameAssetPoolT5.cpp @@ -1,140 +1,67 @@ #include "GameAssetPoolT5.h" #include "Pool/AssetPoolDynamic.h" -#include "Pool/AssetPoolStatic.h" #include #include using namespace T5; -const char* GameAssetPoolT5::ASSET_TYPE_NAMES[]{ - "xmodelpieces", "physpreset", "physconstraints", "destructibledef", "xanim", "xmodel", "material", - "techniqueset", "image", "soundbank", "soundpatch", "clipmap", "clipmap", "comworld", - "gameworldsp", "gameworldmp", "mapents", "gfxworld", "gfxlightdef", "uimap", "font", - "menulist", "menu", "localize", "weapon", "weapondef", "weaponvariant", "snddriverglobals", - "fx", "fximpacttable", "aitype", "mptype", "mpbody", "mphead", "character", - "xmodelalias", "rawfile", "stringtable", "packindex", "xglobals", "ddl", "glasses", - "emblemset", -}; - -GameAssetPoolT5::GameAssetPoolT5(Zone* zone, const int priority) - : ZoneAssetPools(zone), - m_priority(priority) -{ - assert(std::extent_v == ASSET_TYPE_COUNT); -} - -void GameAssetPoolT5::InitPoolStatic(const asset_type_t type, const size_t capacity) +namespace { -#define CASE_INIT_POOL_STATIC(assetType, poolName) \ - case assetType: \ - { \ - if ((poolName) == nullptr && capacity > 0) \ - { \ - (poolName) = std::make_unique>(capacity, m_priority, (assetType)); \ - } \ - break; \ - } - - switch (type) - { - CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset) - CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints) - CASE_INIT_POOL_STATIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def) - CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts) - CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel) - CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material) - CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set) - CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image) - CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound_bank) - CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch) - CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map) - CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map) - CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world) - CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp) - CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp) - CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents) - CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world) - CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def) - CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font) - CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list) - CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def) - CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize) - CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon) - CASE_INIT_POOL_STATIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals) - CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx) - CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table) - CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file) - CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table) - CASE_INIT_POOL_STATIC(ASSET_TYPE_PACK_INDEX, m_pack_index) - CASE_INIT_POOL_STATIC(ASSET_TYPE_XGLOBALS, m_xglobals) - CASE_INIT_POOL_STATIC(ASSET_TYPE_DDL, m_ddl) - CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSES, m_glasses) - CASE_INIT_POOL_STATIC(ASSET_TYPE_EMBLEMSET, m_emblem_set) - - default: - assert(type >= 0 && type < ASSET_TYPE_COUNT); - break; - } - -#undef CASE_INIT_POOL_STATIC + constexpr const char* ASSET_TYPE_NAMES[]{ + "xmodelpieces", "physpreset", "physconstraints", "destructibledef", "xanim", "xmodel", "material", + "techniqueset", "image", "soundbank", "soundpatch", "clipmap", "clipmap", "comworld", + "gameworldsp", "gameworldmp", "mapents", "gfxworld", "gfxlightdef", "uimap", "font", + "menulist", "menu", "localize", "weapon", "weapondef", "weaponvariant", "snddriverglobals", + "fx", "fximpacttable", "aitype", "mptype", "mpbody", "mphead", "character", + "xmodelalias", "rawfile", "stringtable", "packindex", "xglobals", "ddl", "glasses", + "emblemset", + }; } -void GameAssetPoolT5::InitPoolDynamic(const asset_type_t type) +GameAssetPoolT5::GameAssetPoolT5(Zone* zone, const zone_priority_t priority) + : ZoneAssetPools(zone), + m_priority(priority) { -#define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \ - case assetType: \ - { \ - if ((poolName) == nullptr) \ - { \ - (poolName) = std::make_unique>(m_priority, (assetType)); \ - } \ - break; \ - } - - switch (type) - { - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound_bank) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PACK_INDEX, m_pack_index) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XGLOBALS, m_xglobals) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DDL, m_ddl) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GLASSES, m_glasses) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_EMBLEMSET, m_emblem_set) - - default: - assert(type >= 0 && type < ASSET_TYPE_COUNT); - break; - } - -#undef CASE_INIT_POOL_DYNAMIC + static_assert(std::extent_v == ASSET_TYPE_COUNT); + +#define INIT_POOL(poolName) (poolName) = std::make_unique>(m_priority) + + INIT_POOL(m_phys_preset); + INIT_POOL(m_phys_constraints); + INIT_POOL(m_destructible_def); + INIT_POOL(m_xanim_parts); + INIT_POOL(m_xmodel); + INIT_POOL(m_material); + INIT_POOL(m_technique_set); + INIT_POOL(m_image); + INIT_POOL(m_sound_bank); + INIT_POOL(m_sound_patch); + INIT_POOL(m_clip_map); + INIT_POOL(m_com_world); + INIT_POOL(m_game_world_sp); + INIT_POOL(m_game_world_mp); + INIT_POOL(m_map_ents); + INIT_POOL(m_gfx_world); + INIT_POOL(m_gfx_light_def); + INIT_POOL(m_font); + INIT_POOL(m_menu_list); + INIT_POOL(m_menu_def); + INIT_POOL(m_localize); + INIT_POOL(m_weapon); + INIT_POOL(m_snd_driver_globals); + INIT_POOL(m_fx); + INIT_POOL(m_fx_impact_table); + INIT_POOL(m_raw_file); + INIT_POOL(m_string_table); + INIT_POOL(m_pack_index); + INIT_POOL(m_xglobals); + INIT_POOL(m_ddl); + INIT_POOL(m_glasses); + INIT_POOL(m_emblem_set); + +#undef INIT_POOL } XAssetInfoGeneric* GameAssetPoolT5::AddAssetToPool(std::unique_ptr xAssetInfo) @@ -142,7 +69,7 @@ XAssetInfoGeneric* GameAssetPoolT5::AddAssetToPool(std::unique_ptrAddAsset(std::unique_ptr>( \ static_cast*>(xAssetInfo.release()))); \ } @@ -198,8 +125,8 @@ XAssetInfoGeneric* GameAssetPoolT5::GetAsset(const asset_type_t type, const std: #define CASE_GET_ASSET(assetType, poolName) \ case assetType: \ { \ - if ((poolName) != nullptr) \ - return (poolName)->GetAsset(std::move(name)); \ + if (poolName) \ + return (poolName)->GetAsset(name); \ break; \ } diff --git a/src/ZoneCommon/Game/T5/GameAssetPoolT5.h b/src/ZoneCommon/Game/T5/GameAssetPoolT5.h index 2d05eeed..ccb2c09b 100644 --- a/src/ZoneCommon/Game/T5/GameAssetPoolT5.h +++ b/src/ZoneCommon/Game/T5/GameAssetPoolT5.h @@ -8,14 +8,6 @@ class GameAssetPoolT5 final : public ZoneAssetPools { - int m_priority; - - static constexpr const char* ASSET_TYPE_INVALID = "invalid_asset_type"; - static const char* ASSET_TYPE_NAMES[]; - -protected: - XAssetInfoGeneric* AddAssetToPool(std::unique_ptr xAssetInfo) override; - public: std::unique_ptr> m_phys_preset; std::unique_ptr> m_phys_constraints; @@ -50,17 +42,20 @@ class GameAssetPoolT5 final : public ZoneAssetPools std::unique_ptr> m_glasses; std::unique_ptr> m_emblem_set; - GameAssetPoolT5(Zone* zone, int priority); + GameAssetPoolT5(Zone* zone, zone_priority_t priority); ~GameAssetPoolT5() override = default; - void InitPoolStatic(asset_type_t type, size_t capacity) override; - void InitPoolDynamic(asset_type_t type) override; - - _NODISCARD XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override; + [[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override; static std::optional AssetTypeNameByType(asset_type_t assetType); - _NODISCARD std::optional GetAssetTypeName(asset_type_t assetType) const override; + [[nodiscard]] std::optional GetAssetTypeName(asset_type_t assetType) const override; static asset_type_t AssetTypeCount(); - _NODISCARD asset_type_t GetAssetTypeCount() const override; + [[nodiscard]] asset_type_t GetAssetTypeCount() const override; + +protected: + XAssetInfoGeneric* AddAssetToPool(std::unique_ptr xAssetInfo) override; + +private: + zone_priority_t m_priority; }; diff --git a/src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp b/src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp index 558e85f4..95d2ebc6 100644 --- a/src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp +++ b/src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp @@ -1,225 +1,136 @@ #include "GameAssetPoolT6.h" #include "Pool/AssetPoolDynamic.h" -#include "Pool/AssetPoolStatic.h" #include #include using namespace T6; -const char* GameAssetPoolT6::ASSET_TYPE_NAMES[]{ - "xmodelpieces", - "physpreset", - "physconstraints", - "destructibledef", - "xanim", - "xmodel", - "material", - "techniqueset", - "image", - "soundbank", - "soundpatch", - "clipmap", - "clipmap", - "comworld", - "gameworldsp", - "gameworldmp", - "mapents", - "gfxworld", - "gfxlightdef", - "uimap", - "font", - "fonticon", - "menulist", - "menu", - "localize", - "weapon", - "weapondef", - "weaponvariant", - "weaponfull", - "attachment", - "attachmentunique", - "camo", - "snddriverglobals", - "fx", - "fximpacttable", - "aitype", - "mptype", - "mpbody", - "mphead", - "character", - "xmodelalias", - "rawfile", - "stringtable", - "leaderboard", - "xglobals", - "ddl", - "glasses", - "emblemset", - "script", - "keyvaluepairs", - "vehicle", - "memoryblock", - "addonmapents", - "tracer", - "skinnedverts", - "qdb", - "slug", - "footsteptable", - "footstepfxtable", - "zbarrier", -}; +namespace +{ + constexpr const char* ASSET_TYPE_NAMES[]{ + "xmodelpieces", + "physpreset", + "physconstraints", + "destructibledef", + "xanim", + "xmodel", + "material", + "techniqueset", + "image", + "soundbank", + "soundpatch", + "clipmap", + "clipmap", + "comworld", + "gameworldsp", + "gameworldmp", + "mapents", + "gfxworld", + "gfxlightdef", + "uimap", + "font", + "fonticon", + "menulist", + "menu", + "localize", + "weapon", + "weapondef", + "weaponvariant", + "weaponfull", + "attachment", + "attachmentunique", + "camo", + "snddriverglobals", + "fx", + "fximpacttable", + "aitype", + "mptype", + "mpbody", + "mphead", + "character", + "xmodelalias", + "rawfile", + "stringtable", + "leaderboard", + "xglobals", + "ddl", + "glasses", + "emblemset", + "script", + "keyvaluepairs", + "vehicle", + "memoryblock", + "addonmapents", + "tracer", + "skinnedverts", + "qdb", + "slug", + "footsteptable", + "footstepfxtable", + "zbarrier", + }; +} // namespace -GameAssetPoolT6::GameAssetPoolT6(Zone* zone, const int priority) +GameAssetPoolT6::GameAssetPoolT6(Zone* zone, const zone_priority_t priority) : ZoneAssetPools(zone), m_priority(priority) { - assert(std::extent_v == ASSET_TYPE_COUNT); -} - -void GameAssetPoolT6::InitPoolStatic(const asset_type_t type, const size_t capacity) -{ -#define CASE_INIT_POOL_STATIC(assetType, poolName) \ - case assetType: \ - { \ - if ((poolName) == nullptr && capacity > 0) \ - { \ - (poolName) = std::make_unique>(capacity, m_priority, (assetType)); \ - } \ - break; \ - } - - switch (type) - { - CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset) - CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints) - CASE_INIT_POOL_STATIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def) - CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts) - CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel) - CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material) - CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set) - CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image) - CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound_bank) - CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch) - CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map) - CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map) - CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world) - CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp) - CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp) - CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents) - CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world) - CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def) - CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font) - CASE_INIT_POOL_STATIC(ASSET_TYPE_FONTICON, m_font_icon) - CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list) - CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def) - CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize) - CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon) - CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT, m_attachment) - CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique) - CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON_CAMO, m_camo) - CASE_INIT_POOL_STATIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals) - CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx) - CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table) - CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file) - CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table) - CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard) - CASE_INIT_POOL_STATIC(ASSET_TYPE_XGLOBALS, m_xglobals) - CASE_INIT_POOL_STATIC(ASSET_TYPE_DDL, m_ddl) - CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSES, m_glasses) - CASE_INIT_POOL_STATIC(ASSET_TYPE_EMBLEMSET, m_emblem_set) - CASE_INIT_POOL_STATIC(ASSET_TYPE_SCRIPTPARSETREE, m_script) - CASE_INIT_POOL_STATIC(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs) - CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLEDEF, m_vehicle) - CASE_INIT_POOL_STATIC(ASSET_TYPE_MEMORYBLOCK, m_memory_block) - CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents) - CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer) - CASE_INIT_POOL_STATIC(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts) - CASE_INIT_POOL_STATIC(ASSET_TYPE_QDB, m_qdb) - CASE_INIT_POOL_STATIC(ASSET_TYPE_SLUG, m_slug) - CASE_INIT_POOL_STATIC(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table) - CASE_INIT_POOL_STATIC(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table) - CASE_INIT_POOL_STATIC(ASSET_TYPE_ZBARRIER, m_zbarrier) - - default: - assert(type >= 0 && type < ASSET_TYPE_COUNT); - break; - } - -#undef CASE_INIT_POOL_STATIC -} - -void GameAssetPoolT6::InitPoolDynamic(const asset_type_t type) -{ -#define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \ - case assetType: \ - { \ - if ((poolName) == nullptr) \ - { \ - (poolName) = std::make_unique>(m_priority, (assetType)); \ - } \ - break; \ - } + static_assert(std::extent_v == ASSET_TYPE_COUNT); - switch (type) - { - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound_bank) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONTICON, m_font_icon) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT, m_attachment) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON_CAMO, m_camo) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XGLOBALS, m_xglobals) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DDL, m_ddl) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GLASSES, m_glasses) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_EMBLEMSET, m_emblem_set) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SCRIPTPARSETREE, m_script) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLEDEF, m_vehicle) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MEMORYBLOCK, m_memory_block) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_QDB, m_qdb) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SLUG, m_slug) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table) - CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ZBARRIER, m_zbarrier) +#define INIT_POOL(poolName) (poolName) = std::make_unique>(m_priority) - default: - assert(type >= 0 && type < ASSET_TYPE_COUNT); - break; - } + INIT_POOL(m_phys_preset); + INIT_POOL(m_phys_constraints); + INIT_POOL(m_destructible_def); + INIT_POOL(m_xanim_parts); + INIT_POOL(m_xmodel); + INIT_POOL(m_material); + INIT_POOL(m_technique_set); + INIT_POOL(m_image); + INIT_POOL(m_sound_bank); + INIT_POOL(m_sound_patch); + INIT_POOL(m_clip_map); + INIT_POOL(m_com_world); + INIT_POOL(m_game_world_sp); + INIT_POOL(m_game_world_mp); + INIT_POOL(m_map_ents); + INIT_POOL(m_gfx_world); + INIT_POOL(m_gfx_light_def); + INIT_POOL(m_font); + INIT_POOL(m_font_icon); + INIT_POOL(m_menu_list); + INIT_POOL(m_menu_def); + INIT_POOL(m_localize); + INIT_POOL(m_weapon); + INIT_POOL(m_attachment); + INIT_POOL(m_attachment_unique); + INIT_POOL(m_camo); + INIT_POOL(m_snd_driver_globals); + INIT_POOL(m_fx); + INIT_POOL(m_fx_impact_table); + INIT_POOL(m_raw_file); + INIT_POOL(m_string_table); + INIT_POOL(m_leaderboard); + INIT_POOL(m_xglobals); + INIT_POOL(m_ddl); + INIT_POOL(m_glasses); + INIT_POOL(m_emblem_set); + INIT_POOL(m_script); + INIT_POOL(m_key_value_pairs); + INIT_POOL(m_vehicle); + INIT_POOL(m_memory_block); + INIT_POOL(m_addon_map_ents); + INIT_POOL(m_tracer); + INIT_POOL(m_skinned_verts); + INIT_POOL(m_qdb); + INIT_POOL(m_slug); + INIT_POOL(m_footstep_table); + INIT_POOL(m_footstep_fx_table); + INIT_POOL(m_zbarrier); -#undef CASE_INIT_POOL_DYNAMIC +#undef INIT_POOL } XAssetInfoGeneric* GameAssetPoolT6::AddAssetToPool(std::unique_ptr xAssetInfo) @@ -227,7 +138,7 @@ XAssetInfoGeneric* GameAssetPoolT6::AddAssetToPool(std::unique_ptrAddAsset(std::unique_ptr>( \ static_cast*>(xAssetInfo.release()))); \ } @@ -299,7 +210,7 @@ XAssetInfoGeneric* GameAssetPoolT6::GetAsset(const asset_type_t type, const std: #define CASE_GET_ASSET(assetType, poolName) \ case assetType: \ { \ - if ((poolName) != nullptr) \ + if (poolName) \ return (poolName)->GetAsset(name); \ break; \ } diff --git a/src/ZoneCommon/Game/T6/GameAssetPoolT6.h b/src/ZoneCommon/Game/T6/GameAssetPoolT6.h index de7f756b..6e10849d 100644 --- a/src/ZoneCommon/Game/T6/GameAssetPoolT6.h +++ b/src/ZoneCommon/Game/T6/GameAssetPoolT6.h @@ -8,14 +8,6 @@ class GameAssetPoolT6 final : public ZoneAssetPools { - int m_priority; - - static constexpr const char* ASSET_TYPE_INVALID = "invalid_asset_type"; - static const char* ASSET_TYPE_NAMES[]; - -protected: - XAssetInfoGeneric* AddAssetToPool(std::unique_ptr xAssetInfo) override; - public: std::unique_ptr> m_phys_preset; std::unique_ptr> m_phys_constraints; @@ -66,17 +58,20 @@ class GameAssetPoolT6 final : public ZoneAssetPools std::unique_ptr> m_footstep_fx_table; std::unique_ptr> m_zbarrier; - GameAssetPoolT6(Zone* zone, int priority); + GameAssetPoolT6(Zone* zone, zone_priority_t priority); ~GameAssetPoolT6() override = default; - void InitPoolStatic(asset_type_t type, size_t capacity) override; - void InitPoolDynamic(asset_type_t type) override; - - _NODISCARD XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override; + [[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override; static std::optional AssetTypeNameByType(asset_type_t assetType); - _NODISCARD std::optional GetAssetTypeName(asset_type_t assetType) const override; + [[nodiscard]] std::optional GetAssetTypeName(asset_type_t assetType) const override; static asset_type_t AssetTypeCount(); - _NODISCARD asset_type_t GetAssetTypeCount() const override; + [[nodiscard]] asset_type_t GetAssetTypeCount() const override; + +protected: + XAssetInfoGeneric* AddAssetToPool(std::unique_ptr xAssetInfo) override; + +private: + zone_priority_t m_priority; }; diff --git a/src/ZoneCommon/Pool/AssetPoolDynamic.h b/src/ZoneCommon/Pool/AssetPoolDynamic.h index 128f2a63..3b9c54ac 100644 --- a/src/ZoneCommon/Pool/AssetPoolDynamic.h +++ b/src/ZoneCommon/Pool/AssetPoolDynamic.h @@ -4,20 +4,18 @@ #include "GlobalAssetPool.h" #include "XAssetInfo.h" -#include +#include template class AssetPoolDynamic final : public AssetPool { using AssetPool::m_asset_lookup; std::vector>> m_assets; - asset_type_t m_type; public: - AssetPoolDynamic(const int priority, const asset_type_t type) + explicit AssetPoolDynamic(const zone_priority_t priority) { GlobalAssetPool::LinkAssetPool(this, priority); - m_type = type; } AssetPoolDynamic(AssetPoolDynamic&) = delete; diff --git a/src/ZoneCommon/Pool/AssetPoolStatic.h b/src/ZoneCommon/Pool/AssetPoolStatic.h deleted file mode 100644 index 0c32bf9d..00000000 --- a/src/ZoneCommon/Pool/AssetPoolStatic.h +++ /dev/null @@ -1,104 +0,0 @@ -#pragma once - -#include "AssetPool.h" -#include "GlobalAssetPool.h" -#include "XAssetInfo.h" - -#include -#include - -template class AssetPoolStatic final : public AssetPool -{ - using AssetPool::m_asset_lookup; - - struct AssetPoolEntry - { - XAssetInfo* m_info; - - union - { - T m_entry; - AssetPoolEntry* m_next; - }; - }; - - AssetPoolEntry* m_free; - AssetPoolEntry* m_pool; - XAssetInfo* m_info_pool; - size_t m_capacity; - asset_type_t m_type; - -public: - AssetPoolStatic(const size_t capacity, const int priority, const asset_type_t type) - { - m_capacity = capacity; - m_type = type; - - if (m_capacity > 0) - { - m_pool = new AssetPoolEntry[m_capacity]; - m_info_pool = new XAssetInfo[m_capacity]; - - for (size_t i = 0; i < m_capacity - 1; i++) - { - m_pool[i].m_info = &m_info_pool[i]; - m_pool[i].m_next = &m_pool[i + 1]; - } - m_pool[m_capacity - 1].m_info = &m_info_pool[m_capacity - 1]; - m_pool[m_capacity - 1].m_next = nullptr; - - m_free = m_pool; - - GlobalAssetPool::LinkAssetPool(this, priority); - } - else - { - m_pool = nullptr; - m_free = nullptr; - m_info_pool = nullptr; - } - } - - AssetPoolStatic(AssetPoolStatic&) = delete; - AssetPoolStatic(AssetPoolStatic&&) = delete; - AssetPoolStatic& operator=(AssetPoolStatic&) = delete; - AssetPoolStatic& operator=(AssetPoolStatic&&) = default; - - ~AssetPoolStatic() override - { - if (m_capacity > 0) - GlobalAssetPool::UnlinkAssetPool(this); - - delete[] m_pool; - m_pool = nullptr; - - delete[] m_info_pool; - m_info_pool = nullptr; - - m_free = nullptr; - m_capacity = 0; - } - - XAssetInfo* AddAsset(std::unique_ptr> xAssetInfo) override - { - if (m_free == nullptr) - throw std::runtime_error("Could not add asset to static asset pool: capacity exhausted."); - - const auto normalizedName = XAssetInfo::NormalizeAssetName(xAssetInfo->m_name); - - AssetPoolEntry* poolSlot = m_free; - m_free = m_free->m_next; - - const T* pAsset = xAssetInfo->Asset(); - xAssetInfo->m_ptr = static_cast(&poolSlot->m_entry); - memcpy(&poolSlot->m_entry, pAsset, sizeof(T)); - - *poolSlot->m_info = std::move(*xAssetInfo); - - m_asset_lookup[normalizedName] = poolSlot->m_info; - - GlobalAssetPool::LinkAsset(this, normalizedName, poolSlot->m_info); - - return poolSlot->m_info; - } -}; diff --git a/src/ZoneCommon/Pool/GlobalAssetPool.h b/src/ZoneCommon/Pool/GlobalAssetPool.h index 2a328456..7fdbdfab 100644 --- a/src/ZoneCommon/Pool/GlobalAssetPool.h +++ b/src/ZoneCommon/Pool/GlobalAssetPool.h @@ -1,6 +1,7 @@ #pragma once #include "AssetPool.h" +#include "Zone/ZoneTypes.h" #include #include @@ -14,7 +15,7 @@ template class GlobalAssetPool struct LinkedAssetPool { AssetPool* m_asset_pool; - int m_priority; + zone_priority_t m_priority; }; struct GameAssetPoolEntry @@ -92,7 +93,7 @@ template class GlobalAssetPool } public: - static void LinkAssetPool(AssetPool* assetPool, const int priority) + static void LinkAssetPool(AssetPool* assetPool, const zone_priority_t priority) { auto newLink = std::make_unique(); newLink->m_asset_pool = assetPool; diff --git a/src/ZoneCommon/Pool/XAssetInfo.cpp b/src/ZoneCommon/Pool/XAssetInfo.cpp index 6448c962..c9d94955 100644 --- a/src/ZoneCommon/Pool/XAssetInfo.cpp +++ b/src/ZoneCommon/Pool/XAssetInfo.cpp @@ -93,6 +93,11 @@ XAssetInfoGeneric::XAssetInfoGeneric(const asset_type_t type, { } +bool XAssetInfoGeneric::IsReference() const +{ + return !m_name.empty() && m_name[0] == ','; +} + std::string XAssetInfoGeneric::NormalizeAssetName(std::string input) { utils::MakeStringLowerCase(input); diff --git a/src/ZoneCommon/Pool/XAssetInfo.h b/src/ZoneCommon/Pool/XAssetInfo.h index fa77ea10..321fb996 100644 --- a/src/ZoneCommon/Pool/XAssetInfo.h +++ b/src/ZoneCommon/Pool/XAssetInfo.h @@ -54,6 +54,8 @@ class XAssetInfoGeneric XAssetInfoGeneric& operator=(const XAssetInfoGeneric& other) = default; XAssetInfoGeneric& operator=(XAssetInfoGeneric&& other) noexcept = default; + [[nodiscard]] bool IsReference() const; + static std::string NormalizeAssetName(std::string input); asset_type_t m_type; diff --git a/src/ZoneCommon/Pool/ZoneAssetPools.h b/src/ZoneCommon/Pool/ZoneAssetPools.h index 5f4b1ecf..97c94ff9 100644 --- a/src/ZoneCommon/Pool/ZoneAssetPools.h +++ b/src/ZoneCommon/Pool/ZoneAssetPools.h @@ -16,12 +16,6 @@ class XAssetInfoGeneric; class ZoneAssetPools { -protected: - Zone* m_zone; - std::vector m_assets_in_order; - - virtual XAssetInfoGeneric* AddAssetToPool(std::unique_ptr xAssetInfo) = 0; - public: using iterator = std::vector::const_iterator; @@ -45,13 +39,16 @@ class ZoneAssetPools _NODISCARD virtual asset_type_t GetAssetTypeCount() const = 0; _NODISCARD virtual std::optional 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; - _NODISCARD size_t GetTotalAssetCount() const; _NODISCARD iterator begin() const; _NODISCARD iterator end() const; static std::unique_ptr CreateForGame(GameId game, Zone* zone, zone_priority_t priority); + +protected: + virtual XAssetInfoGeneric* AddAssetToPool(std::unique_ptr xAssetInfo) = 0; + + Zone* m_zone; + std::vector m_assets_in_order; }; diff --git a/src/ZoneCommon/Zone/Zone.cpp b/src/ZoneCommon/Zone/Zone.cpp index f62e300c..5014120a 100644 --- a/src/ZoneCommon/Zone/Zone.cpp +++ b/src/ZoneCommon/Zone/Zone.cpp @@ -9,9 +9,6 @@ Zone::Zone(std::string name, const zone_priority_t priority, IGame* game) m_game(game), m_pools(ZoneAssetPools::CreateForGame(game->GetId(), this, priority)) { - const auto assetTypeCount = m_pools->GetAssetTypeCount(); - for (auto i = 0; i < assetTypeCount; i++) - m_pools->InitPoolDynamic(i); } Zone::~Zone() diff --git a/src/ZoneLoading/Game/IW3/ContentLoaderIW3.cpp b/src/ZoneLoading/Game/IW3/ContentLoaderIW3.cpp index e6dfea2b..e78039c9 100644 --- a/src/ZoneLoading/Game/IW3/ContentLoaderIW3.cpp +++ b/src/ZoneLoading/Game/IW3/ContentLoaderIW3.cpp @@ -126,11 +126,6 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count if (atStreamStart) m_stream->Load(varXAsset, count); - for (asset_type_t assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++) - { - m_zone->m_pools->InitPoolDynamic(assetType); - } - for (size_t index = 0; index < count; index++) { LoadXAsset(false); diff --git a/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp b/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp index 49eecd4c..6ae4f493 100644 --- a/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp +++ b/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp @@ -146,11 +146,6 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count if (atStreamStart) m_stream->Load(varXAsset, count); - for (asset_type_t assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++) - { - m_zone->m_pools->InitPoolDynamic(assetType); - } - for (size_t index = 0; index < count; index++) { LoadXAsset(false); diff --git a/src/ZoneLoading/Game/IW5/ContentLoaderIW5.cpp b/src/ZoneLoading/Game/IW5/ContentLoaderIW5.cpp index 97dbf4d7..101d259b 100644 --- a/src/ZoneLoading/Game/IW5/ContentLoaderIW5.cpp +++ b/src/ZoneLoading/Game/IW5/ContentLoaderIW5.cpp @@ -155,11 +155,6 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count if (atStreamStart) m_stream->Load(varXAsset, count); - for (asset_type_t assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++) - { - m_zone->m_pools->InitPoolDynamic(assetType); - } - for (size_t index = 0; index < count; index++) { LoadXAsset(false); diff --git a/src/ZoneLoading/Game/T5/ContentLoaderT5.cpp b/src/ZoneLoading/Game/T5/ContentLoaderT5.cpp index 921de0d4..327cdf93 100644 --- a/src/ZoneLoading/Game/T5/ContentLoaderT5.cpp +++ b/src/ZoneLoading/Game/T5/ContentLoaderT5.cpp @@ -139,11 +139,6 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count if (atStreamStart) m_stream->Load(varXAsset, count); - for (asset_type_t assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++) - { - m_zone->m_pools->InitPoolDynamic(assetType); - } - for (size_t index = 0; index < count; index++) { LoadXAsset(false); diff --git a/src/ZoneLoading/Game/T6/ContentLoaderT6.cpp b/src/ZoneLoading/Game/T6/ContentLoaderT6.cpp index 106b8c09..2b54ebc1 100644 --- a/src/ZoneLoading/Game/T6/ContentLoaderT6.cpp +++ b/src/ZoneLoading/Game/T6/ContentLoaderT6.cpp @@ -168,11 +168,6 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count if (atStreamStart) m_stream->Load(varXAsset, count); - for (asset_type_t assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++) - { - m_zone->m_pools->InitPoolDynamic(assetType); - } - for (size_t index = 0; index < count; index++) { LoadXAsset(false);