diff --git a/src/Common/Game/IAsset.h b/src/Common/Game/IAsset.h index d51b2abe..05c66980 100644 --- a/src/Common/Game/IAsset.h +++ b/src/Common/Game/IAsset.h @@ -5,20 +5,39 @@ #include #include -struct IAssetBase -{ -}; - -template class Asset : IAssetBase +template class Asset { public: + static constexpr bool IS_ASSET = true; static constexpr auto EnumEntry = AssetTypeEnum; using Type = AssetType; }; -template struct AssetNameAccessor +template class SubAsset +{ +public: + static constexpr bool IS_ASSET = false; + static constexpr auto EnumEntry = AssetTypeEnum; + using Type = AssetType; +}; + +template +concept HasAssetEnumEntry = std::is_integral_v; + +template +concept HasAssetType = std::is_class_v; + +template +concept AssetOrSubAssetDefinition = HasAssetEnumEntry && HasAssetType; + +template +concept AssetDefinition = AssetOrSubAssetDefinition && T::IS_ASSET; + +template +concept SubAssetDefinition = AssetOrSubAssetDefinition && !T::IS_ASSET; + +template struct AssetNameAccessor { - static_assert(std::is_base_of_v); // static constexpr bool IS_SINGLETON = false; // using RETURN_TYPE = const char*&; @@ -32,7 +51,6 @@ template struct AssetNameAccessor template<> struct AssetNameAccessor \ { \ public: \ - static_assert(std::is_base_of_v); \ static constexpr bool IS_SINGLETON = false; \ using RETURN_TYPE = const char*&; \ \ @@ -46,7 +64,6 @@ template struct AssetNameAccessor template<> struct AssetNameAccessor \ { \ public: \ - static_assert(std::is_base_of_v); \ static constexpr bool IS_SINGLETON = true; \ using RETURN_TYPE = const char* const&; \ \ @@ -57,8 +74,7 @@ template struct AssetNameAccessor } \ } -template AssetNameAccessor::RETURN_TYPE AssetName(typename AssetType::Type& asset) +template AssetNameAccessor::RETURN_TYPE AssetName(typename Asset_t::Type& asset) { - static_assert(std::is_base_of_v); - return AssetNameAccessor::GetAssetName(asset); + return AssetNameAccessor::GetAssetName(asset); } diff --git a/src/Common/Game/IGame.h b/src/Common/Game/IGame.h index 71c27528..f938efa2 100644 --- a/src/Common/Game/IGame.h +++ b/src/Common/Game/IGame.h @@ -69,5 +69,8 @@ public: [[nodiscard]] virtual asset_type_t GetAssetTypeCount() const = 0; [[nodiscard]] virtual std::optional GetAssetTypeName(asset_type_t assetType) const = 0; + [[nodiscard]] virtual asset_type_t GetSubAssetTypeCount() const = 0; + [[nodiscard]] virtual std::optional GetSubAssetTypeName(asset_type_t subAssetType) const = 0; + static IGame* GetGameById(GameId gameId); }; diff --git a/src/Common/Game/IW3/GameIW3.cpp b/src/Common/Game/IW3/GameIW3.cpp index 63d4944b..31007508 100644 --- a/src/Common/Game/IW3/GameIW3.cpp +++ b/src/Common/Game/IW3/GameIW3.cpp @@ -14,6 +14,12 @@ namespace "menulist", "menu", "localize", "weapon", "snddriverglobals", "fx", "impactfx", "aitype", "mptype", "character", "xmodelalias", "rawfile", "stringtable", }; + + constexpr const char* SUB_ASSET_TYPE_NAMES[SUB_ASSET_TYPE_COUNT]{ + "technique", + "vertexshader", + "pixelshader", + }; } // namespace namespace IW3 @@ -53,4 +59,17 @@ namespace IW3 return std::nullopt; } + + asset_type_t Game::GetSubAssetTypeCount() const + { + return SUB_ASSET_TYPE_COUNT; + } + + std::optional Game::GetSubAssetTypeName(const asset_type_t subAssetType) const + { + if (subAssetType < std::extent_v) + return SUB_ASSET_TYPE_NAMES[subAssetType]; + + return std::nullopt; + } } // namespace IW3 diff --git a/src/Common/Game/IW3/GameIW3.h b/src/Common/Game/IW3/GameIW3.h index 852e2049..5e7cd5a3 100644 --- a/src/Common/Game/IW3/GameIW3.h +++ b/src/Common/Game/IW3/GameIW3.h @@ -14,5 +14,7 @@ namespace IW3 [[nodiscard]] asset_type_t GetAssetTypeCount() const override; [[nodiscard]] std::optional GetAssetTypeName(asset_type_t assetType) const override; + [[nodiscard]] asset_type_t GetSubAssetTypeCount() const override; + [[nodiscard]] std::optional GetSubAssetTypeName(asset_type_t subAssetType) const override; }; } // namespace IW3 diff --git a/src/Common/Game/IW3/IW3.h b/src/Common/Game/IW3/IW3.h index a39ad3db..ee7d6856 100644 --- a/src/Common/Game/IW3/IW3.h +++ b/src/Common/Game/IW3/IW3.h @@ -11,6 +11,53 @@ namespace IW3 { + enum XAssetType + { + ASSET_TYPE_XMODELPIECES, + ASSET_TYPE_PHYSPRESET, + ASSET_TYPE_XANIMPARTS, + ASSET_TYPE_XMODEL, + ASSET_TYPE_MATERIAL, + ASSET_TYPE_TECHNIQUE_SET, + ASSET_TYPE_IMAGE, + ASSET_TYPE_SOUND, + ASSET_TYPE_SOUND_CURVE, + ASSET_TYPE_LOADED_SOUND, + ASSET_TYPE_CLIPMAP, + ASSET_TYPE_CLIPMAP_PVS, + ASSET_TYPE_COMWORLD, + ASSET_TYPE_GAMEWORLD_SP, + ASSET_TYPE_GAMEWORLD_MP, + ASSET_TYPE_MAP_ENTS, + ASSET_TYPE_GFXWORLD, + ASSET_TYPE_LIGHT_DEF, + ASSET_TYPE_UI_MAP, + ASSET_TYPE_FONT, + ASSET_TYPE_MENULIST, + ASSET_TYPE_MENU, + ASSET_TYPE_LOCALIZE_ENTRY, + ASSET_TYPE_WEAPON, + ASSET_TYPE_SNDDRIVER_GLOBALS, + ASSET_TYPE_FX, + ASSET_TYPE_IMPACT_FX, + ASSET_TYPE_AITYPE, + ASSET_TYPE_MPTYPE, + ASSET_TYPE_CHARACTER, + ASSET_TYPE_XMODELALIAS, + ASSET_TYPE_RAWFILE, + ASSET_TYPE_STRINGTABLE, + + ASSET_TYPE_COUNT + }; + + enum SubAssetType + { + SUB_ASSET_TYPE_TECHNIQUE, + SUB_ASSET_TYPE_VERTEX_SHADER, + SUB_ASSET_TYPE_PIXEL_SHADER, + + SUB_ASSET_TYPE_COUNT + }; struct DB_AuthHash { diff --git a/src/Common/Game/IW3/IW3_Assets.h b/src/Common/Game/IW3/IW3_Assets.h index e9bcb463..8f3c0e01 100644 --- a/src/Common/Game/IW3/IW3_Assets.h +++ b/src/Common/Game/IW3/IW3_Assets.h @@ -9,49 +9,6 @@ namespace IW3 { #endif - enum XAssetType - { - ASSET_TYPE_XMODELPIECES = 0x0, - ASSET_TYPE_PHYSPRESET = 0x1, - ASSET_TYPE_XANIMPARTS = 0x2, - ASSET_TYPE_XMODEL = 0x3, - ASSET_TYPE_MATERIAL = 0x4, - ASSET_TYPE_TECHNIQUE_SET = 0x5, - ASSET_TYPE_IMAGE = 0x6, - ASSET_TYPE_SOUND = 0x7, - ASSET_TYPE_SOUND_CURVE = 0x8, - ASSET_TYPE_LOADED_SOUND = 0x9, - ASSET_TYPE_CLIPMAP = 0xA, - ASSET_TYPE_CLIPMAP_PVS = 0xB, - ASSET_TYPE_COMWORLD = 0xC, - ASSET_TYPE_GAMEWORLD_SP = 0xD, - ASSET_TYPE_GAMEWORLD_MP = 0xE, - ASSET_TYPE_MAP_ENTS = 0xF, - ASSET_TYPE_GFXWORLD = 0x10, - ASSET_TYPE_LIGHT_DEF = 0x11, - ASSET_TYPE_UI_MAP = 0x12, - ASSET_TYPE_FONT = 0x13, - ASSET_TYPE_MENULIST = 0x14, - ASSET_TYPE_MENU = 0x15, - ASSET_TYPE_LOCALIZE_ENTRY = 0x16, - ASSET_TYPE_WEAPON = 0x17, - ASSET_TYPE_SNDDRIVER_GLOBALS = 0x18, - ASSET_TYPE_FX = 0x19, - ASSET_TYPE_IMPACT_FX = 0x1A, - ASSET_TYPE_AITYPE = 0x1B, - ASSET_TYPE_MPTYPE = 0x1C, - ASSET_TYPE_CHARACTER = 0x1D, - ASSET_TYPE_XMODELALIAS = 0x1E, - ASSET_TYPE_RAWFILE = 0x1F, - ASSET_TYPE_STRINGTABLE = 0x20, - ASSET_TYPE_COUNT, - - ASSET_TYPE_STRING = ASSET_TYPE_COUNT, - ASSET_TYPE_ASSETLIST, - - ASSET_TYPE_FULLCOUNT - }; - enum XFileBlock { XFILE_BLOCK_TEMP, diff --git a/src/Common/Game/IW4/GameIW4.cpp b/src/Common/Game/IW4/GameIW4.cpp index ec81db3d..a3ca8860 100644 --- a/src/Common/Game/IW4/GameIW4.cpp +++ b/src/Common/Game/IW4/GameIW4.cpp @@ -19,6 +19,10 @@ namespace "xmodelalias", "rawfile", "stringtable", "leaderboard", "structureddatadef", "tracer", "vehicle", "addonmapents", }; + + constexpr const char* SUB_ASSET_TYPE_NAMES[SUB_ASSET_TYPE_COUNT]{ + "technique", + }; } // namespace namespace IW4 @@ -58,4 +62,17 @@ namespace IW4 return std::nullopt; } + + asset_type_t Game::GetSubAssetTypeCount() const + { + return SUB_ASSET_TYPE_COUNT; + } + + std::optional Game::GetSubAssetTypeName(const asset_type_t subAssetType) const + { + if (subAssetType < std::extent_v) + return SUB_ASSET_TYPE_NAMES[subAssetType]; + + return std::nullopt; + } } // namespace IW4 diff --git a/src/Common/Game/IW4/GameIW4.h b/src/Common/Game/IW4/GameIW4.h index bd63bd67..5a2a269c 100644 --- a/src/Common/Game/IW4/GameIW4.h +++ b/src/Common/Game/IW4/GameIW4.h @@ -13,5 +13,7 @@ namespace IW4 [[nodiscard]] asset_type_t GetAssetTypeCount() const override; [[nodiscard]] std::optional GetAssetTypeName(asset_type_t assetType) const override; + [[nodiscard]] asset_type_t GetSubAssetTypeCount() const override; + [[nodiscard]] std::optional GetSubAssetTypeName(asset_type_t subAssetType) const override; }; } // namespace IW4 diff --git a/src/Common/Game/IW4/IW4.h b/src/Common/Game/IW4/IW4.h index fe9c7e03..ac7400b2 100644 --- a/src/Common/Game/IW4/IW4.h +++ b/src/Common/Game/IW4/IW4.h @@ -11,6 +11,62 @@ namespace IW4 { + enum XAssetType + { + ASSET_TYPE_PHYSPRESET, + ASSET_TYPE_PHYSCOLLMAP, + ASSET_TYPE_XANIMPARTS, + ASSET_TYPE_XMODEL_SURFS, + ASSET_TYPE_XMODEL, + ASSET_TYPE_MATERIAL, + ASSET_TYPE_PIXELSHADER, + ASSET_TYPE_VERTEXSHADER, + ASSET_TYPE_VERTEXDECL, + ASSET_TYPE_TECHNIQUE_SET, + ASSET_TYPE_IMAGE, + ASSET_TYPE_SOUND, + ASSET_TYPE_SOUND_CURVE, + ASSET_TYPE_LOADED_SOUND, + ASSET_TYPE_CLIPMAP_SP, + ASSET_TYPE_CLIPMAP_MP, + ASSET_TYPE_COMWORLD, + ASSET_TYPE_GAMEWORLD_SP, + ASSET_TYPE_GAMEWORLD_MP, + ASSET_TYPE_MAP_ENTS, + ASSET_TYPE_FXWORLD, + ASSET_TYPE_GFXWORLD, + ASSET_TYPE_LIGHT_DEF, + ASSET_TYPE_UI_MAP, + ASSET_TYPE_FONT, + ASSET_TYPE_MENULIST, + ASSET_TYPE_MENU, + ASSET_TYPE_LOCALIZE_ENTRY, + ASSET_TYPE_WEAPON, + ASSET_TYPE_SNDDRIVER_GLOBALS, + ASSET_TYPE_FX, + ASSET_TYPE_IMPACT_FX, + ASSET_TYPE_AITYPE, + ASSET_TYPE_MPTYPE, + ASSET_TYPE_CHARACTER, + ASSET_TYPE_XMODELALIAS, + ASSET_TYPE_RAWFILE, + ASSET_TYPE_STRINGTABLE, + ASSET_TYPE_LEADERBOARD, + ASSET_TYPE_STRUCTURED_DATA_DEF, + ASSET_TYPE_TRACER, + ASSET_TYPE_VEHICLE, + ASSET_TYPE_ADDON_MAP_ENTS, + + ASSET_TYPE_COUNT + }; + + enum SubAssetType + { + SUB_ASSET_TYPE_TECHNIQUE, + + SUB_ASSET_TYPE_COUNT + }; + struct DB_AuthHash { char bytes[32]; diff --git a/src/Common/Game/IW4/IW4_Assets.h b/src/Common/Game/IW4/IW4_Assets.h index 1e3437e1..2407a5b0 100644 --- a/src/Common/Game/IW4/IW4_Assets.h +++ b/src/Common/Game/IW4/IW4_Assets.h @@ -9,59 +9,6 @@ namespace IW4 { #endif - enum XAssetType - { - ASSET_TYPE_PHYSPRESET = 0x0, - ASSET_TYPE_PHYSCOLLMAP = 0x1, - ASSET_TYPE_XANIMPARTS = 0x2, - ASSET_TYPE_XMODEL_SURFS = 0x3, - ASSET_TYPE_XMODEL = 0x4, - ASSET_TYPE_MATERIAL = 0x5, - ASSET_TYPE_PIXELSHADER = 0x6, - ASSET_TYPE_VERTEXSHADER = 0x7, - ASSET_TYPE_VERTEXDECL = 0x8, - ASSET_TYPE_TECHNIQUE_SET = 0x9, - ASSET_TYPE_IMAGE = 0xA, - ASSET_TYPE_SOUND = 0xB, - ASSET_TYPE_SOUND_CURVE = 0xC, - ASSET_TYPE_LOADED_SOUND = 0xD, - ASSET_TYPE_CLIPMAP_SP = 0xE, - ASSET_TYPE_CLIPMAP_MP = 0xF, - ASSET_TYPE_COMWORLD = 0x10, - ASSET_TYPE_GAMEWORLD_SP = 0x11, - ASSET_TYPE_GAMEWORLD_MP = 0x12, - ASSET_TYPE_MAP_ENTS = 0x13, - ASSET_TYPE_FXWORLD = 0x14, - ASSET_TYPE_GFXWORLD = 0x15, - ASSET_TYPE_LIGHT_DEF = 0x16, - ASSET_TYPE_UI_MAP = 0x17, - ASSET_TYPE_FONT = 0x18, - ASSET_TYPE_MENULIST = 0x19, - ASSET_TYPE_MENU = 0x1A, - ASSET_TYPE_LOCALIZE_ENTRY = 0x1B, - ASSET_TYPE_WEAPON = 0x1C, - ASSET_TYPE_SNDDRIVER_GLOBALS = 0x1D, - ASSET_TYPE_FX = 0x1E, - ASSET_TYPE_IMPACT_FX = 0x1F, - ASSET_TYPE_AITYPE = 0x20, - ASSET_TYPE_MPTYPE = 0x21, - ASSET_TYPE_CHARACTER = 0x22, - ASSET_TYPE_XMODELALIAS = 0x23, - ASSET_TYPE_RAWFILE = 0x24, - ASSET_TYPE_STRINGTABLE = 0x25, - ASSET_TYPE_LEADERBOARD = 0x26, - ASSET_TYPE_STRUCTURED_DATA_DEF = 0x27, - ASSET_TYPE_TRACER = 0x28, - ASSET_TYPE_VEHICLE = 0x29, - ASSET_TYPE_ADDON_MAP_ENTS = 0x2A, - - ASSET_TYPE_COUNT, - ASSET_TYPE_STRING = ASSET_TYPE_COUNT, - ASSET_TYPE_ASSETLIST = 0x2C, - - ASSET_TYPE_FULLCOUNT - }; - enum XFileBlock { XFILE_BLOCK_TEMP, diff --git a/src/Common/Game/IW5/GameIW5.cpp b/src/Common/Game/IW5/GameIW5.cpp index 1a863bb1..f7dafcea 100644 --- a/src/Common/Game/IW5/GameIW5.cpp +++ b/src/Common/Game/IW5/GameIW5.cpp @@ -56,6 +56,10 @@ namespace "vehicle", "addonmapents", }; + + constexpr const char* SUB_ASSET_TYPE_NAMES[SUB_ASSET_TYPE_COUNT]{ + "technique", + }; } // namespace namespace IW5 @@ -95,4 +99,17 @@ namespace IW5 return std::nullopt; } + + asset_type_t Game::GetSubAssetTypeCount() const + { + return SUB_ASSET_TYPE_COUNT; + } + + std::optional Game::GetSubAssetTypeName(const asset_type_t subAssetType) const + { + if (subAssetType < std::extent_v) + return SUB_ASSET_TYPE_NAMES[subAssetType]; + + return std::nullopt; + } } // namespace IW5 diff --git a/src/Common/Game/IW5/GameIW5.h b/src/Common/Game/IW5/GameIW5.h index bec5019e..b6f67c04 100644 --- a/src/Common/Game/IW5/GameIW5.h +++ b/src/Common/Game/IW5/GameIW5.h @@ -13,5 +13,7 @@ namespace IW5 [[nodiscard]] asset_type_t GetAssetTypeCount() const override; [[nodiscard]] std::optional GetAssetTypeName(asset_type_t assetType) const override; + [[nodiscard]] asset_type_t GetSubAssetTypeCount() const override; + [[nodiscard]] std::optional GetSubAssetTypeName(asset_type_t subAssetType) const override; }; } // namespace IW5 diff --git a/src/Common/Game/IW5/IW5.h b/src/Common/Game/IW5/IW5.h index c2018a64..548842cc 100644 --- a/src/Common/Game/IW5/IW5.h +++ b/src/Common/Game/IW5/IW5.h @@ -11,6 +11,65 @@ namespace IW5 { + enum XAssetType + { + ASSET_TYPE_PHYSPRESET, + ASSET_TYPE_PHYSCOLLMAP, + ASSET_TYPE_XANIMPARTS, + ASSET_TYPE_XMODEL_SURFS, + ASSET_TYPE_XMODEL, + ASSET_TYPE_MATERIAL, + ASSET_TYPE_PIXELSHADER, + ASSET_TYPE_VERTEXSHADER, + ASSET_TYPE_VERTEXDECL, + ASSET_TYPE_TECHNIQUE_SET, + ASSET_TYPE_IMAGE, + ASSET_TYPE_SOUND, + ASSET_TYPE_SOUND_CURVE, + ASSET_TYPE_LOADED_SOUND, + ASSET_TYPE_CLIPMAP, + ASSET_TYPE_COMWORLD, + ASSET_TYPE_GLASSWORLD, + ASSET_TYPE_PATHDATA, + ASSET_TYPE_VEHICLE_TRACK, + ASSET_TYPE_MAP_ENTS, + ASSET_TYPE_FXWORLD, + ASSET_TYPE_GFXWORLD, + ASSET_TYPE_LIGHT_DEF, + ASSET_TYPE_UI_MAP, + ASSET_TYPE_FONT, + ASSET_TYPE_MENULIST, + ASSET_TYPE_MENU, + ASSET_TYPE_LOCALIZE_ENTRY, + ASSET_TYPE_ATTACHMENT, + ASSET_TYPE_WEAPON, + ASSET_TYPE_SNDDRIVER_GLOBALS, + ASSET_TYPE_FX, + ASSET_TYPE_IMPACT_FX, + ASSET_TYPE_SURFACE_FX, + ASSET_TYPE_AITYPE, + ASSET_TYPE_MPTYPE, + ASSET_TYPE_CHARACTER, + ASSET_TYPE_XMODELALIAS, + ASSET_TYPE_RAWFILE, + ASSET_TYPE_SCRIPTFILE, + ASSET_TYPE_STRINGTABLE, + ASSET_TYPE_LEADERBOARD, + ASSET_TYPE_STRUCTURED_DATA_DEF, + ASSET_TYPE_TRACER, + ASSET_TYPE_VEHICLE, + ASSET_TYPE_ADDON_MAP_ENTS, + + ASSET_TYPE_COUNT + }; + + enum SubAssetType + { + SUB_ASSET_TYPE_TECHNIQUE, + + SUB_ASSET_TYPE_COUNT + }; + struct DB_AuthHash { char bytes[32]; diff --git a/src/Common/Game/IW5/IW5_Assets.h b/src/Common/Game/IW5/IW5_Assets.h index 4613e8b0..01f7aab2 100644 --- a/src/Common/Game/IW5/IW5_Assets.h +++ b/src/Common/Game/IW5/IW5_Assets.h @@ -17,62 +17,6 @@ namespace IW5 { #endif #endif - enum XAssetType - { - ASSET_TYPE_PHYSPRESET = 0x0, - ASSET_TYPE_PHYSCOLLMAP = 0x1, - ASSET_TYPE_XANIMPARTS = 0x2, - ASSET_TYPE_XMODEL_SURFS = 0x3, - ASSET_TYPE_XMODEL = 0x4, - ASSET_TYPE_MATERIAL = 0x5, - ASSET_TYPE_PIXELSHADER = 0x6, - ASSET_TYPE_VERTEXSHADER = 0x7, - ASSET_TYPE_VERTEXDECL = 0x8, - ASSET_TYPE_TECHNIQUE_SET = 0x9, - ASSET_TYPE_IMAGE = 0xA, - ASSET_TYPE_SOUND = 0xB, - ASSET_TYPE_SOUND_CURVE = 0xC, - ASSET_TYPE_LOADED_SOUND = 0xD, - ASSET_TYPE_CLIPMAP = 0xE, - ASSET_TYPE_COMWORLD = 0xF, - ASSET_TYPE_GLASSWORLD = 0x10, - ASSET_TYPE_PATHDATA = 0x11, - ASSET_TYPE_VEHICLE_TRACK = 0x12, - ASSET_TYPE_MAP_ENTS = 0x13, - ASSET_TYPE_FXWORLD = 0x14, - ASSET_TYPE_GFXWORLD = 0x15, - ASSET_TYPE_LIGHT_DEF = 0x16, - ASSET_TYPE_UI_MAP = 0x17, - ASSET_TYPE_FONT = 0x18, - ASSET_TYPE_MENULIST = 0x19, - ASSET_TYPE_MENU = 0x1A, - ASSET_TYPE_LOCALIZE_ENTRY = 0x1B, - ASSET_TYPE_ATTACHMENT = 0x1C, - ASSET_TYPE_WEAPON = 0x1D, - ASSET_TYPE_SNDDRIVER_GLOBALS = 0x1E, - ASSET_TYPE_FX = 0x1F, - ASSET_TYPE_IMPACT_FX = 0x20, - ASSET_TYPE_SURFACE_FX = 0x21, - ASSET_TYPE_AITYPE = 0x22, - ASSET_TYPE_MPTYPE = 0x23, - ASSET_TYPE_CHARACTER = 0x24, - ASSET_TYPE_XMODELALIAS = 0x25, - ASSET_TYPE_RAWFILE = 0x26, - ASSET_TYPE_SCRIPTFILE = 0x27, - ASSET_TYPE_STRINGTABLE = 0x28, - ASSET_TYPE_LEADERBOARD = 0x29, - ASSET_TYPE_STRUCTURED_DATA_DEF = 0x2A, - ASSET_TYPE_TRACER = 0x2B, - ASSET_TYPE_VEHICLE = 0x2C, - ASSET_TYPE_ADDON_MAP_ENTS = 0x2D, - ASSET_TYPE_COUNT, - - ASSET_TYPE_STRING = ASSET_TYPE_COUNT, - ASSET_TYPE_ASSETLIST = 0x2F, - - ASSET_TYPE_FULLCOUNT - }; - enum XFileBlock { XFILE_BLOCK_TEMP, diff --git a/src/Common/Game/T5/GameT5.cpp b/src/Common/Game/T5/GameT5.cpp index cf41a117..d72c81bf 100644 --- a/src/Common/Game/T5/GameT5.cpp +++ b/src/Common/Game/T5/GameT5.cpp @@ -17,6 +17,12 @@ namespace "xmodelalias", "rawfile", "stringtable", "packindex", "xglobals", "ddl", "glasses", "emblemset", }; + + constexpr const char* SUB_ASSET_TYPE_NAMES[SUB_ASSET_TYPE_COUNT]{ + "technique", + "vertexshader", + "pixelshader", + }; } // namespace namespace T5 @@ -71,4 +77,17 @@ namespace T5 return std::nullopt; } + + asset_type_t Game::GetSubAssetTypeCount() const + { + return SUB_ASSET_TYPE_COUNT; + } + + std::optional Game::GetSubAssetTypeName(const asset_type_t subAssetType) const + { + if (subAssetType < std::extent_v) + return SUB_ASSET_TYPE_NAMES[subAssetType]; + + return std::nullopt; + } } // namespace T5 diff --git a/src/Common/Game/T5/GameT5.h b/src/Common/Game/T5/GameT5.h index fdc8334b..0a86bc70 100644 --- a/src/Common/Game/T5/GameT5.h +++ b/src/Common/Game/T5/GameT5.h @@ -13,5 +13,7 @@ namespace T5 [[nodiscard]] asset_type_t GetAssetTypeCount() const override; [[nodiscard]] std::optional GetAssetTypeName(asset_type_t assetType) const override; + [[nodiscard]] asset_type_t GetSubAssetTypeCount() const override; + [[nodiscard]] std::optional GetSubAssetTypeName(asset_type_t subAssetType) const override; }; } // namespace T5 diff --git a/src/Common/Game/T5/T5.h b/src/Common/Game/T5/T5.h index 2683e62f..89ebd8e7 100644 --- a/src/Common/Game/T5/T5.h +++ b/src/Common/Game/T5/T5.h @@ -11,6 +11,64 @@ namespace T5 { + enum XAssetType + { + ASSET_TYPE_XMODELPIECES, + ASSET_TYPE_PHYSPRESET, + ASSET_TYPE_PHYSCONSTRAINTS, + ASSET_TYPE_DESTRUCTIBLEDEF, + ASSET_TYPE_XANIMPARTS, + ASSET_TYPE_XMODEL, + ASSET_TYPE_MATERIAL, + ASSET_TYPE_TECHNIQUE_SET, + ASSET_TYPE_IMAGE, + ASSET_TYPE_SOUND, + ASSET_TYPE_SOUND_PATCH, + ASSET_TYPE_CLIPMAP, + ASSET_TYPE_CLIPMAP_PVS, + ASSET_TYPE_COMWORLD, + ASSET_TYPE_GAMEWORLD_SP, + ASSET_TYPE_GAMEWORLD_MP, + ASSET_TYPE_MAP_ENTS, + ASSET_TYPE_GFXWORLD, + ASSET_TYPE_LIGHT_DEF, + ASSET_TYPE_UI_MAP, + ASSET_TYPE_FONT, + ASSET_TYPE_MENULIST, + ASSET_TYPE_MENU, + ASSET_TYPE_LOCALIZE_ENTRY, + ASSET_TYPE_WEAPON, + ASSET_TYPE_WEAPONDEF, + ASSET_TYPE_WEAPON_VARIANT, + ASSET_TYPE_SNDDRIVER_GLOBALS, + ASSET_TYPE_FX, + ASSET_TYPE_IMPACT_FX, + ASSET_TYPE_AITYPE, + ASSET_TYPE_MPTYPE, + ASSET_TYPE_MPBODY, + ASSET_TYPE_MPHEAD, + ASSET_TYPE_CHARACTER, + ASSET_TYPE_XMODELALIAS, + ASSET_TYPE_RAWFILE, + ASSET_TYPE_STRINGTABLE, + ASSET_TYPE_PACK_INDEX, + ASSET_TYPE_XGLOBALS, + ASSET_TYPE_DDL, + ASSET_TYPE_GLASSES, + ASSET_TYPE_EMBLEMSET, + + ASSET_TYPE_COUNT + }; + + enum SubAssetType + { + SUB_ASSET_TYPE_TECHNIQUE = ASSET_TYPE_COUNT, + SUB_ASSET_TYPE_VERTEX_SHADER, + SUB_ASSET_TYPE_PIXEL_SHADER, + + SUB_ASSET_TYPE_COUNT + }; + struct ScriptStringList { int count; diff --git a/src/Common/Game/T5/T5_Assets.h b/src/Common/Game/T5/T5_Assets.h index db716247..c8e2cc5c 100644 --- a/src/Common/Game/T5/T5_Assets.h +++ b/src/Common/Game/T5/T5_Assets.h @@ -43,58 +43,6 @@ namespace T5 struct Glasses; struct EmblemSet; - enum XAssetType - { - ASSET_TYPE_XMODELPIECES = 0x0, - ASSET_TYPE_PHYSPRESET = 0x1, - ASSET_TYPE_PHYSCONSTRAINTS = 0x2, - ASSET_TYPE_DESTRUCTIBLEDEF = 0x3, - ASSET_TYPE_XANIMPARTS = 0x4, - ASSET_TYPE_XMODEL = 0x5, - ASSET_TYPE_MATERIAL = 0x6, - ASSET_TYPE_TECHNIQUE_SET = 0x7, - ASSET_TYPE_IMAGE = 0x8, - ASSET_TYPE_SOUND = 0x9, - ASSET_TYPE_SOUND_PATCH = 0xA, - ASSET_TYPE_CLIPMAP = 0xB, - ASSET_TYPE_CLIPMAP_PVS = 0xC, - ASSET_TYPE_COMWORLD = 0xD, - ASSET_TYPE_GAMEWORLD_SP = 0xE, - ASSET_TYPE_GAMEWORLD_MP = 0xF, - ASSET_TYPE_MAP_ENTS = 0x10, - ASSET_TYPE_GFXWORLD = 0x11, - ASSET_TYPE_LIGHT_DEF = 0x12, - ASSET_TYPE_UI_MAP = 0x13, - ASSET_TYPE_FONT = 0x14, - ASSET_TYPE_MENULIST = 0x15, - ASSET_TYPE_MENU = 0x16, - ASSET_TYPE_LOCALIZE_ENTRY = 0x17, - ASSET_TYPE_WEAPON = 0x18, - ASSET_TYPE_WEAPONDEF = 0x19, - ASSET_TYPE_WEAPON_VARIANT = 0x1A, - ASSET_TYPE_SNDDRIVER_GLOBALS = 0x1B, - ASSET_TYPE_FX = 0x1C, - ASSET_TYPE_IMPACT_FX = 0x1D, - ASSET_TYPE_AITYPE = 0x1E, - ASSET_TYPE_MPTYPE = 0x1F, - ASSET_TYPE_MPBODY = 0x20, - ASSET_TYPE_MPHEAD = 0x21, - ASSET_TYPE_CHARACTER = 0x22, - ASSET_TYPE_XMODELALIAS = 0x23, - ASSET_TYPE_RAWFILE = 0x24, - ASSET_TYPE_STRINGTABLE = 0x25, - ASSET_TYPE_PACK_INDEX = 0x26, - ASSET_TYPE_XGLOBALS = 0x27, - ASSET_TYPE_DDL = 0x28, - ASSET_TYPE_GLASSES = 0x29, - ASSET_TYPE_EMBLEMSET = 0x2A, - ASSET_TYPE_COUNT = 0x2B, - ASSET_TYPE_STRING = 0x2B, - ASSET_TYPE_ASSETLIST = 0x2C, - - ASSET_TYPE_FULL_COUNT - }; - enum XFileBlock { XFILE_BLOCK_TEMP, diff --git a/src/Common/Game/T6/GameT6.cpp b/src/Common/Game/T6/GameT6.cpp index 3a38a387..8ef710f9 100644 --- a/src/Common/Game/T6/GameT6.cpp +++ b/src/Common/Game/T6/GameT6.cpp @@ -70,6 +70,12 @@ namespace "footstepfxtable", "zbarrier", }; + + constexpr const char* SUB_ASSET_TYPE_NAMES[SUB_ASSET_TYPE_COUNT]{ + "technique", + "vertexshader", + "pixelshader", + }; } // namespace namespace T6 @@ -127,4 +133,17 @@ namespace T6 return std::nullopt; } + + asset_type_t Game::GetSubAssetTypeCount() const + { + return SUB_ASSET_TYPE_COUNT; + } + + std::optional Game::GetSubAssetTypeName(const asset_type_t subAssetType) const + { + if (subAssetType < std::extent_v) + return SUB_ASSET_TYPE_NAMES[subAssetType]; + + return std::nullopt; + } } // namespace T6 diff --git a/src/Common/Game/T6/GameT6.h b/src/Common/Game/T6/GameT6.h index 060b50be..b8debcbf 100644 --- a/src/Common/Game/T6/GameT6.h +++ b/src/Common/Game/T6/GameT6.h @@ -13,5 +13,7 @@ namespace T6 [[nodiscard]] asset_type_t GetAssetTypeCount() const override; [[nodiscard]] std::optional GetAssetTypeName(asset_type_t assetType) const override; + [[nodiscard]] asset_type_t GetSubAssetTypeCount() const override; + [[nodiscard]] std::optional GetSubAssetTypeName(asset_type_t subAssetType) const override; }; } // namespace T6 diff --git a/src/Common/Game/T6/T6.h b/src/Common/Game/T6/T6.h index 72cd851b..f3b052f1 100644 --- a/src/Common/Game/T6/T6.h +++ b/src/Common/Game/T6/T6.h @@ -9,8 +9,86 @@ // clang-format on +#include +#include + namespace T6 { + enum XAssetType + { + ASSET_TYPE_XMODELPIECES, + ASSET_TYPE_PHYSPRESET, + ASSET_TYPE_PHYSCONSTRAINTS, + ASSET_TYPE_DESTRUCTIBLEDEF, + ASSET_TYPE_XANIMPARTS, + ASSET_TYPE_XMODEL, + ASSET_TYPE_MATERIAL, + ASSET_TYPE_TECHNIQUE_SET, + ASSET_TYPE_IMAGE, + ASSET_TYPE_SOUND, + ASSET_TYPE_SOUND_PATCH, + ASSET_TYPE_CLIPMAP, + ASSET_TYPE_CLIPMAP_PVS, + ASSET_TYPE_COMWORLD, + ASSET_TYPE_GAMEWORLD_SP, + ASSET_TYPE_GAMEWORLD_MP, + ASSET_TYPE_MAP_ENTS, + ASSET_TYPE_GFXWORLD, + ASSET_TYPE_LIGHT_DEF, + ASSET_TYPE_UI_MAP, + ASSET_TYPE_FONT, + ASSET_TYPE_FONTICON, + ASSET_TYPE_MENULIST, + ASSET_TYPE_MENU, + ASSET_TYPE_LOCALIZE_ENTRY, + ASSET_TYPE_WEAPON, + ASSET_TYPE_WEAPONDEF, + ASSET_TYPE_WEAPON_VARIANT, + ASSET_TYPE_WEAPON_FULL, + ASSET_TYPE_ATTACHMENT, + ASSET_TYPE_ATTACHMENT_UNIQUE, + ASSET_TYPE_WEAPON_CAMO, + ASSET_TYPE_SNDDRIVER_GLOBALS, + ASSET_TYPE_FX, + ASSET_TYPE_IMPACT_FX, + ASSET_TYPE_AITYPE, + ASSET_TYPE_MPTYPE, + ASSET_TYPE_MPBODY, + ASSET_TYPE_MPHEAD, + ASSET_TYPE_CHARACTER, + ASSET_TYPE_XMODELALIAS, + ASSET_TYPE_RAWFILE, + ASSET_TYPE_STRINGTABLE, + ASSET_TYPE_LEADERBOARD, + ASSET_TYPE_XGLOBALS, + ASSET_TYPE_DDL, + ASSET_TYPE_GLASSES, + ASSET_TYPE_EMBLEMSET, + ASSET_TYPE_SCRIPTPARSETREE, + ASSET_TYPE_KEYVALUEPAIRS, + ASSET_TYPE_VEHICLEDEF, + ASSET_TYPE_MEMORYBLOCK, + ASSET_TYPE_ADDON_MAP_ENTS, + ASSET_TYPE_TRACER, + ASSET_TYPE_SKINNEDVERTS, + ASSET_TYPE_QDB, + ASSET_TYPE_SLUG, + ASSET_TYPE_FOOTSTEP_TABLE, + ASSET_TYPE_FOOTSTEPFX_TABLE, + ASSET_TYPE_ZBARRIER, + + ASSET_TYPE_COUNT + }; + + enum SubAssetType + { + SUB_ASSET_TYPE_TECHNIQUE, + SUB_ASSET_TYPE_VERTEX_SHADER, + SUB_ASSET_TYPE_PIXEL_SHADER, + + SUB_ASSET_TYPE_COUNT + }; + struct ScriptStringList { int count; @@ -208,6 +286,10 @@ namespace T6 using AssetFootstepTable = Asset; using AssetFootstepFxTable = Asset; using AssetZBarrier = Asset; + + using SubAssetTechnique = SubAsset; + using SubAssetVertexShader = SubAsset; + using SubAssetPixelShader = SubAsset; } // namespace T6 DEFINE_ASSET_NAME_ACCESSOR(T6::AssetPhysPreset, name); diff --git a/src/Common/Game/T6/T6_Assets.h b/src/Common/Game/T6/T6_Assets.h index 9b0a102d..22525cfc 100644 --- a/src/Common/Game/T6/T6_Assets.h +++ b/src/Common/Game/T6/T6_Assets.h @@ -236,76 +236,6 @@ namespace T6 struct FootstepTableDef; struct FootstepFXTableDef; - enum XAssetType - { - ASSET_TYPE_XMODELPIECES = 0x0, - ASSET_TYPE_PHYSPRESET = 0x1, - ASSET_TYPE_PHYSCONSTRAINTS = 0x2, - ASSET_TYPE_DESTRUCTIBLEDEF = 0x3, - ASSET_TYPE_XANIMPARTS = 0x4, - ASSET_TYPE_XMODEL = 0x5, - ASSET_TYPE_MATERIAL = 0x6, - ASSET_TYPE_TECHNIQUE_SET = 0x7, - ASSET_TYPE_IMAGE = 0x8, - ASSET_TYPE_SOUND = 0x9, - ASSET_TYPE_SOUND_PATCH = 0xA, - ASSET_TYPE_CLIPMAP = 0xB, - ASSET_TYPE_CLIPMAP_PVS = 0xC, - ASSET_TYPE_COMWORLD = 0xD, - ASSET_TYPE_GAMEWORLD_SP = 0xE, - ASSET_TYPE_GAMEWORLD_MP = 0xF, - ASSET_TYPE_MAP_ENTS = 0x10, - ASSET_TYPE_GFXWORLD = 0x11, - ASSET_TYPE_LIGHT_DEF = 0x12, - ASSET_TYPE_UI_MAP = 0x13, - ASSET_TYPE_FONT = 0x14, - ASSET_TYPE_FONTICON = 0x15, - ASSET_TYPE_MENULIST = 0x16, - ASSET_TYPE_MENU = 0x17, - ASSET_TYPE_LOCALIZE_ENTRY = 0x18, - ASSET_TYPE_WEAPON = 0x19, - ASSET_TYPE_WEAPONDEF = 0x1A, - ASSET_TYPE_WEAPON_VARIANT = 0x1B, - ASSET_TYPE_WEAPON_FULL = 0x1C, - ASSET_TYPE_ATTACHMENT = 0x1D, - ASSET_TYPE_ATTACHMENT_UNIQUE = 0x1E, - ASSET_TYPE_WEAPON_CAMO = 0x1F, - ASSET_TYPE_SNDDRIVER_GLOBALS = 0x20, - ASSET_TYPE_FX = 0x21, - ASSET_TYPE_IMPACT_FX = 0x22, - ASSET_TYPE_AITYPE = 0x23, - ASSET_TYPE_MPTYPE = 0x24, - ASSET_TYPE_MPBODY = 0x25, - ASSET_TYPE_MPHEAD = 0x26, - ASSET_TYPE_CHARACTER = 0x27, - ASSET_TYPE_XMODELALIAS = 0x28, - ASSET_TYPE_RAWFILE = 0x29, - ASSET_TYPE_STRINGTABLE = 0x2A, - ASSET_TYPE_LEADERBOARD = 0x2B, - ASSET_TYPE_XGLOBALS = 0x2C, - ASSET_TYPE_DDL = 0x2D, - ASSET_TYPE_GLASSES = 0x2E, - ASSET_TYPE_EMBLEMSET = 0x2F, - ASSET_TYPE_SCRIPTPARSETREE = 0x30, - ASSET_TYPE_KEYVALUEPAIRS = 0x31, - ASSET_TYPE_VEHICLEDEF = 0x32, - ASSET_TYPE_MEMORYBLOCK = 0x33, - ASSET_TYPE_ADDON_MAP_ENTS = 0x34, - ASSET_TYPE_TRACER = 0x35, - ASSET_TYPE_SKINNEDVERTS = 0x36, - ASSET_TYPE_QDB = 0x37, - ASSET_TYPE_SLUG = 0x38, - ASSET_TYPE_FOOTSTEP_TABLE = 0x39, - ASSET_TYPE_FOOTSTEPFX_TABLE = 0x3A, - ASSET_TYPE_ZBARRIER = 0x3B, - ASSET_TYPE_COUNT = 0x3C, - ASSET_TYPE_STRING = 0x3C, - ASSET_TYPE_ASSETLIST = 0x3D, - ASSET_TYPE_REPORT = 0x3E, - ASSET_TYPE_DEPEND = 0x3F, - ASSET_TYPE_FULL_COUNT = 0x40, - }; - enum XFileBlock { XFILE_BLOCK_TEMP, diff --git a/src/ModMan/Web/Binds/AssetBinds.cpp b/src/ModMan/Web/Binds/AssetBinds.cpp index 31769a01..47c611f5 100644 --- a/src/ModMan/Web/Binds/AssetBinds.cpp +++ b/src/ModMan/Web/Binds/AssetBinds.cpp @@ -110,12 +110,12 @@ namespace std::vector references; // Reserve some entries already. Numbers are arbitrary. - const auto assetCount = zone.m_pools->GetTotalAssetCount(); + const auto assetCount = zone.m_pools.GetTotalAssetCount(); assets.reserve(assetCount / 2); references.reserve(assetCount / 8); const auto& assetTypeMapper = *ICommonAssetTypeMapper::GetCommonAssetMapperByGame(zone.m_game_id); - for (const auto& asset : *zone.m_pools) + for (const auto& asset : zone.m_pools) { if (asset->IsReference()) { diff --git a/src/ModMan/Web/Binds/UnlinkingBinds.cpp b/src/ModMan/Web/Binds/UnlinkingBinds.cpp index ba3f7a58..d226e629 100644 --- a/src/ModMan/Web/Binds/UnlinkingBinds.cpp +++ b/src/ModMan/Web/Binds/UnlinkingBinds.cpp @@ -1,7 +1,7 @@ #include "UnlinkingBinds.h" #include "Context/ModManContext.h" -#include "IObjWriter.h" +#include "ObjWriter.h" #include "SearchPath/OutputPathFilesystem.h" #include "SearchPath/SearchPaths.h" #include "Utils/PathUtils.h" @@ -64,7 +64,7 @@ namespace const auto& loadedZone = *existingZone->get(); - const auto* objWriter = IObjWriter::GetObjWriterForGame(loadedZone.m_zone->m_game_id); + auto* objWriter = IObjWriter::GetObjWriterForGame(loadedZone.m_zone->m_game_id); const auto outputFolderPath = fs::path(utils::GetExecutablePath()).parent_path() / "zone_dump" / zoneName; const auto outputFolderPathStr = outputFolderPath.string(); diff --git a/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.cpp b/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.cpp index 84421051..fd4de1c0 100644 --- a/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.cpp +++ b/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.cpp @@ -8,7 +8,6 @@ #include "Game/IW4/Techset/TechsetConstantsIW4.h" #include "Gdt/AbstractGdtEntryReader.h" #include "Gdt/IGdtQueryable.h" -#include "ObjLoading.h" #include "Pool/GlobalAssetPool.h" #include "StateMap/StateMapFromTechniqueExtractor.h" #include "StateMap/StateMapHandler.h" @@ -18,6 +17,7 @@ #include "Techset/TechsetDefinitionCache.h" #include "Utils/Logging/Log.h" +#include #include #include #include diff --git a/src/ObjCompiling/Image/ImageIPakPostProcessor.h b/src/ObjCompiling/Image/ImageIPakPostProcessor.h index b6a6ec2d..28412121 100644 --- a/src/ObjCompiling/Image/ImageIPakPostProcessor.h +++ b/src/ObjCompiling/Image/ImageIPakPostProcessor.h @@ -34,11 +34,9 @@ namespace image unsigned m_current_ipak_end_index; }; - template class IPakPostProcessor final : public AbstractIPakPostProcessor + template class IPakPostProcessor final : public AbstractIPakPostProcessor { public: - static_assert(std::is_base_of_v); - IPakPostProcessor(const ZoneDefinitionContext& zoneDefinition, ISearchPath& searchPath, ZoneAssetCreationStateContainer& zoneStates, @@ -49,7 +47,7 @@ namespace image [[nodiscard]] asset_type_t GetHandlingAssetType() const override { - return AssetType::EnumEntry; + return Asset_t::EnumEntry; } }; } // namespace image diff --git a/src/ObjCompiling/Image/ImageIwdPostProcessor.h b/src/ObjCompiling/Image/ImageIwdPostProcessor.h index a7bf657b..5fe48a1a 100644 --- a/src/ObjCompiling/Image/ImageIwdPostProcessor.h +++ b/src/ObjCompiling/Image/ImageIwdPostProcessor.h @@ -34,11 +34,9 @@ namespace image unsigned m_current_iwd_end_index; }; - template class IwdPostProcessor final : public AbstractIwdPostProcessor + template class IwdPostProcessor final : public AbstractIwdPostProcessor { public: - static_assert(std::is_base_of_v); - IwdPostProcessor(const ZoneDefinitionContext& zoneDefinition, ISearchPath& searchPath, ZoneAssetCreationStateContainer& zoneStates, IOutputPath& outDir) : AbstractIwdPostProcessor(zoneDefinition, searchPath, zoneStates, outDir) { @@ -46,7 +44,7 @@ namespace image [[nodiscard]] asset_type_t GetHandlingAssetType() const override { - return AssetType::EnumEntry; + return Asset_t::EnumEntry; } }; } // namespace image diff --git a/src/ObjLoading/Asset/AssetCreationContext.cpp b/src/ObjLoading/Asset/AssetCreationContext.cpp index b5a2bd0e..f547d3e0 100644 --- a/src/ObjLoading/Asset/AssetCreationContext.cpp +++ b/src/ObjLoading/Asset/AssetCreationContext.cpp @@ -16,7 +16,7 @@ IgnoredAssetLookup::IgnoredAssetLookup(const AssetList& assetList) } } -bool IgnoredAssetLookup::IsAssetIgnored(asset_type_t assetType, const std::string& name) const +bool IgnoredAssetLookup::IsAssetIgnored(const asset_type_t assetType, const std::string& name) const { const auto entries = m_ignored_asset_lookup.equal_range(name); @@ -66,7 +66,8 @@ 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_id, &zone, zone.m_priority)), + m_forced_asset_pools(std::make_unique(zone, zone.m_priority)), + m_sub_asset_pools(IGame::GetGameById(zone.m_game_id)->GetSubAssetTypeCount()), m_creators(creators), m_ignored_asset_lookup(ignoredAssetLookup), m_forced_load_depth(0u) @@ -85,10 +86,27 @@ XAssetInfoGeneric* AssetCreationContext::AddAssetGeneric(GenericAssetRegistratio 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)); + addedAsset = m_zone.m_pools.AddAsset(std::move(xAssetInfo)); if (addedAsset == nullptr) con::error(R"(Failed to add asset of type "{}" to pool: "{}")", *IGame::GetGameById(m_zone.m_game_id)->GetAssetTypeName(assetType), pAssetName); + + return addedAsset; +} + +XAssetInfoGeneric* AssetCreationContext::AddSubAssetGeneric(GenericAssetRegistration registration) const +{ + auto xAssetInfo = registration.CreateXAssetInfo(); + xAssetInfo->m_zone = &m_zone; + + const auto subAssetType = xAssetInfo->m_type; + const auto* pAssetName = xAssetInfo->m_name.c_str(); + + auto* addedAsset = m_sub_asset_pools[subAssetType]->AddAsset(std::move(xAssetInfo)); + + if (addedAsset == nullptr) + con::error(R"(Failed to add sub asset of type "{}" to pool: "{}")", *IGame::GetGameById(m_zone.m_game_id)->GetAssetTypeName(subAssetType), pAssetName); + return addedAsset; } @@ -103,9 +121,9 @@ XAssetInfoGeneric* AssetCreationContext::LoadDefaultAssetDependency(const asset_ return nullptr; } -XAssetInfoGeneric* AssetCreationContext::LoadDependencyGeneric(const asset_type_t assetType, const std::string& assetName, bool required) +XAssetInfoGeneric* AssetCreationContext::LoadDependencyGeneric(const asset_type_t assetType, const std::string& assetName, const bool required) { - auto* alreadyLoadedAsset = m_zone.m_pools->GetAssetOrAssetReference(assetType, assetName); + auto* alreadyLoadedAsset = m_zone.m_pools.GetAssetOrAssetReference(assetType, assetName); if (alreadyLoadedAsset) return alreadyLoadedAsset; @@ -138,9 +156,28 @@ XAssetInfoGeneric* AssetCreationContext::LoadDependencyGeneric(const asset_type_ return nullptr; } +XAssetInfoGeneric* AssetCreationContext::LoadSubAssetGeneric(const asset_type_t subAssetType, const std::string& assetName) +{ + assert(subAssetType < m_sub_asset_pools.size()); + auto* alreadyLoadedSubAsset = m_sub_asset_pools[subAssetType]->GetAsset(assetName); + if (alreadyLoadedSubAsset) + return alreadyLoadedSubAsset; + + const auto result = m_creators->CreateSubAsset(subAssetType, assetName, *this); + if (result.HasTakenAction()) + { + if (!result.HasFailed()) + return result.GetAssetInfo(); + + con::error(R"(Could not load sub asset "{}" of type "{}")", assetName, *IGame::GetGameById(m_zone.m_game_id)->GetSubAssetTypeName(subAssetType)); + } + + return nullptr; +} + IndirectAssetReference AssetCreationContext::LoadIndirectAssetReferenceGeneric(const asset_type_t assetType, const std::string& assetName) { - const 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); @@ -158,7 +195,7 @@ IndirectAssetReference AssetCreationContext::LoadIndirectAssetReferenceGeneric(c XAssetInfoGeneric* AssetCreationContext::ForceLoadDependencyGeneric(const asset_type_t assetType, const std::string& assetName) { - auto* alreadyLoadedAsset = m_zone.m_pools->GetAssetOrAssetReference(assetType, assetName); + auto* alreadyLoadedAsset = m_zone.m_pools.GetAssetOrAssetReference(assetType, assetName); if (alreadyLoadedAsset && !alreadyLoadedAsset->IsReference()) return alreadyLoadedAsset; alreadyLoadedAsset = m_forced_asset_pools->GetAssetOrAssetReference(assetType, assetName); diff --git a/src/ObjLoading/Asset/AssetCreationContext.h b/src/ObjLoading/Asset/AssetCreationContext.h index d0efd031..0c349457 100644 --- a/src/ObjLoading/Asset/AssetCreationContext.h +++ b/src/ObjLoading/Asset/AssetCreationContext.h @@ -30,36 +30,47 @@ class AssetCreationContext : public ZoneAssetCreationStateContainer public: AssetCreationContext(Zone& zone, const AssetCreatorCollection* creators, const IgnoredAssetLookup* ignoredAssetLookup); - template XAssetInfo* AddAsset(AssetRegistration registration) + template XAssetInfo* AddAsset(AssetRegistration registration) { - static_assert(std::is_base_of_v); - - return static_cast*>(AddAssetGeneric(std::move(registration))); + return static_cast*>(AddAssetGeneric(std::move(registration))); } - template XAssetInfo* AddAsset(std::string assetName, typename AssetType::Type* asset) + template XAssetInfo* AddAsset(std::string assetName, Asset_t::Type* asset) { - static_assert(std::is_base_of_v); - - return static_cast*>(AddAssetGeneric(AssetRegistration(std::move(assetName), asset))); + return static_cast*>(AddAssetGeneric(AssetRegistration(std::move(assetName), asset))); } XAssetInfoGeneric* AddAssetGeneric(GenericAssetRegistration registration) const; - template XAssetInfo* LoadDependency(const std::string& assetName) + template XAssetInfo* AddSubAsset(AssetRegistration registration) { - static_assert(std::is_base_of_v); + return static_cast*>(AddSubAssetGeneric(std::move(registration))); + } - return static_cast*>(LoadDependencyGeneric(AssetType::EnumEntry, assetName)); + template XAssetInfo* AddSubAsset(std::string assetName, SubAsset_t::Type* asset) + { + return static_cast*>(AddSubAssetGeneric(AssetRegistration(std::move(assetName), asset))); + } + + XAssetInfoGeneric* AddSubAssetGeneric(GenericAssetRegistration registration) const; + + template XAssetInfo* LoadDependency(const std::string& assetName) + { + return static_cast*>(LoadDependencyGeneric(Asset_t::EnumEntry, assetName)); } XAssetInfoGeneric* LoadDependencyGeneric(asset_type_t assetType, const std::string& assetName, bool required = true); - template IndirectAssetReference LoadIndirectAssetReference(const std::string& assetName) + template XAssetInfo* LoadSubAsset(const std::string& assetName) { - static_assert(std::is_base_of_v); + return static_cast*>(LoadSubAssetGeneric(SubAsset_t::EnumEntry, assetName)); + } - return LoadIndirectAssetReferenceGeneric(AssetType::EnumEntry, assetName); + XAssetInfoGeneric* LoadSubAssetGeneric(asset_type_t subAssetType, const std::string& assetName); + + template IndirectAssetReference LoadIndirectAssetReference(const std::string& assetName) + { + return LoadIndirectAssetReferenceGeneric(Asset_t::EnumEntry, assetName); } IndirectAssetReference LoadIndirectAssetReferenceGeneric(asset_type_t assetType, const std::string& assetName); @@ -67,15 +78,13 @@ public: /** * \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 + * \tparam Asset_t 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) + template XAssetInfo* ForceLoadDependency(const std::string& assetName) { - static_assert(std::is_base_of_v); - - return static_cast*>(ForceLoadDependencyGeneric(AssetType::EnumEntry, assetName)); + return static_cast*>(ForceLoadDependencyGeneric(Asset_t::EnumEntry, assetName)); } XAssetInfoGeneric* ForceLoadDependencyGeneric(asset_type_t assetType, const std::string& assetName); @@ -85,6 +94,7 @@ private: Zone& m_zone; std::unique_ptr m_forced_asset_pools; + std::vector> m_sub_asset_pools; const AssetCreatorCollection* m_creators; const IgnoredAssetLookup* m_ignored_asset_lookup; diff --git a/src/ObjLoading/Asset/AssetCreatorCollection.cpp b/src/ObjLoading/Asset/AssetCreatorCollection.cpp index 4ed9b70f..13282c69 100644 --- a/src/ObjLoading/Asset/AssetCreatorCollection.cpp +++ b/src/ObjLoading/Asset/AssetCreatorCollection.cpp @@ -6,6 +6,7 @@ AssetCreatorCollection::AssetCreatorCollection(const Zone& zone) { const auto* game = IGame::GetGameById(zone.m_game_id); m_asset_creators_by_type.resize(game->GetAssetTypeCount()); + m_sub_asset_creators_by_type.resize(game->GetSubAssetTypeCount()); m_asset_post_processors_by_type.resize(game->GetAssetTypeCount()); m_default_asset_creators_by_type.resize(game->GetAssetTypeCount()); } @@ -20,6 +21,16 @@ void AssetCreatorCollection::AddAssetCreator(std::unique_ptr crea m_asset_creators.emplace_back(std::move(creator)); } +void AssetCreatorCollection::AddSubAssetCreator(std::unique_ptr creator) +{ + const auto maybeHandlingSubAssetType = creator->GetHandlingSubAssetType(); + assert(!maybeHandlingSubAssetType || static_cast(*maybeHandlingSubAssetType) < m_sub_asset_creators_by_type.size()); + if (maybeHandlingSubAssetType && static_cast(*maybeHandlingSubAssetType) < m_sub_asset_creators_by_type.size()) + m_sub_asset_creators_by_type[static_cast(*maybeHandlingSubAssetType)].emplace_back(creator.get()); + + m_sub_asset_creators.emplace_back(std::move(creator)); +} + void AssetCreatorCollection::AddAssetPostProcessor(std::unique_ptr postProcessor) { const auto handlingAssetType = postProcessor->GetHandlingAssetType(); @@ -42,9 +53,9 @@ void AssetCreatorCollection::AddDefaultAssetCreator(std::unique_ptr= 0 && static_cast(assetType) < m_asset_creators_by_type.size()); + assert(assetType < m_asset_creators_by_type.size()); - if (assetType >= 0 && static_cast(assetType) < m_asset_creators_by_type.size()) + if (assetType < m_asset_creators_by_type.size()) { for (const auto& creator : m_asset_creators_by_type[assetType]) { @@ -68,11 +79,29 @@ AssetCreationResult AssetCreatorCollection::CreateAsset(const asset_type_t asset return AssetCreationResult::NoAction(); } +AssetCreationResult + AssetCreatorCollection::CreateSubAsset(const asset_type_t subAssetType, const std::string& subAssetName, AssetCreationContext& context) const +{ + assert(subAssetType < m_sub_asset_creators_by_type.size()); + + if (subAssetType < m_sub_asset_creators_by_type.size()) + { + for (const auto& creator : m_sub_asset_creators_by_type[subAssetType]) + { + const auto result = creator->CreateSubAsset(subAssetName, context); + if (result.HasTakenAction()) + return result; + } + } + + return AssetCreationResult::NoAction(); +} + AssetCreationResult AssetCreatorCollection::CreateDefaultAsset(const asset_type_t assetType, const std::string& assetName, AssetCreationContext& context) const { - assert(assetType >= 0 && static_cast(assetType) < m_default_asset_creators_by_type.size()); + assert(assetType < m_default_asset_creators_by_type.size()); - if (assetType >= 0 && static_cast(assetType) < m_default_asset_creators_by_type.size() && m_default_asset_creators_by_type[assetType]) + if (assetType < m_default_asset_creators_by_type.size() && m_default_asset_creators_by_type[assetType]) { return m_default_asset_creators_by_type[assetType]->CreateDefaultAsset(assetName, context); } diff --git a/src/ObjLoading/Asset/AssetCreatorCollection.h b/src/ObjLoading/Asset/AssetCreatorCollection.h index 9b720b11..9065ff41 100644 --- a/src/ObjLoading/Asset/AssetCreatorCollection.h +++ b/src/ObjLoading/Asset/AssetCreatorCollection.h @@ -12,6 +12,7 @@ class AssetCreationContext; class IAssetCreator; +class ISubAssetCreator; class IAssetPostProcessor; class AssetCreationResult; class IDefaultAssetCreator; @@ -22,17 +23,24 @@ public: explicit AssetCreatorCollection(const Zone& zone); void AddAssetCreator(std::unique_ptr creator); + void AddSubAssetCreator(std::unique_ptr creator); void AddAssetPostProcessor(std::unique_ptr postProcessor); void AddDefaultAssetCreator(std::unique_ptr defaultAssetCreator); AssetCreationResult CreateAsset(asset_type_t assetType, const std::string& assetName, AssetCreationContext& context) const; + AssetCreationResult CreateSubAsset(asset_type_t subAssetType, const std::string& subAssetName, AssetCreationContext& context) const; AssetCreationResult CreateDefaultAsset(asset_type_t assetType, const std::string& assetName, AssetCreationContext& context) const; void FinalizeZone(AssetCreationContext& context) const; private: std::vector> m_asset_creators_by_type; std::vector> m_asset_creators; + + std::vector> m_sub_asset_creators_by_type; + std::vector> m_sub_asset_creators; + std::vector> m_asset_post_processors_by_type; std::vector> m_asset_post_processors; + std::vector> m_default_asset_creators_by_type; }; diff --git a/src/ObjLoading/Asset/AssetRegistration.h b/src/ObjLoading/Asset/AssetRegistration.h index a0b549ec..398247f1 100644 --- a/src/ObjLoading/Asset/AssetRegistration.h +++ b/src/ObjLoading/Asset/AssetRegistration.h @@ -34,18 +34,16 @@ protected: std::unordered_set m_indirect_asset_references; }; -template class AssetRegistration : public GenericAssetRegistration +template class AssetRegistration : public GenericAssetRegistration { - static_assert(std::is_base_of_v); - public: - AssetRegistration(std::string assetName) - : GenericAssetRegistration(AssetType::EnumEntry, std::move(assetName), nullptr) + explicit AssetRegistration(std::string assetName) + : GenericAssetRegistration(Asset_t::EnumEntry, std::move(assetName), nullptr) { } - AssetRegistration(std::string assetName, typename AssetType::Type* asset) - : GenericAssetRegistration(AssetType::EnumEntry, std::move(assetName), asset) + AssetRegistration(std::string assetName, typename Asset_t::Type* asset) + : GenericAssetRegistration(Asset_t::EnumEntry, std::move(assetName), asset) { } @@ -54,7 +52,7 @@ public: AssetRegistration& operator=(const AssetRegistration& other) = delete; AssetRegistration& operator=(AssetRegistration&& other) noexcept = default; - void SetAsset(typename AssetType::Type* asset) + void SetAsset(typename Asset_t::Type* asset) { m_asset = asset; } diff --git a/src/ObjLoading/Asset/GlobalAssetPoolsLoader.h b/src/ObjLoading/Asset/GlobalAssetPoolsLoader.h index e47a32e4..09c348b1 100644 --- a/src/ObjLoading/Asset/GlobalAssetPoolsLoader.h +++ b/src/ObjLoading/Asset/GlobalAssetPoolsLoader.h @@ -25,11 +25,9 @@ private: bool m_failure; }; -template class GlobalAssetPoolsLoader : public AssetCreator +template class GlobalAssetPoolsLoader : public AssetCreator { public: - static_assert(std::is_base_of_v); - explicit GlobalAssetPoolsLoader(Zone& zone) : m_zone(zone) { @@ -37,15 +35,15 @@ public: AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - auto* existingAsset = GlobalAssetPool::GetAssetByName(assetName); + auto* existingAsset = GameGlobalAssetPools::GetGlobalPoolsForGame(m_zone.m_game_id)->GetAsset(assetName); if (!existingAsset) return AssetCreationResult::NoAction(); - AssetRegistration registration(assetName, existingAsset->Asset()); + AssetRegistration registration(assetName, existingAsset->Asset()); GlobalAssetPoolsRegistrationPreparation registrationPreparation(registration, m_zone, *existingAsset->m_zone, context); - AssetMarker marker(registrationPreparation); + AssetMarker marker(registrationPreparation); marker.Mark(existingAsset->Asset()); auto* newAsset = context.AddAsset(std::move(registration)); diff --git a/src/ObjLoading/Asset/IAssetCreator.h b/src/ObjLoading/Asset/IAssetCreator.h index 42dfeed0..172aedb0 100644 --- a/src/ObjLoading/Asset/IAssetCreator.h +++ b/src/ObjLoading/Asset/IAssetCreator.h @@ -29,13 +29,36 @@ public: virtual void FinalizeZone(AssetCreationContext& context) {} }; -template class AssetCreator : public IAssetCreator +class ISubAssetCreator { public: - static_assert(std::is_base_of_v); + ISubAssetCreator() = default; + virtual ~ISubAssetCreator() = default; + ISubAssetCreator(const ISubAssetCreator& other) = default; + ISubAssetCreator(ISubAssetCreator&& other) noexcept = default; + ISubAssetCreator& operator=(const ISubAssetCreator& other) = default; + ISubAssetCreator& operator=(ISubAssetCreator&& other) noexcept = default; + [[nodiscard]] virtual std::optional GetHandlingSubAssetType() const = 0; + virtual AssetCreationResult CreateSubAsset(const std::string& subAssetName, AssetCreationContext& context) = 0; + + virtual void FinalizeZone(AssetCreationContext& context) {} +}; + +template class AssetCreator : public IAssetCreator +{ +public: [[nodiscard]] std::optional GetHandlingAssetType() const override { - return AssetType::EnumEntry; - }; + return Asset_t::EnumEntry; + } +}; + +template class SubAssetCreator : public ISubAssetCreator +{ +public: + [[nodiscard]] std::optional GetHandlingSubAssetType() const override + { + return SubAsset_t::EnumEntry; + } }; diff --git a/src/ObjLoading/Asset/IDefaultAssetCreator.h b/src/ObjLoading/Asset/IDefaultAssetCreator.h index cf43ba2a..f07c053b 100644 --- a/src/ObjLoading/Asset/IDefaultAssetCreator.h +++ b/src/ObjLoading/Asset/IDefaultAssetCreator.h @@ -24,27 +24,25 @@ public: virtual AssetCreationResult CreateDefaultAsset(const std::string& assetName, AssetCreationContext& context) const = 0; }; -template class DefaultAssetCreator : public IDefaultAssetCreator +template class DefaultAssetCreator : public IDefaultAssetCreator { public: - static_assert(std::is_base_of_v); - - DefaultAssetCreator(MemoryManager& memory) + explicit DefaultAssetCreator(MemoryManager& memory) : m_memory(memory) { } [[nodiscard]] asset_type_t GetHandlingAssetType() const override { - return AssetType::EnumEntry; + return Asset_t::EnumEntry; } AssetCreationResult CreateDefaultAsset(const std::string& assetName, AssetCreationContext& context) const override { - auto* asset = m_memory.Alloc(); - AssetName(*asset) = m_memory.Dup(assetName.c_str()); + auto* asset = m_memory.Alloc(); + AssetName(*asset) = m_memory.Dup(assetName.c_str()); - return AssetCreationResult::Success(context.AddAsset(assetName, asset)); + return AssetCreationResult::Success(context.AddAsset(assetName, asset)); } private: diff --git a/src/ObjLoading/Game/T6/ObjLoaderT6.cpp b/src/ObjLoading/Game/T6/ObjLoaderT6.cpp index b9747017..5642bf4a 100644 --- a/src/ObjLoading/Game/T6/ObjLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/ObjLoaderT6.cpp @@ -5,7 +5,6 @@ #include "FontIcon/JsonLoaderFontIconT6.h" #include "Game/T6/AssetMarkerT6.h" #include "Game/T6/CommonT6.h" -#include "Game/T6/GameAssetPoolT6.h" #include "Game/T6/GameT6.h" #include "Game/T6/Image/ImageLoaderEmbeddedT6.h" #include "Game/T6/Image/ImageLoaderExternalT6.h" @@ -236,36 +235,29 @@ namespace T6 void ObjLoader::LoadReferencedContainersForZone(ISearchPath& searchPath, Zone& zone) const { - const auto* assetPoolT6 = dynamic_cast(zone.m_pools.get()); const auto zoneNameHash = Common::Com_HashKey(zone.m_name.c_str(), 64); LoadCommonIPaks(searchPath, zone); - if (assetPoolT6->m_key_value_pairs != nullptr) + for (auto* keyValuePairsEntry : zone.m_pools.PoolAssets()) { - for (auto* keyValuePairsEntry : *assetPoolT6->m_key_value_pairs) + const auto* keyValuePairs = keyValuePairsEntry->Asset(); + for (auto variableIndex = 0u; variableIndex < keyValuePairs->numVariables; variableIndex++) { - const auto* keyValuePairs = keyValuePairsEntry->Asset(); - for (auto variableIndex = 0u; variableIndex < keyValuePairs->numVariables; variableIndex++) - { - auto* variable = &keyValuePairs->keyValuePairs[variableIndex]; + auto* variable = &keyValuePairs->keyValuePairs[variableIndex]; - if (variable->namespaceHash == zoneNameHash && variable->keyHash == IPAK_READ_HASH) - { - LoadIPakForZone(searchPath, variable->value, zone); - } + if (variable->namespaceHash == zoneNameHash && variable->keyHash == IPAK_READ_HASH) + { + LoadIPakForZone(searchPath, variable->value, zone); } } } - if (assetPoolT6->m_sound_bank != nullptr) - { - std::set loadedSoundBanksForZone; + std::set loadedSoundBanksForZone; - for (auto* sndBankAssetInfo : *assetPoolT6->m_sound_bank) - { - LoadSoundBanksFromAsset(searchPath, *sndBankAssetInfo->Asset(), zone, loadedSoundBanksForZone); - } + for (auto* sndBankAssetInfo : zone.m_pools.PoolAssets()) + { + LoadSoundBanksFromAsset(searchPath, *sndBankAssetInfo->Asset(), zone, loadedSoundBanksForZone); } } diff --git a/src/ObjWriting/Dumping/AbstractAssetDumper.h b/src/ObjWriting/Dumping/AbstractAssetDumper.h index c0371bc4..3d85433b 100644 --- a/src/ObjWriting/Dumping/AbstractAssetDumper.h +++ b/src/ObjWriting/Dumping/AbstractAssetDumper.h @@ -4,23 +4,26 @@ #include "IAssetDumper.h" #include "Pool/AssetPool.h" -template class AbstractAssetDumper : public IAssetDumper +template class AbstractAssetDumper : public IAssetDumper { - static_assert(std::is_base_of_v); - public: - using AssetType_t = AssetType; + using AssetType_t = Asset_t; - [[nodiscard]] size_t GetProgressTotalCount() const override + [[nodiscard]] std::optional GetHandlingAssetType() const override { - return m_pool.m_asset_lookup.size(); + return Asset_t::EnumEntry; + } + + [[nodiscard]] size_t GetProgressTotalCount(AssetDumpingContext& context) const override + { + return context.m_zone.m_pools.PoolAssets().size(); } void Dump(AssetDumpingContext& context) override { - for (const auto* assetInfo : m_pool) + for (const auto* assetInfo : context.m_zone.m_pools.PoolAssets()) { - if (assetInfo->m_name[0] == ',' || !ShouldDump(*assetInfo)) + if (assetInfo->IsReference() || !ShouldDump(*assetInfo)) { context.IncrementProgress(); continue; @@ -32,38 +35,26 @@ public: } protected: - explicit AbstractAssetDumper(const AssetPool& pool) - : m_pool(pool) - { - } - - virtual bool ShouldDump(const XAssetInfo& asset) + virtual bool ShouldDump(const XAssetInfo& asset) { return true; } - virtual void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) = 0; - - const AssetPool& m_pool; + virtual void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) = 0; }; -template class AbstractSingleProgressAssetDumper : public IAssetDumper +template class AbstractSingleProgressAssetDumper : public IAssetDumper { - static_assert(std::is_base_of_v); - public: - using AssetType_t = AssetType; + using AssetType_t = Asset_t; - [[nodiscard]] size_t GetProgressTotalCount() const override + [[nodiscard]] std::optional GetHandlingAssetType() const override { - return m_pool.m_asset_lookup.empty() ? 0uz : 1uz; + return Asset_t::EnumEntry; } -protected: - explicit AbstractSingleProgressAssetDumper(const AssetPool& pool) - : m_pool(pool) + [[nodiscard]] size_t GetProgressTotalCount(AssetDumpingContext& context) const override { + return context.m_zone.m_pools.PoolAssets().empty() ? 0uz : 1uz; } - - const AssetPool& m_pool; }; diff --git a/src/ObjWriting/Dumping/IAssetDumper.h b/src/ObjWriting/Dumping/IAssetDumper.h index 7c046de3..ebfa0750 100644 --- a/src/ObjWriting/Dumping/IAssetDumper.h +++ b/src/ObjWriting/Dumping/IAssetDumper.h @@ -1,6 +1,9 @@ #pragma once #include "AssetDumpingContext.h" +#include "Zone/ZoneTypes.h" + +#include class IAssetDumper { @@ -12,6 +15,11 @@ public: IAssetDumper& operator=(const IAssetDumper& other) = default; IAssetDumper& operator=(IAssetDumper&& other) noexcept = default; - [[nodiscard]] virtual size_t GetProgressTotalCount() const = 0; + [[nodiscard]] virtual std::optional GetHandlingAssetType() const + { + return std::nullopt; + } + + [[nodiscard]] virtual size_t GetProgressTotalCount(AssetDumpingContext& context) const = 0; virtual void Dump(AssetDumpingContext& context) = 0; }; diff --git a/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.cpp b/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.cpp index f73d88d7..1d9b2572 100644 --- a/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.cpp +++ b/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.cpp @@ -64,8 +64,8 @@ namespace namespace image { - DumperIW3::DumperIW3(const AssetPool& pool) - : AbstractAssetDumper(pool) + DumperIW3::DumperIW3() + : AbstractAssetDumper() { switch (ObjWriting::Configuration.ImageOutputFormat) { diff --git a/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.h b/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.h index e8c9665c..05e0224a 100644 --- a/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.h +++ b/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.h @@ -11,7 +11,7 @@ namespace image class DumperIW3 final : public AbstractAssetDumper { public: - explicit DumperIW3(const AssetPool& pool); + DumperIW3(); protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; diff --git a/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.cpp b/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.cpp index e1e1c9e5..cf27dfbb 100644 --- a/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.cpp +++ b/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.cpp @@ -5,25 +5,15 @@ #include "Utils/Logging/Log.h" #include -#include using namespace IW3; namespace localize { - DumperIW3::DumperIW3(const AssetPool& pool) - : AbstractSingleProgressAssetDumper(pool) - { - } - - size_t DumperIW3::GetProgressTotalCount() const - { - return m_pool.m_asset_lookup.empty() ? 0uz : 1uz; - } - void DumperIW3::Dump(AssetDumpingContext& context) { - if (m_pool.m_asset_lookup.empty()) + auto localizeAssets = context.m_zone.m_pools.PoolAssets(); + if (localizeAssets.empty()) return; const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language); @@ -40,7 +30,7 @@ namespace localize stringFileDumper.SetNotes(""); - for (const auto* localizeEntry : m_pool) + for (const auto* localizeEntry : localizeAssets) { stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value); } diff --git a/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.h b/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.h index 18971f83..a3a982e3 100644 --- a/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.h +++ b/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.h @@ -2,16 +2,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW3/IW3.h" -#include "Pool/AssetPool.h" namespace localize { class DumperIW3 final : public AbstractSingleProgressAssetDumper { public: - explicit DumperIW3(const AssetPool& pool); - - [[nodiscard]] size_t GetProgressTotalCount() const override; void Dump(AssetDumpingContext& context) override; }; } // namespace localize diff --git a/src/ObjWriting/Game/IW3/Maps/MapEntsDumperIW3.cpp b/src/ObjWriting/Game/IW3/Maps/MapEntsDumperIW3.cpp index e89014a4..53af032e 100644 --- a/src/ObjWriting/Game/IW3/Maps/MapEntsDumperIW3.cpp +++ b/src/ObjWriting/Game/IW3/Maps/MapEntsDumperIW3.cpp @@ -4,11 +4,6 @@ using namespace IW3; namespace map_ents { - DumperIW3::DumperIW3(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperIW3::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* mapEnts = asset.Asset(); diff --git a/src/ObjWriting/Game/IW3/Maps/MapEntsDumperIW3.h b/src/ObjWriting/Game/IW3/Maps/MapEntsDumperIW3.h index 7e7786ea..06386c20 100644 --- a/src/ObjWriting/Game/IW3/Maps/MapEntsDumperIW3.h +++ b/src/ObjWriting/Game/IW3/Maps/MapEntsDumperIW3.h @@ -7,9 +7,6 @@ namespace map_ents { class DumperIW3 final : public AbstractAssetDumper { - public: - explicit DumperIW3(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW3/Material/MaterialConstantZoneStateIW3.cpp b/src/ObjWriting/Game/IW3/Material/MaterialConstantZoneStateIW3.cpp index 662b0604..2bc90c8b 100644 --- a/src/ObjWriting/Game/IW3/Material/MaterialConstantZoneStateIW3.cpp +++ b/src/ObjWriting/Game/IW3/Material/MaterialConstantZoneStateIW3.cpp @@ -1,7 +1,6 @@ #include "MaterialConstantZoneStateIW3.h" #include "Game/IW3/CommonIW3.h" -#include "Game/IW3/GameAssetPoolIW3.h" #include "Game/IW3/GameIW3.h" #include "ObjWriting.h" #include "Zone/ZoneRegistry.h" @@ -205,11 +204,7 @@ namespace IW3 { for (const auto* zone : ZoneRegistry::GetRegistryForGame(GameId::IW3)->Zones()) { - const auto* assetPools = dynamic_cast(zone->m_pools.get()); - if (!assetPools) - return; - - for (const auto* techniqueSetInfo : *assetPools->m_technique_set) + for (const auto* techniqueSetInfo : zone->m_pools.PoolAssets()) { const auto* techniqueSet = techniqueSetInfo->Asset(); diff --git a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp index aba69545..e754eb6b 100644 --- a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp +++ b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp @@ -1,69 +1,42 @@ #include "ObjWriterIW3.h" -#include "Game/IW3/GameAssetPoolIW3.h" #include "Game/IW3/Material/MaterialJsonDumperIW3.h" #include "Game/IW3/XModel/XModelDumperIW3.h" #include "Image/ImageDumperIW3.h" #include "Localize/LocalizeDumperIW3.h" #include "Maps/MapEntsDumperIW3.h" -#include "ObjWriting.h" #include "RawFile/RawFileDumperIW3.h" #include "Sound/LoadedSoundDumperIW3.h" #include "StringTable/StringTableDumperIW3.h" using namespace IW3; -bool ObjWriter::DumpZone(AssetDumpingContext& context) const +void ObjWriter::RegisterAssetDumpers(AssetDumpingContext& context) { -#define REGISTER_DUMPER(dumperType, poolName) \ - if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(dumperType::AssetType_t::EnumEntry)) \ - { \ - dumpers.emplace_back(std::make_unique(*assetPools->poolName)); \ - } - - const auto* assetPools = dynamic_cast(context.m_zone.m_pools.get()); - std::vector> dumpers; - - // REGISTER_DUMPER(AssetDumperPhysPreset, m_phys_preset) - // REGISTER_DUMPER(AssetDumperXAnimParts, m_xanim_parts) - REGISTER_DUMPER(xmodel::DumperIW3, m_xmodel) - REGISTER_DUMPER(material::JsonDumperIW3, m_material) - // REGISTER_DUMPER(AssetDumperMaterialTechniqueSet, m_technique_set) - REGISTER_DUMPER(image::DumperIW3, m_image) - // REGISTER_DUMPER(AssetDumpersnd_alias_list_t, m_sound) - // REGISTER_DUMPER(AssetDumperSndCurve, m_sound_curve) - REGISTER_DUMPER(sound::LoadedSoundDumperIW3, m_loaded_sound) - // REGISTER_DUMPER(AssetDumperClipMap, m_clip_map) - // REGISTER_DUMPER(AssetDumperComWorld, m_com_world) - // REGISTER_DUMPER(AssetDumperGameWorldSp, m_game_world_sp) - // REGISTER_DUMPER(AssetDumperGameWorldMp, m_game_world_mp) - REGISTER_DUMPER(map_ents::DumperIW3, m_map_ents) - // REGISTER_DUMPER(AssetDumperGfxWorld, m_gfx_world) - // REGISTER_DUMPER(AssetDumperGfxLightDef, m_gfx_light_def) - // REGISTER_DUMPER(AssetDumperFont_s, m_font) - // REGISTER_DUMPER(AssetDumperMenuList, m_menu_list) - // REGISTER_DUMPER(AssetDumpermenuDef_t, m_menu_def) - REGISTER_DUMPER(localize::DumperIW3, m_localize) - // REGISTER_DUMPER(AssetDumperWeapon, m_weapon) - // REGISTER_DUMPER(AssetDumperSndDriverGlobals, m_snd_driver_globals) - // REGISTER_DUMPER(AssetDumperFxEffectDef, m_fx) - // REGISTER_DUMPER(AssetDumperFxImpactTable, m_fx_impact_table) - REGISTER_DUMPER(raw_file::DumperIW3, m_raw_file) - REGISTER_DUMPER(string_table::DumperIW3, m_string_table) - - if (context.ShouldTrackProgress()) - { - size_t totalProgress = 0uz; - for (const auto& dumper : dumpers) - totalProgress += dumper->GetProgressTotalCount(); - - context.SetTotalProgress(totalProgress); - } - - for (const auto& dumper : dumpers) - dumper->Dump(context); - - return true; - -#undef REGISTER_DUMPER + // REGISTER_DUMPER(AssetDumperPhysPreset) + // REGISTER_DUMPER(AssetDumperXAnimParts) + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + // REGISTER_DUMPER(AssetDumperMaterialTechniqueSet) + RegisterAssetDumper(std::make_unique()); + // REGISTER_DUMPER(AssetDumpersnd_alias_list_t) + // REGISTER_DUMPER(AssetDumperSndCurve) + RegisterAssetDumper(std::make_unique()); + // REGISTER_DUMPER(AssetDumperClipMap) + // REGISTER_DUMPER(AssetDumperComWorld) + // REGISTER_DUMPER(AssetDumperGameWorldSp) + // REGISTER_DUMPER(AssetDumperGameWorldMp) + RegisterAssetDumper(std::make_unique()); + // REGISTER_DUMPER(AssetDumperGfxWorld) + // REGISTER_DUMPER(AssetDumperGfxLightDef) + // REGISTER_DUMPER(AssetDumperFont_s) + // REGISTER_DUMPER(AssetDumperMenuList) + // REGISTER_DUMPER(AssetDumpermenuDef_t) + RegisterAssetDumper(std::make_unique()); + // REGISTER_DUMPER(AssetDumperWeapon) + // REGISTER_DUMPER(AssetDumperSndDriverGlobals) + // REGISTER_DUMPER(AssetDumperFxEffectDef) + // REGISTER_DUMPER(AssetDumperFxImpactTable) + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); } diff --git a/src/ObjWriting/Game/IW3/ObjWriterIW3.h b/src/ObjWriting/Game/IW3/ObjWriterIW3.h index e28527d4..02935e12 100644 --- a/src/ObjWriting/Game/IW3/ObjWriterIW3.h +++ b/src/ObjWriting/Game/IW3/ObjWriterIW3.h @@ -1,12 +1,12 @@ #pragma once -#include "IObjWriter.h" +#include "ObjWriter.h" namespace IW3 { class ObjWriter final : public IObjWriter { - public: - bool DumpZone(AssetDumpingContext& context) const override; + protected: + void RegisterAssetDumpers(AssetDumpingContext& context) override; }; } // namespace IW3 diff --git a/src/ObjWriting/Game/IW3/RawFile/RawFileDumperIW3.cpp b/src/ObjWriting/Game/IW3/RawFile/RawFileDumperIW3.cpp index 9ec12f1d..b6efba38 100644 --- a/src/ObjWriting/Game/IW3/RawFile/RawFileDumperIW3.cpp +++ b/src/ObjWriting/Game/IW3/RawFile/RawFileDumperIW3.cpp @@ -4,11 +4,6 @@ using namespace IW3; namespace raw_file { - DumperIW3::DumperIW3(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperIW3::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* rawFile = asset.Asset(); diff --git a/src/ObjWriting/Game/IW3/RawFile/RawFileDumperIW3.h b/src/ObjWriting/Game/IW3/RawFile/RawFileDumperIW3.h index eb6a80b2..9ade98ae 100644 --- a/src/ObjWriting/Game/IW3/RawFile/RawFileDumperIW3.h +++ b/src/ObjWriting/Game/IW3/RawFile/RawFileDumperIW3.h @@ -7,9 +7,6 @@ namespace raw_file { class DumperIW3 final : public AbstractAssetDumper { - public: - explicit DumperIW3(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.cpp b/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.cpp index 2fe85a25..ca7b7109 100644 --- a/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.cpp +++ b/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.cpp @@ -25,11 +25,6 @@ namespace namespace sound { - LoadedSoundDumperIW3::LoadedSoundDumperIW3(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void LoadedSoundDumperIW3::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* loadedSound = asset.Asset(); diff --git a/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.h b/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.h index c639ff07..f05820d1 100644 --- a/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.h +++ b/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.h @@ -7,9 +7,6 @@ namespace sound { class LoadedSoundDumperIW3 final : public AbstractAssetDumper { - public: - explicit LoadedSoundDumperIW3(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.cpp b/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.cpp index cf36f2fe..0dc0322c 100644 --- a/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.cpp +++ b/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.cpp @@ -6,11 +6,6 @@ using namespace IW3; namespace string_table { - DumperIW3::DumperIW3(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperIW3::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* stringTable = asset.Asset(); diff --git a/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.h b/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.h index 78c87d6f..f35995d2 100644 --- a/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.h +++ b/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.h @@ -7,9 +7,6 @@ namespace string_table { class DumperIW3 final : public AbstractAssetDumper { - public: - explicit DumperIW3(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.cpp b/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.cpp index e52aacd3..bf85f7e6 100644 --- a/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.cpp @@ -61,8 +61,7 @@ namespace namespace image { - DumperIW4::DumperIW4(const AssetPool& pool) - : AbstractAssetDumper(pool) + DumperIW4::DumperIW4() { switch (ObjWriting::Configuration.ImageOutputFormat) { diff --git a/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.h b/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.h index 80239cbc..eb92d015 100644 --- a/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.h @@ -11,7 +11,7 @@ namespace image class DumperIW4 final : public AbstractAssetDumper { public: - explicit DumperIW4(const AssetPool& pool); + DumperIW4(); protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; diff --git a/src/ObjWriting/Game/IW4/Leaderboard/LeaderboardJsonDumperIW4.cpp b/src/ObjWriting/Game/IW4/Leaderboard/LeaderboardJsonDumperIW4.cpp index 41840a68..ced306ab 100644 --- a/src/ObjWriting/Game/IW4/Leaderboard/LeaderboardJsonDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Leaderboard/LeaderboardJsonDumperIW4.cpp @@ -77,11 +77,6 @@ namespace namespace leaderboard { - JsonDumperIW4::JsonDumperIW4(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void JsonDumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAsset(asset.m_name)); diff --git a/src/ObjWriting/Game/IW4/Leaderboard/LeaderboardJsonDumperIW4.h b/src/ObjWriting/Game/IW4/Leaderboard/LeaderboardJsonDumperIW4.h index e5098b64..e9f3ffc2 100644 --- a/src/ObjWriting/Game/IW4/Leaderboard/LeaderboardJsonDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Leaderboard/LeaderboardJsonDumperIW4.h @@ -7,9 +7,6 @@ namespace leaderboard { class JsonDumperIW4 final : public AbstractAssetDumper { - public: - explicit JsonDumperIW4(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.cpp b/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.cpp index 402ed74a..3806cddf 100644 --- a/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.cpp @@ -6,11 +6,6 @@ using namespace IW4; namespace light_def { - DumperIW4::DumperIW4(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* lightDef = asset.Asset(); diff --git a/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.h b/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.h index 9bc28e3a..58891d44 100644 --- a/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.h +++ b/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.h @@ -7,9 +7,6 @@ namespace light_def { class DumperIW4 final : public AbstractAssetDumper { - public: - explicit DumperIW4(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.cpp b/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.cpp index 67003134..26b453e8 100644 --- a/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.cpp @@ -10,14 +10,10 @@ using namespace IW4; namespace localize { - DumperIW4::DumperIW4(const AssetPool& pool) - : AbstractSingleProgressAssetDumper(pool) - { - } - void DumperIW4::Dump(AssetDumpingContext& context) { - if (m_pool.m_asset_lookup.empty()) + auto localizeAssets = context.m_zone.m_pools.PoolAssets(); + if (localizeAssets.empty()) return; const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language); @@ -34,7 +30,7 @@ namespace localize stringFileDumper.SetNotes(""); - for (const auto* localizeEntry : m_pool) + for (const auto* localizeEntry : localizeAssets) { stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value); } diff --git a/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.h b/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.h index 781e75f0..9dbac2e8 100644 --- a/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.h @@ -8,8 +8,6 @@ namespace localize class DumperIW4 final : public AbstractSingleProgressAssetDumper { public: - explicit DumperIW4(const AssetPool& pool); - void Dump(AssetDumpingContext& context) override; }; } // namespace localize diff --git a/src/ObjWriting/Game/IW4/Maps/AddonMapEntsDumperIW4.cpp b/src/ObjWriting/Game/IW4/Maps/AddonMapEntsDumperIW4.cpp index 11de5e0e..b003c059 100644 --- a/src/ObjWriting/Game/IW4/Maps/AddonMapEntsDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Maps/AddonMapEntsDumperIW4.cpp @@ -7,11 +7,6 @@ using namespace IW4; namespace addon_map_ents { - DumperIW4::DumperIW4(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* addonMapEnts = asset.Asset(); diff --git a/src/ObjWriting/Game/IW4/Maps/AddonMapEntsDumperIW4.h b/src/ObjWriting/Game/IW4/Maps/AddonMapEntsDumperIW4.h index 9e3439ea..54906b97 100644 --- a/src/ObjWriting/Game/IW4/Maps/AddonMapEntsDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Maps/AddonMapEntsDumperIW4.h @@ -7,9 +7,6 @@ namespace addon_map_ents { class DumperIW4 final : public AbstractAssetDumper { - public: - explicit DumperIW4(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW4/Material/MaterialConstantZoneStateIW4.cpp b/src/ObjWriting/Game/IW4/Material/MaterialConstantZoneStateIW4.cpp index 0a77207e..391beda2 100644 --- a/src/ObjWriting/Game/IW4/Material/MaterialConstantZoneStateIW4.cpp +++ b/src/ObjWriting/Game/IW4/Material/MaterialConstantZoneStateIW4.cpp @@ -1,7 +1,6 @@ #include "MaterialConstantZoneStateIW4.h" #include "Game/IW4/CommonIW4.h" -#include "Game/IW4/GameAssetPoolIW4.h" #include "Game/IW4/GameIW4.h" #include "ObjWriting.h" #include "Zone/ZoneRegistry.h" @@ -205,18 +204,14 @@ namespace IW4 { for (const auto* zone : ZoneRegistry::GetRegistryForGame(GameId::IW4)->Zones()) { - const auto* assetPools = dynamic_cast(zone->m_pools.get()); - if (!assetPools) - return; - - for (const auto* vertexShaderAsset : *assetPools->m_material_vertex_shader) + for (const auto* vertexShaderAsset : zone->m_pools.PoolAssets()) { const auto* vertexShader = vertexShaderAsset->Asset(); if (ShouldDumpFromStruct(vertexShader)) ExtractNamesFromShader(vertexShader->prog.loadDef.program, static_cast(vertexShader->prog.loadDef.programSize) * sizeof(uint32_t)); } - for (const auto* pixelShaderAsset : *assetPools->m_material_pixel_shader) + for (const auto* pixelShaderAsset : zone->m_pools.PoolAssets()) { const auto* pixelShader = pixelShaderAsset->Asset(); if (ShouldDumpFromStruct(pixelShader)) diff --git a/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.cpp b/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.cpp index 2a2a8e37..1d37b223 100644 --- a/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.cpp @@ -1109,11 +1109,6 @@ namespace namespace material { - DecompilingGdtDumperIW4::DecompilingGdtDumperIW4(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DecompilingGdtDumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { if (!context.m_gdt) diff --git a/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.h b/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.h index f66ad842..9d031313 100644 --- a/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.h @@ -7,9 +7,6 @@ namespace material { class DecompilingGdtDumperIW4 final : public AbstractAssetDumper { - public: - explicit DecompilingGdtDumperIW4(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.cpp b/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.cpp index e25e983a..14b1a316 100644 --- a/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.cpp @@ -1,6 +1,5 @@ #include "MenuDumperIW4.h" -#include "Game/IW4/GameAssetPoolIW4.h" #include "MenuListDumperIW4.h" #include "MenuWriterIW4.h" #include "ObjWriting.h" @@ -25,11 +24,6 @@ namespace namespace menu { - MenuDumperIW4::MenuDumperIW4(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void MenuDumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* menu = asset.Asset(); @@ -38,8 +32,8 @@ namespace menu if (!ObjWriting::ShouldHandleAssetType(ASSET_TYPE_MENULIST)) { // Make sure menu paths based on menu lists are created - const auto* gameAssetPool = dynamic_cast(asset.m_zone->m_pools.get()); - for (auto* menuListAsset : *gameAssetPool->m_menu_list) + auto menuListAssets = context.m_zone.m_pools.PoolAssets(); + for (auto* menuListAsset : menuListAssets) CreateDumpingStateForMenuListIW4(zoneState, menuListAsset->Asset()); } diff --git a/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.h b/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.h index 91e452ab..7bf9898c 100644 --- a/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.h @@ -7,9 +7,6 @@ namespace menu { class MenuDumperIW4 final : public AbstractAssetDumper { - public: - explicit MenuDumperIW4(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.cpp b/src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.cpp index 217a3c3f..0bf8faff 100644 --- a/src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.cpp @@ -147,11 +147,6 @@ namespace menu } } - MenuListDumperIW4::MenuListDumperIW4(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void MenuListDumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* menuList = asset.Asset(); @@ -178,7 +173,8 @@ namespace menu { auto* zoneState = context.GetZoneAssetDumperState(); - for (const auto* asset : m_pool) + auto menuListAssets = context.m_zone.m_pools.PoolAssets(); + for (const auto* asset : menuListAssets) CreateDumpingStateForMenuListIW4(zoneState, asset->Asset()); AbstractAssetDumper::Dump(context); diff --git a/src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.h b/src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.h index 93610331..b8fcc285 100644 --- a/src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.h @@ -11,8 +11,6 @@ namespace menu class MenuListDumperIW4 final : public AbstractAssetDumper { public: - explicit MenuListDumperIW4(const AssetPool& pool); - void Dump(AssetDumpingContext& context) override; protected: diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index 73d5b2d1..8ae26e8e 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -1,6 +1,5 @@ #include "ObjWriterIW4.h" -#include "Game/IW4/GameAssetPoolIW4.h" #include "Game/IW4/Material/MaterialJsonDumperIW4.h" #include "Game/IW4/XModel/XModelDumperIW4.h" #include "Image/ImageDumperIW4.h" @@ -11,7 +10,6 @@ #include "Material/MaterialDecompilingDumperIW4.h" #include "Menu/MenuDumperIW4.h" #include "Menu/MenuListDumperIW4.h" -#include "ObjWriting.h" #include "PhysCollmap/PhysCollmapDumperIW4.h" #include "PhysPreset/PhysPresetInfoStringDumperIW4.h" #include "RawFile/RawFileDumperIW4.h" @@ -28,69 +26,44 @@ using namespace IW4; -bool ObjWriter::DumpZone(AssetDumpingContext& context) const +void ObjWriter::RegisterAssetDumpers(AssetDumpingContext& context) { -#define REGISTER_DUMPER(dumperType, poolName) \ - if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(dumperType::AssetType_t::EnumEntry)) \ - { \ - dumpers.emplace_back(std::make_unique(*assetPools->poolName)); \ - } - - const auto* assetPools = dynamic_cast(context.m_zone.m_pools.get()); - std::vector> dumpers; - - REGISTER_DUMPER(phys_preset::InfoStringDumperIW4, m_phys_preset) - REGISTER_DUMPER(phys_collmap::DumperIW4, m_phys_collmap) - // REGISTER_DUMPER(AssetDumperXAnimParts, m_xanim_parts) - REGISTER_DUMPER(xmodel::DumperIW4, m_xmodel) - REGISTER_DUMPER(material::JsonDumperIW4, m_material) + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + // REGISTER_DUMPER(AssetDumperXAnimParts) + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); #ifdef EXPERIMENTAL_MATERIAL_COMPILATION - DUMP_ASSET_POOL(material::DecompilingGdtDumperIW4, m_material) + RegisterAssetDumper(std::make_unique()); #endif - REGISTER_DUMPER(shader::PixelShaderDumperIW4, m_material_pixel_shader) - REGISTER_DUMPER(shader::VertexShaderDumperIW4, m_material_vertex_shader) - REGISTER_DUMPER(techset::DumperIW4, m_technique_set) - REGISTER_DUMPER(image::DumperIW4, m_image) - // REGISTER_DUMPER(AssetDumpersnd_alias_list_t, m_sound) - REGISTER_DUMPER(sound_curve::DumperIW4, m_sound_curve) - REGISTER_DUMPER(sound::LoadedSoundDumperIW4, m_loaded_sound) - // REGISTER_DUMPER(AssetDumperClipMap, m_clip_map) - // REGISTER_DUMPER(AssetDumperComWorld, m_com_world) - // REGISTER_DUMPER(AssetDumperGameWorldSp, m_game_world_sp) - // REGISTER_DUMPER(AssetDumperGameWorldMp, m_game_world_mp) - // REGISTER_DUMPER(AssetDumperMapEnts, m_map_ents) - // REGISTER_DUMPER(AssetDumperFxWorld, m_fx_world) - // REGISTER_DUMPER(AssetDumperGfxWorld, m_gfx_world) - REGISTER_DUMPER(light_def::DumperIW4, m_gfx_light_def) - // REGISTER_DUMPER(AssetDumperFont_s, m_font) - REGISTER_DUMPER(menu::MenuListDumperIW4, m_menu_list) - REGISTER_DUMPER(menu::MenuDumperIW4, m_menu_def) - REGISTER_DUMPER(localize::DumperIW4, m_localize) - REGISTER_DUMPER(weapon::DumperIW4, m_weapon) - // REGISTER_DUMPER(AssetDumperSndDriverGlobals, m_snd_driver_globals) - // REGISTER_DUMPER(AssetDumperFxEffectDef, m_fx) - // REGISTER_DUMPER(AssetDumperFxImpactTable, m_fx_impact_table) - REGISTER_DUMPER(raw_file::DumperIW4, m_raw_file) - REGISTER_DUMPER(string_table::DumperIW4, m_string_table) - REGISTER_DUMPER(leaderboard::JsonDumperIW4, m_leaderboard) - REGISTER_DUMPER(structured_data_def::DumperIW4, m_structed_data_def_set) - REGISTER_DUMPER(tracer::DumperIW4, m_tracer) - REGISTER_DUMPER(vehicle::DumperIW4, m_vehicle) - REGISTER_DUMPER(addon_map_ents::DumperIW4, m_addon_map_ents) - - if (context.ShouldTrackProgress()) - { - size_t totalProgress = 0uz; - for (const auto& dumper : dumpers) - totalProgress += dumper->GetProgressTotalCount(); - - context.SetTotalProgress(totalProgress); - } - - for (const auto& dumper : dumpers) - dumper->Dump(context); - - return true; - -#undef REGISTER_DUMPER + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + // REGISTER_DUMPER(AssetDumpersnd_alias_list_t) + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + // REGISTER_DUMPER(AssetDumperClipMap) + // REGISTER_DUMPER(AssetDumperComWorld) + // REGISTER_DUMPER(AssetDumperGameWorldSp) + // REGISTER_DUMPER(AssetDumperGameWorldMp) + // REGISTER_DUMPER(AssetDumperMapEnts) + // REGISTER_DUMPER(AssetDumperFxWorld) + // REGISTER_DUMPER(AssetDumperGfxWorld) + RegisterAssetDumper(std::make_unique()); + // REGISTER_DUMPER(AssetDumperFont_s) + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + // REGISTER_DUMPER(AssetDumperSndDriverGlobals) + // REGISTER_DUMPER(AssetDumperFxEffectDef) + // REGISTER_DUMPER(AssetDumperFxImpactTable) + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); } diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.h b/src/ObjWriting/Game/IW4/ObjWriterIW4.h index 4519fc44..6494435c 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.h +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.h @@ -1,11 +1,12 @@ #pragma once -#include "IObjWriter.h" + +#include "ObjWriter.h" namespace IW4 { class ObjWriter final : public IObjWriter { - public: - bool DumpZone(AssetDumpingContext& context) const override; + protected: + void RegisterAssetDumpers(AssetDumpingContext& context) override; }; } // namespace IW4 diff --git a/src/ObjWriting/Game/IW4/PhysCollmap/PhysCollmapDumperIW4.cpp b/src/ObjWriting/Game/IW4/PhysCollmap/PhysCollmapDumperIW4.cpp index 2cf39ef3..03eb9b55 100644 --- a/src/ObjWriting/Game/IW4/PhysCollmap/PhysCollmapDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/PhysCollmap/PhysCollmapDumperIW4.cpp @@ -10,11 +10,6 @@ using namespace IW4; namespace phys_collmap { - DumperIW4::DumperIW4(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* physCollmap = asset.Asset(); diff --git a/src/ObjWriting/Game/IW4/PhysCollmap/PhysCollmapDumperIW4.h b/src/ObjWriting/Game/IW4/PhysCollmap/PhysCollmapDumperIW4.h index c3cb8061..9acd1d05 100644 --- a/src/ObjWriting/Game/IW4/PhysCollmap/PhysCollmapDumperIW4.h +++ b/src/ObjWriting/Game/IW4/PhysCollmap/PhysCollmapDumperIW4.h @@ -7,9 +7,6 @@ namespace phys_collmap { class DumperIW4 final : public AbstractAssetDumper { - public: - explicit DumperIW4(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.cpp b/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.cpp index c60e38a8..158ac925 100644 --- a/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.cpp @@ -80,11 +80,6 @@ namespace namespace phys_preset { - InfoStringDumperIW4::InfoStringDumperIW4(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void InfoStringDumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { // Only dump raw when no gdt available diff --git a/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.h b/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.h index 17457ce9..028f8449 100644 --- a/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.h +++ b/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.h @@ -7,9 +7,6 @@ namespace phys_preset { class InfoStringDumperIW4 final : public AbstractAssetDumper { - public: - explicit InfoStringDumperIW4(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.cpp b/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.cpp index 39109672..77ef6c2c 100644 --- a/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.cpp @@ -10,11 +10,6 @@ using namespace IW4; namespace raw_file { - DumperIW4::DumperIW4(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* rawFile = asset.Asset(); diff --git a/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.h b/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.h index 5a3b7559..e84a68ba 100644 --- a/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.h +++ b/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.h @@ -7,9 +7,6 @@ namespace raw_file { class DumperIW4 final : public AbstractAssetDumper { - public: - explicit DumperIW4(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.cpp b/src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.cpp index 9ef1571b..17a779ae 100644 --- a/src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.cpp @@ -6,11 +6,6 @@ using namespace IW4; namespace shader { - PixelShaderDumperIW4::PixelShaderDumperIW4(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void PixelShaderDumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* pixelShader = asset.Asset(); diff --git a/src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.h b/src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.h index 0c1e5339..5e91c95c 100644 --- a/src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.h @@ -7,9 +7,6 @@ namespace shader { class PixelShaderDumperIW4 final : public AbstractAssetDumper { - public: - explicit PixelShaderDumperIW4(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.cpp b/src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.cpp index d5a66fcb..9531f0e6 100644 --- a/src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.cpp @@ -6,11 +6,6 @@ using namespace IW4; namespace shader { - VertexShaderDumperIW4::VertexShaderDumperIW4(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void VertexShaderDumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* vertexShader = asset.Asset(); diff --git a/src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.h b/src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.h index 5702e94d..2b817b5d 100644 --- a/src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.h @@ -7,9 +7,6 @@ namespace shader { class VertexShaderDumperIW4 final : public AbstractAssetDumper { - public: - explicit VertexShaderDumperIW4(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.cpp b/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.cpp index e0d2ed2d..8b51fe2b 100644 --- a/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.cpp @@ -25,11 +25,6 @@ namespace namespace sound { - LoadedSoundDumperIW4::LoadedSoundDumperIW4(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void LoadedSoundDumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* loadedSound = asset.Asset(); diff --git a/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.h b/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.h index fa28defe..c3471be9 100644 --- a/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.h @@ -7,9 +7,6 @@ namespace sound { class LoadedSoundDumperIW4 final : public AbstractAssetDumper { - public: - explicit LoadedSoundDumperIW4(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.cpp b/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.cpp index 8a6ab9a2..39ab49fc 100644 --- a/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.cpp @@ -7,11 +7,6 @@ using namespace IW4; namespace sound_curve { - DumperIW4::DumperIW4(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* sndCurve = asset.Asset(); diff --git a/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.h b/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.h index 0c4358d5..6dfc4253 100644 --- a/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.h @@ -7,9 +7,6 @@ namespace sound_curve { class DumperIW4 final : public AbstractAssetDumper { - public: - explicit DumperIW4(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW4/StringTable/StringTableDumperIW4.cpp b/src/ObjWriting/Game/IW4/StringTable/StringTableDumperIW4.cpp index 27a92ecb..72be67c9 100644 --- a/src/ObjWriting/Game/IW4/StringTable/StringTableDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/StringTable/StringTableDumperIW4.cpp @@ -6,11 +6,6 @@ using namespace IW4; namespace string_table { - DumperIW4::DumperIW4(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* stringTable = asset.Asset(); diff --git a/src/ObjWriting/Game/IW4/StringTable/StringTableDumperIW4.h b/src/ObjWriting/Game/IW4/StringTable/StringTableDumperIW4.h index 8abb9057..2f3be91b 100644 --- a/src/ObjWriting/Game/IW4/StringTable/StringTableDumperIW4.h +++ b/src/ObjWriting/Game/IW4/StringTable/StringTableDumperIW4.h @@ -7,9 +7,6 @@ namespace string_table { class DumperIW4 final : public AbstractAssetDumper { - public: - explicit DumperIW4(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.cpp b/src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.cpp index 10665f83..4bc84e6a 100644 --- a/src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.cpp @@ -187,11 +187,6 @@ namespace namespace structured_data_def { - DumperIW4::DumperIW4(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* set = asset.Asset(); diff --git a/src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.h b/src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.h index 47b14f89..96810268 100644 --- a/src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.h +++ b/src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.h @@ -7,9 +7,6 @@ namespace structured_data_def { class DumperIW4 final : public AbstractAssetDumper { - public: - explicit DumperIW4(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.cpp b/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.cpp index 9885247e..eb4554af 100644 --- a/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.cpp @@ -250,7 +250,8 @@ namespace if (vertexShader->name[0] == ',') { - const auto loadedVertexShaderFromOtherZone = GlobalAssetPool::GetAssetByName(&vertexShader->name[1]); + const auto loadedVertexShaderFromOtherZone = + GameGlobalAssetPools::GetGlobalPoolsForGame(GameId::IW4)->GetAsset(&vertexShader->name[1]); if (loadedVertexShaderFromOtherZone == nullptr) { @@ -305,7 +306,8 @@ namespace if (pixelShader->name[0] == ',') { - const auto loadedPixelShaderFromOtherZone = GlobalAssetPool::GetAssetByName(&pixelShader->name[1]); + const auto loadedPixelShaderFromOtherZone = + GameGlobalAssetPools::GetGlobalPoolsForGame(GameId::IW4)->GetAsset(&pixelShader->name[1]); if (loadedPixelShaderFromOtherZone == nullptr) { @@ -377,7 +379,8 @@ namespace if (vertexDecl->name && vertexDecl->name[0] == ',') { - const auto loadedVertexDeclFromOtherZone = GlobalAssetPool::GetAssetByName(&vertexDecl->name[1]); + const auto loadedVertexDeclFromOtherZone = + GameGlobalAssetPools::GetGlobalPoolsForGame(GameId::IW4)->GetAsset(&vertexDecl->name[1]); if (loadedVertexDeclFromOtherZone == nullptr) { @@ -488,11 +491,6 @@ namespace namespace techset { - DumperIW4::DumperIW4(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* techniqueSet = asset.Asset(); diff --git a/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.h b/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.h index ea8f076f..17daac8e 100644 --- a/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.h @@ -7,9 +7,6 @@ namespace techset { class DumperIW4 final : public AbstractAssetDumper { - public: - explicit DumperIW4(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.cpp b/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.cpp index 63076021..339c26b4 100644 --- a/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.cpp @@ -52,11 +52,6 @@ namespace namespace tracer { - DumperIW4::DumperIW4(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { // Only dump raw when no gdt available diff --git a/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.h b/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.h index 708d7c76..81569b0e 100644 --- a/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.h @@ -7,9 +7,6 @@ namespace tracer { class DumperIW4 final : public AbstractAssetDumper { - public: - explicit DumperIW4(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW4/Vehicle/VehicleDumperIW4.cpp b/src/ObjWriting/Game/IW4/Vehicle/VehicleDumperIW4.cpp index 5830391f..0561b43a 100644 --- a/src/ObjWriting/Game/IW4/Vehicle/VehicleDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Vehicle/VehicleDumperIW4.cpp @@ -93,11 +93,6 @@ namespace namespace vehicle { - DumperIW4::DumperIW4(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { // Only dump raw when no gdt available diff --git a/src/ObjWriting/Game/IW4/Vehicle/VehicleDumperIW4.h b/src/ObjWriting/Game/IW4/Vehicle/VehicleDumperIW4.h index 1af2dcaa..0de96a21 100644 --- a/src/ObjWriting/Game/IW4/Vehicle/VehicleDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Vehicle/VehicleDumperIW4.h @@ -7,9 +7,6 @@ namespace vehicle { class DumperIW4 final : public AbstractAssetDumper { - public: - explicit DumperIW4(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW4/Weapon/WeaponDumperIW4.cpp b/src/ObjWriting/Game/IW4/Weapon/WeaponDumperIW4.cpp index 6ca11889..8c5c9ebc 100644 --- a/src/ObjWriting/Game/IW4/Weapon/WeaponDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Weapon/WeaponDumperIW4.cpp @@ -405,11 +405,6 @@ namespace namespace weapon { - DumperIW4::DumperIW4(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { // Only dump raw when no gdt available diff --git a/src/ObjWriting/Game/IW4/Weapon/WeaponDumperIW4.h b/src/ObjWriting/Game/IW4/Weapon/WeaponDumperIW4.h index a97ff280..24614d3b 100644 --- a/src/ObjWriting/Game/IW4/Weapon/WeaponDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Weapon/WeaponDumperIW4.h @@ -7,9 +7,6 @@ namespace weapon { class DumperIW4 final : public AbstractAssetDumper { - public: - explicit DumperIW4(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.cpp b/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.cpp index 74995f30..123208f5 100644 --- a/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.cpp @@ -62,8 +62,7 @@ namespace namespace image { - DumperIW5::DumperIW5(const AssetPool& pool) - : AbstractAssetDumper(pool) + DumperIW5::DumperIW5() { switch (ObjWriting::Configuration.ImageOutputFormat) { diff --git a/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.h b/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.h index 064991cc..4d481d3f 100644 --- a/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.h +++ b/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.h @@ -11,7 +11,7 @@ namespace image class DumperIW5 final : public AbstractAssetDumper { public: - explicit DumperIW5(const AssetPool& pool); + DumperIW5(); protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; diff --git a/src/ObjWriting/Game/IW5/Leaderboard/LeaderboardJsonDumperIW5.cpp b/src/ObjWriting/Game/IW5/Leaderboard/LeaderboardJsonDumperIW5.cpp index 08586629..798e0e9d 100644 --- a/src/ObjWriting/Game/IW5/Leaderboard/LeaderboardJsonDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Leaderboard/LeaderboardJsonDumperIW5.cpp @@ -94,11 +94,6 @@ namespace namespace leaderboard { - JsonDumperIW5::JsonDumperIW5(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void JsonDumperIW5::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAsset(asset.m_name)); diff --git a/src/ObjWriting/Game/IW5/Leaderboard/LeaderboardJsonDumperIW5.h b/src/ObjWriting/Game/IW5/Leaderboard/LeaderboardJsonDumperIW5.h index 04d07ecf..49b09851 100644 --- a/src/ObjWriting/Game/IW5/Leaderboard/LeaderboardJsonDumperIW5.h +++ b/src/ObjWriting/Game/IW5/Leaderboard/LeaderboardJsonDumperIW5.h @@ -7,9 +7,6 @@ namespace leaderboard { class JsonDumperIW5 final : public AbstractAssetDumper { - public: - explicit JsonDumperIW5(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.cpp b/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.cpp index 55894aed..92590a1a 100644 --- a/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.cpp @@ -5,20 +5,15 @@ #include "Utils/Logging/Log.h" #include -#include using namespace IW5; namespace localize { - DumperIW5::DumperIW5(const AssetPool& pool) - : AbstractSingleProgressAssetDumper(pool) - { - } - void DumperIW5::Dump(AssetDumpingContext& context) { - if (m_pool.m_asset_lookup.empty()) + auto localizeAssets = context.m_zone.m_pools.PoolAssets(); + if (localizeAssets.empty()) return; const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language); @@ -35,7 +30,7 @@ namespace localize stringFileDumper.SetNotes(""); - for (const auto* localizeEntry : m_pool) + for (const auto* localizeEntry : localizeAssets) { stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value); } diff --git a/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.h b/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.h index 427ca8dd..bf0e873a 100644 --- a/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.h +++ b/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.h @@ -8,8 +8,6 @@ namespace localize class DumperIW5 final : public AbstractSingleProgressAssetDumper { public: - explicit DumperIW5(const AssetPool& pool); - void Dump(AssetDumpingContext& context) override; }; } // namespace localize diff --git a/src/ObjWriting/Game/IW5/Maps/AddonMapEntsDumperIW5.cpp b/src/ObjWriting/Game/IW5/Maps/AddonMapEntsDumperIW5.cpp index 6c2ba3a3..6508f96b 100644 --- a/src/ObjWriting/Game/IW5/Maps/AddonMapEntsDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Maps/AddonMapEntsDumperIW5.cpp @@ -7,11 +7,6 @@ using namespace IW5; namespace addon_map_ents { - DumperIW5::DumperIW5(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperIW5::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* addonMapEnts = asset.Asset(); diff --git a/src/ObjWriting/Game/IW5/Maps/AddonMapEntsDumperIW5.h b/src/ObjWriting/Game/IW5/Maps/AddonMapEntsDumperIW5.h index d7a8d226..edcbb479 100644 --- a/src/ObjWriting/Game/IW5/Maps/AddonMapEntsDumperIW5.h +++ b/src/ObjWriting/Game/IW5/Maps/AddonMapEntsDumperIW5.h @@ -7,9 +7,6 @@ namespace addon_map_ents { class DumperIW5 final : public AbstractAssetDumper { - public: - explicit DumperIW5(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW5/Material/MaterialConstantZoneStateIW5.cpp b/src/ObjWriting/Game/IW5/Material/MaterialConstantZoneStateIW5.cpp index 486ec6d5..ba5537ee 100644 --- a/src/ObjWriting/Game/IW5/Material/MaterialConstantZoneStateIW5.cpp +++ b/src/ObjWriting/Game/IW5/Material/MaterialConstantZoneStateIW5.cpp @@ -1,7 +1,6 @@ #include "MaterialConstantZoneStateIW5.h" #include "Game/IW5/CommonIW5.h" -#include "Game/IW5/GameAssetPoolIW5.h" #include "Game/IW5/GameIW5.h" #include "ObjWriting.h" #include "Zone/ZoneRegistry.h" @@ -205,18 +204,14 @@ namespace IW5 { for (const auto* zone : ZoneRegistry::GetRegistryForGame(GameId::IW5)->Zones()) { - const auto* iw5AssetPools = dynamic_cast(zone->m_pools.get()); - if (!iw5AssetPools) - return; - - for (const auto* vertexShaderAsset : *iw5AssetPools->m_material_vertex_shader) + for (const auto* vertexShaderAsset : zone->m_pools.PoolAssets()) { const auto* vertexShader = vertexShaderAsset->Asset(); if (ShouldDumpFromStruct(vertexShader)) ExtractNamesFromShader(vertexShader->prog.loadDef.program, static_cast(vertexShader->prog.loadDef.programSize) * sizeof(uint32_t)); } - for (const auto* pixelShaderAsset : *iw5AssetPools->m_material_pixel_shader) + for (const auto* pixelShaderAsset : zone->m_pools.PoolAssets()) { const auto* pixelShader = pixelShaderAsset->Asset(); if (ShouldDumpFromStruct(pixelShader)) diff --git a/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.cpp b/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.cpp index 986ee1cc..bbf6c44d 100644 --- a/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.cpp @@ -1,7 +1,5 @@ #include "MenuDumperIW5.h" -#include "Game/IW5/GameAssetPoolIW5.h" -#include "Game/IW5/Menu/MenuDumperIW5.h" #include "MenuWriterIW5.h" #include "ObjWriting.h" @@ -18,8 +16,8 @@ namespace const MenuList* GetParentMenuList(const XAssetInfo& asset) { const auto* menu = asset.Asset(); - const auto* gameAssetPool = dynamic_cast(asset.m_zone->m_pools.get()); - for (const auto* menuList : *gameAssetPool->m_menu_list) + auto zoneMenuListPool = asset.m_zone->m_pools.PoolAssets(); + for (const auto* menuList : zoneMenuListPool) { const auto* menuListAsset = menuList->Asset(); @@ -51,11 +49,6 @@ namespace namespace menu { - MenuDumperIW5::MenuDumperIW5(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void MenuDumperIW5::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* menu = asset.Asset(); diff --git a/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.h b/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.h index e996e47d..f3d00967 100644 --- a/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.h +++ b/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.h @@ -7,9 +7,6 @@ namespace menu { class MenuDumperIW5 final : public AbstractAssetDumper { - public: - explicit MenuDumperIW5(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.cpp b/src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.cpp index 55e61eb1..20d333aa 100644 --- a/src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.cpp @@ -106,11 +106,6 @@ namespace namespace menu { - MenuListDumperIW5::MenuListDumperIW5(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void MenuListDumperIW5::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* menuList = asset.Asset(); diff --git a/src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.h b/src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.h index 7b87deda..1ec80a50 100644 --- a/src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.h +++ b/src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.h @@ -7,9 +7,6 @@ namespace menu { class MenuListDumperIW5 final : public AbstractAssetDumper { - public: - explicit MenuListDumperIW5(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp index e7ca7a8f..9e99e403 100644 --- a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp +++ b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp @@ -1,6 +1,5 @@ #include "ObjWriterIW5.h" -#include "Game/IW5/GameAssetPoolIW5.h" #include "Game/IW5/Material/MaterialJsonDumperIW5.h" #include "Game/IW5/XModel/XModelDumperIW5.h" #include "Image/ImageDumperIW5.h" @@ -9,7 +8,6 @@ #include "Maps/AddonMapEntsDumperIW5.h" #include "Menu/MenuDumperIW5.h" #include "Menu/MenuListDumperIW5.h" -#include "ObjWriting.h" #include "RawFile/RawFileDumperIW5.h" #include "Script/ScriptDumperIW5.h" #include "Sound/LoadedSoundDumperIW5.h" @@ -19,71 +17,46 @@ using namespace IW5; -bool ObjWriter::DumpZone(AssetDumpingContext& context) const +void ObjWriter::RegisterAssetDumpers(AssetDumpingContext& context) { -#define REGISTER_DUMPER(dumperType, poolName) \ - if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(dumperType::AssetType_t::EnumEntry)) \ - { \ - dumpers.emplace_back(std::make_unique(*assetPools->poolName)); \ - } - - const auto* assetPools = dynamic_cast(context.m_zone.m_pools.get()); - std::vector> dumpers; - - // REGISTER_DUMPER(AssetDumperPhysPreset, m_phys_preset) - // REGISTER_DUMPER(AssetDumperPhysCollmap, m_phys_collmap) - // REGISTER_DUMPER(AssetDumperXAnimParts, m_xanim_parts) - // REGISTER_DUMPER(AssetDumperXModelSurfs, m_xmodel_surfs) - REGISTER_DUMPER(xmodel::DumperIW5, m_xmodel) - REGISTER_DUMPER(material::JsonDumperIW5, m_material) - // REGISTER_DUMPER(AssetDumperMaterialPixelShader, m_material_pixel_shader) - // REGISTER_DUMPER(AssetDumperMaterialVertexShader, m_material_vertex_shader) - // REGISTER_DUMPER(AssetDumperMaterialVertexDeclaration, m_material_vertex_decl) - // REGISTER_DUMPER(AssetDumperMaterialTechniqueSet, m_technique_set) - REGISTER_DUMPER(image::DumperIW5, m_image) - // REGISTER_DUMPER(AssetDumpersnd_alias_list_t, m_sound) - // REGISTER_DUMPER(AssetDumperSndCurve, m_sound_curve) - REGISTER_DUMPER(sound::LoadedSoundDumperIW5, m_loaded_sound) - // REGISTER_DUMPER(AssetDumperclipMap_t, m_clip_map) - // REGISTER_DUMPER(AssetDumperComWorld, m_com_world) - // REGISTER_DUMPER(AssetDumperGlassWorld, m_glass_world) - // REGISTER_DUMPER(AssetDumperPathData, m_path_data) - // REGISTER_DUMPER(AssetDumperVehicleTrack, m_vehicle_track) - // REGISTER_DUMPER(AssetDumperMapEnts, m_map_ents) - // REGISTER_DUMPER(AssetDumperFxWorld, m_fx_world) - // REGISTER_DUMPER(AssetDumperGfxWorld, m_gfx_world) - // REGISTER_DUMPER(AssetDumperGfxLightDef, m_gfx_light_def) - // REGISTER_DUMPER(AssetDumperFont_s, m_font) - REGISTER_DUMPER(menu::MenuListDumperIW5, m_menu_list) - REGISTER_DUMPER(menu::MenuDumperIW5, m_menu_def) - REGISTER_DUMPER(localize::DumperIW5, m_localize) - REGISTER_DUMPER(attachment::JsonDumperIW5, m_attachment) - REGISTER_DUMPER(weapon::DumperIW5, m_weapon) - // REGISTER_DUMPER(AssetDumperFxEffectDef, m_fx) - // REGISTER_DUMPER(AssetDumperFxImpactTable, m_fx_impact_table) - // REGISTER_DUMPER(AssetDumperSurfaceFxTable, m_surface_fx_table) - REGISTER_DUMPER(raw_file::DumperIW5, m_raw_file) - REGISTER_DUMPER(script::DumperIW5, m_script_file) - REGISTER_DUMPER(string_table::DumperIW5, m_string_table) - REGISTER_DUMPER(leaderboard::JsonDumperIW5, m_leaderboard) - // REGISTER_DUMPER(AssetDumperStructuredDataDefSet, m_structed_data_def_set) - // REGISTER_DUMPER(AssetDumperTracerDef, m_tracer) - // REGISTER_DUMPER(AssetDumperVehicleDef, m_vehicle) - REGISTER_DUMPER(addon_map_ents::DumperIW5, m_addon_map_ents) - - if (context.ShouldTrackProgress()) - { - size_t totalProgress = 0uz; - for (const auto& dumper : dumpers) - totalProgress += dumper->GetProgressTotalCount(); - - context.SetTotalProgress(totalProgress); - } - - for (const auto& dumper : dumpers) - dumper->Dump(context); - - return true; - -#undef REGISTER_DUMPER + // REGISTER_DUMPER(AssetDumperPhysPreset) + // REGISTER_DUMPER(AssetDumperPhysCollmap) + // REGISTER_DUMPER(AssetDumperXAnimParts) + // REGISTER_DUMPER(AssetDumperXModelSurfs) + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + // REGISTER_DUMPER(AssetDumperMaterialPixelShader) + // REGISTER_DUMPER(AssetDumperMaterialVertexShader) + // REGISTER_DUMPER(AssetDumperMaterialVertexDeclaration) + // REGISTER_DUMPER(AssetDumperMaterialTechniqueSet) + RegisterAssetDumper(std::make_unique()); + // REGISTER_DUMPER(AssetDumpersnd_alias_list_t) + // REGISTER_DUMPER(AssetDumperSndCurve) + RegisterAssetDumper(std::make_unique()); + // REGISTER_DUMPER(AssetDumperclipMap_t) + // REGISTER_DUMPER(AssetDumperComWorld) + // REGISTER_DUMPER(AssetDumperGlassWorld) + // REGISTER_DUMPER(AssetDumperPathData) + // REGISTER_DUMPER(AssetDumperVehicleTrack) + // REGISTER_DUMPER(AssetDumperMapEnts) + // REGISTER_DUMPER(AssetDumperFxWorld) + // REGISTER_DUMPER(AssetDumperGfxWorld) + // REGISTER_DUMPER(AssetDumperGfxLightDef) + // REGISTER_DUMPER(AssetDumperFont_s) + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + // REGISTER_DUMPER(AssetDumperFxEffectDef) + // REGISTER_DUMPER(AssetDumperFxImpactTable) + // REGISTER_DUMPER(AssetDumperSurfaceFxTable) + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + // REGISTER_DUMPER(AssetDumperStructuredDataDefSet) + // REGISTER_DUMPER(AssetDumperTracerDef) + // REGISTER_DUMPER(AssetDumperVehicleDef) + RegisterAssetDumper(std::make_unique()); } diff --git a/src/ObjWriting/Game/IW5/ObjWriterIW5.h b/src/ObjWriting/Game/IW5/ObjWriterIW5.h index dd38ba5d..0ae648f7 100644 --- a/src/ObjWriting/Game/IW5/ObjWriterIW5.h +++ b/src/ObjWriting/Game/IW5/ObjWriterIW5.h @@ -1,11 +1,12 @@ #pragma once -#include "IObjWriter.h" + +#include "ObjWriter.h" namespace IW5 { class ObjWriter final : public IObjWriter { public: - bool DumpZone(AssetDumpingContext& context) const override; + void RegisterAssetDumpers(AssetDumpingContext& context) override; }; } // namespace IW5 diff --git a/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.cpp b/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.cpp index 30b9fcfb..4f8ce1c6 100644 --- a/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.cpp @@ -10,11 +10,6 @@ using namespace IW5; namespace raw_file { - DumperIW5::DumperIW5(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperIW5::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* rawFile = asset.Asset(); diff --git a/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.h b/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.h index 1da93e45..7f3ab807 100644 --- a/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.h +++ b/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.h @@ -7,9 +7,6 @@ namespace raw_file { class DumperIW5 final : public AbstractAssetDumper { - public: - explicit DumperIW5(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW5/Script/ScriptDumperIW5.cpp b/src/ObjWriting/Game/IW5/Script/ScriptDumperIW5.cpp index 1fcbf206..d41f7505 100644 --- a/src/ObjWriting/Game/IW5/Script/ScriptDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Script/ScriptDumperIW5.cpp @@ -4,11 +4,6 @@ using namespace IW5; namespace script { - DumperIW5::DumperIW5(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - // See https://github.com/xensik/gsc-tool#file-format for an in-depth explanation about the .gscbin format void DumperIW5::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { diff --git a/src/ObjWriting/Game/IW5/Script/ScriptDumperIW5.h b/src/ObjWriting/Game/IW5/Script/ScriptDumperIW5.h index 920f3733..5b48c6cf 100644 --- a/src/ObjWriting/Game/IW5/Script/ScriptDumperIW5.h +++ b/src/ObjWriting/Game/IW5/Script/ScriptDumperIW5.h @@ -7,9 +7,6 @@ namespace script { class DumperIW5 final : public AbstractAssetDumper { - public: - explicit DumperIW5(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.cpp b/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.cpp index 5a847929..64f9e70c 100644 --- a/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.cpp @@ -25,11 +25,6 @@ namespace namespace sound { - LoadedSoundDumperIW5::LoadedSoundDumperIW5(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void LoadedSoundDumperIW5::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* loadedSound = asset.Asset(); diff --git a/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.h b/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.h index 32350c68..295b8271 100644 --- a/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.h +++ b/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.h @@ -7,9 +7,6 @@ namespace sound { class LoadedSoundDumperIW5 final : public AbstractAssetDumper { - public: - explicit LoadedSoundDumperIW5(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW5/StringTable/StringTableDumperIW5.cpp b/src/ObjWriting/Game/IW5/StringTable/StringTableDumperIW5.cpp index 0b3dfae2..663df17a 100644 --- a/src/ObjWriting/Game/IW5/StringTable/StringTableDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/StringTable/StringTableDumperIW5.cpp @@ -6,11 +6,6 @@ using namespace IW5; namespace string_table { - DumperIW5::DumperIW5(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperIW5::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* stringTable = asset.Asset(); diff --git a/src/ObjWriting/Game/IW5/StringTable/StringTableDumperIW5.h b/src/ObjWriting/Game/IW5/StringTable/StringTableDumperIW5.h index 071a08ee..1cdd171c 100644 --- a/src/ObjWriting/Game/IW5/StringTable/StringTableDumperIW5.h +++ b/src/ObjWriting/Game/IW5/StringTable/StringTableDumperIW5.h @@ -7,9 +7,6 @@ namespace string_table { class DumperIW5 final : public AbstractAssetDumper { - public: - explicit DumperIW5(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW5/Weapon/AttachmentJsonDumperIW5.cpp b/src/ObjWriting/Game/IW5/Weapon/AttachmentJsonDumperIW5.cpp index 79f842c9..6be7b331 100644 --- a/src/ObjWriting/Game/IW5/Weapon/AttachmentJsonDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Weapon/AttachmentJsonDumperIW5.cpp @@ -395,11 +395,6 @@ namespace namespace attachment { - JsonDumperIW5::JsonDumperIW5(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void JsonDumperIW5::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAssetName(asset.m_name)); diff --git a/src/ObjWriting/Game/IW5/Weapon/AttachmentJsonDumperIW5.h b/src/ObjWriting/Game/IW5/Weapon/AttachmentJsonDumperIW5.h index f43204a1..2b8b5058 100644 --- a/src/ObjWriting/Game/IW5/Weapon/AttachmentJsonDumperIW5.h +++ b/src/ObjWriting/Game/IW5/Weapon/AttachmentJsonDumperIW5.h @@ -7,9 +7,6 @@ namespace attachment { class JsonDumperIW5 final : public AbstractAssetDumper { - public: - explicit JsonDumperIW5(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/IW5/Weapon/WeaponDumperIW5.cpp b/src/ObjWriting/Game/IW5/Weapon/WeaponDumperIW5.cpp index ed3f984d..322eff0a 100644 --- a/src/ObjWriting/Game/IW5/Weapon/WeaponDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Weapon/WeaponDumperIW5.cpp @@ -733,11 +733,6 @@ namespace namespace weapon { - DumperIW5::DumperIW5(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperIW5::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { // TODO: only dump infostring fields when non-default diff --git a/src/ObjWriting/Game/IW5/Weapon/WeaponDumperIW5.h b/src/ObjWriting/Game/IW5/Weapon/WeaponDumperIW5.h index 5772e5fc..3ab5ddde 100644 --- a/src/ObjWriting/Game/IW5/Weapon/WeaponDumperIW5.h +++ b/src/ObjWriting/Game/IW5/Weapon/WeaponDumperIW5.h @@ -7,9 +7,6 @@ namespace weapon { class DumperIW5 final : public AbstractAssetDumper { - public: - explicit DumperIW5(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/T5/Image/ImageDumperT5.cpp b/src/ObjWriting/Game/T5/Image/ImageDumperT5.cpp index 2f0e0649..e541e579 100644 --- a/src/ObjWriting/Game/T5/Image/ImageDumperT5.cpp +++ b/src/ObjWriting/Game/T5/Image/ImageDumperT5.cpp @@ -61,8 +61,7 @@ namespace namespace image { - DumperT5::DumperT5(const AssetPool& pool) - : AbstractAssetDumper(pool) + DumperT5::DumperT5() { switch (ObjWriting::Configuration.ImageOutputFormat) { diff --git a/src/ObjWriting/Game/T5/Image/ImageDumperT5.h b/src/ObjWriting/Game/T5/Image/ImageDumperT5.h index 43cb41df..6f8e2d65 100644 --- a/src/ObjWriting/Game/T5/Image/ImageDumperT5.h +++ b/src/ObjWriting/Game/T5/Image/ImageDumperT5.h @@ -11,7 +11,7 @@ namespace image class DumperT5 final : public AbstractAssetDumper { public: - explicit DumperT5(const AssetPool& pool); + DumperT5(); protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; diff --git a/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.cpp b/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.cpp index 5edb14a4..bac9a9ad 100644 --- a/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.cpp +++ b/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.cpp @@ -5,20 +5,15 @@ #include "Utils/Logging/Log.h" #include -#include using namespace T5; namespace localize { - DumperT5::DumperT5(const AssetPool& pool) - : AbstractSingleProgressAssetDumper(pool) - { - } - void DumperT5::Dump(AssetDumpingContext& context) { - if (m_pool.m_asset_lookup.empty()) + auto localizeAssets = context.m_zone.m_pools.PoolAssets(); + if (localizeAssets.empty()) return; const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language); @@ -35,7 +30,7 @@ namespace localize stringFileDumper.SetNotes(""); - for (const auto* localizeEntry : m_pool) + for (const auto* localizeEntry : localizeAssets) { stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value); } diff --git a/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.h b/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.h index 5dfac74c..1d959f5c 100644 --- a/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.h +++ b/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.h @@ -8,8 +8,6 @@ namespace localize class DumperT5 final : public AbstractSingleProgressAssetDumper { public: - explicit DumperT5(const AssetPool& pool); - void Dump(AssetDumpingContext& context) override; }; } // namespace localize diff --git a/src/ObjWriting/Game/T5/Material/MaterialConstantZoneStateT5.cpp b/src/ObjWriting/Game/T5/Material/MaterialConstantZoneStateT5.cpp index 44f3f87c..3293c570 100644 --- a/src/ObjWriting/Game/T5/Material/MaterialConstantZoneStateT5.cpp +++ b/src/ObjWriting/Game/T5/Material/MaterialConstantZoneStateT5.cpp @@ -1,7 +1,6 @@ #include "MaterialConstantZoneStateT5.h" #include "Game/T5/CommonT5.h" -#include "Game/T5/GameAssetPoolT5.h" #include "Game/T5/GameT5.h" #include "ObjWriting.h" #include "Zone/ZoneRegistry.h" @@ -479,11 +478,7 @@ namespace T5 { for (const auto* zone : ZoneRegistry::GetRegistryForGame(GameId::T5)->Zones()) { - const auto* assetPools = dynamic_cast(zone->m_pools.get()); - if (!assetPools) - return; - - for (const auto* techniqueSetInfo : *assetPools->m_technique_set) + for (const auto* techniqueSetInfo : zone->m_pools.PoolAssets()) { const auto* techniqueSet = techniqueSetInfo->Asset(); diff --git a/src/ObjWriting/Game/T5/ObjWriterT5.cpp b/src/ObjWriting/Game/T5/ObjWriterT5.cpp index 78618c26..99549385 100644 --- a/src/ObjWriting/Game/T5/ObjWriterT5.cpp +++ b/src/ObjWriting/Game/T5/ObjWriterT5.cpp @@ -1,36 +1,25 @@ #include "ObjWriterT5.h" -#include "Game/T5/GameAssetPoolT5.h" #include "Game/T5/Material/MaterialJsonDumperT5.h" #include "Game/T5/Techset/TechsetDumperT5.h" #include "Game/T5/XModel/XModelDumperT5.h" #include "Image/ImageDumperT5.h" #include "Localize/LocalizeDumperT5.h" -#include "ObjWriting.h" #include "RawFile/RawFileDumperT5.h" #include "StringTable/StringTableDumperT5.h" using namespace T5; -bool ObjWriter::DumpZone(AssetDumpingContext& context) const +void ObjWriter::RegisterAssetDumpers(AssetDumpingContext& context) { -#define REGISTER_DUMPER(dumperType, poolName) \ - if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(dumperType::AssetType_t::EnumEntry)) \ - { \ - dumpers.emplace_back(std::make_unique(*assetPools->poolName)); \ - } - - const auto* assetPools = dynamic_cast(context.m_zone.m_pools.get()); - std::vector> dumpers; - // REGISTER_DUMPER(AssetDumperPhysPreset, m_phys_preset) // REGISTER_DUMPER(AssetDumperPhysConstraints, m_phys_constraints) // REGISTER_DUMPER(AssetDumperDestructibleDef, m_destructible_def) // REGISTER_DUMPER(AssetDumperXAnimParts, m_xanim_parts) - REGISTER_DUMPER(xmodel::DumperT5, m_xmodel) - REGISTER_DUMPER(material::JsonDumperT5, m_material) - REGISTER_DUMPER(techset::DumperT5, m_technique_set) - REGISTER_DUMPER(image::DumperT5, m_image) + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); // REGISTER_DUMPER(AssetDumperSndBank, m_sound_bank) // REGISTER_DUMPER(AssetDumperSndPatch, m_sound_patch) // REGISTER_DUMPER(AssetDumperClipMap, m_clip_map) @@ -43,32 +32,16 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // REGISTER_DUMPER(AssetDumperFont, m_font) // REGISTER_DUMPER(AssetDumperMenuList, m_menu_list) // REGISTER_DUMPER(AssetDumperMenuDef, m_menu_def) - REGISTER_DUMPER(localize::DumperT5, m_localize) + RegisterAssetDumper(std::make_unique()); // REGISTER_DUMPER(AssetDumperWeapon, m_weapon) // REGISTER_DUMPER(AssetDumperSndDriverGlobals, m_snd_driver_globals) // REGISTER_DUMPER(AssetDumperFxEffectDef, m_fx) // REGISTER_DUMPER(AssetDumperFxImpactTable, m_fx_impact_table) - REGISTER_DUMPER(raw_file::DumperT5, m_raw_file) - REGISTER_DUMPER(string_table::DumperT5, m_string_table) + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); // REGISTER_DUMPER(AssetDumperPackIndex, m_pack_index) // REGISTER_DUMPER(AssetDumperXGlobals, m_xglobals) // REGISTER_DUMPER(AssetDumperDDLRoot, m_ddl) // REGISTER_DUMPER(AssetDumperGlasses, m_glasses) // REGISTER_DUMPER(AssetDumperEmblemSet, m_emblem_set) - - if (context.ShouldTrackProgress()) - { - size_t totalProgress = 0uz; - for (const auto& dumper : dumpers) - totalProgress += dumper->GetProgressTotalCount(); - - context.SetTotalProgress(totalProgress); - } - - for (const auto& dumper : dumpers) - dumper->Dump(context); - - return true; - -#undef REGISTER_DUMPER } diff --git a/src/ObjWriting/Game/T5/ObjWriterT5.h b/src/ObjWriting/Game/T5/ObjWriterT5.h index 1fa6971f..5977789e 100644 --- a/src/ObjWriting/Game/T5/ObjWriterT5.h +++ b/src/ObjWriting/Game/T5/ObjWriterT5.h @@ -1,11 +1,12 @@ #pragma once -#include "IObjWriter.h" + +#include "ObjWriter.h" namespace T5 { class ObjWriter final : public IObjWriter { public: - bool DumpZone(AssetDumpingContext& context) const override; + void RegisterAssetDumpers(AssetDumpingContext& context) override; }; } // namespace T5 diff --git a/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.cpp b/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.cpp index ca86c231..a8bdf085 100644 --- a/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.cpp +++ b/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.cpp @@ -13,7 +13,7 @@ namespace fs = std::filesystem; namespace { - constexpr static size_t GSC_MAX_SIZE = 0xC000000; + constexpr size_t GSC_MAX_SIZE = 0xC000000; void DumpGsc(AssetDumpingContext& context, const XAssetInfo& asset, std::ostream& stream) { @@ -96,11 +96,6 @@ namespace namespace raw_file { - DumperT5::DumperT5(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperT5::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* rawFile = asset.Asset(); diff --git a/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.h b/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.h index 46ec5302..9d623cd1 100644 --- a/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.h +++ b/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.h @@ -7,9 +7,6 @@ namespace raw_file { class DumperT5 final : public AbstractAssetDumper { - public: - explicit DumperT5(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.cpp b/src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.cpp index ce6135e9..7c9d2516 100644 --- a/src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.cpp +++ b/src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.cpp @@ -6,11 +6,6 @@ using namespace T5; namespace string_table { - DumperT5::DumperT5(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperT5::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* stringTable = asset.Asset(); diff --git a/src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.h b/src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.h index 4d388533..444068f1 100644 --- a/src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.h +++ b/src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.h @@ -7,9 +7,6 @@ namespace string_table { class DumperT5 final : public AbstractAssetDumper { - public: - explicit DumperT5(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/T5/Techset/TechsetDumperT5.cpp b/src/ObjWriting/Game/T5/Techset/TechsetDumperT5.cpp index 09f1f79d..9504fcc2 100644 --- a/src/ObjWriting/Game/T5/Techset/TechsetDumperT5.cpp +++ b/src/ObjWriting/Game/T5/Techset/TechsetDumperT5.cpp @@ -318,11 +318,6 @@ namespace namespace techset { - DumperT5::DumperT5(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperT5::Dump(AssetDumpingContext& context) { context.GetZoneAssetDumperState()->EnsureInitialized(); diff --git a/src/ObjWriting/Game/T5/Techset/TechsetDumperT5.h b/src/ObjWriting/Game/T5/Techset/TechsetDumperT5.h index 5a616730..1d1aef2d 100644 --- a/src/ObjWriting/Game/T5/Techset/TechsetDumperT5.h +++ b/src/ObjWriting/Game/T5/Techset/TechsetDumperT5.h @@ -8,8 +8,6 @@ namespace techset class DumperT5 final : public AbstractAssetDumper { public: - explicit DumperT5(const AssetPool& pool); - void Dump(AssetDumpingContext& context) override; protected: diff --git a/src/ObjWriting/Game/T6/FontIcon/FontIconCsvDumperT6.cpp b/src/ObjWriting/Game/T6/FontIcon/FontIconCsvDumperT6.cpp index 77282951..a0b4b435 100644 --- a/src/ObjWriting/Game/T6/FontIcon/FontIconCsvDumperT6.cpp +++ b/src/ObjWriting/Game/T6/FontIcon/FontIconCsvDumperT6.cpp @@ -133,11 +133,6 @@ namespace namespace font_icon { - CsvDumperT6::CsvDumperT6(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void CsvDumperT6::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto assetFile = context.OpenAssetFile(asset.m_name); diff --git a/src/ObjWriting/Game/T6/FontIcon/FontIconCsvDumperT6.h b/src/ObjWriting/Game/T6/FontIcon/FontIconCsvDumperT6.h index ee880ff2..9eaa4b7f 100644 --- a/src/ObjWriting/Game/T6/FontIcon/FontIconCsvDumperT6.h +++ b/src/ObjWriting/Game/T6/FontIcon/FontIconCsvDumperT6.h @@ -7,9 +7,6 @@ namespace font_icon { class CsvDumperT6 final : public AbstractAssetDumper { - public: - explicit CsvDumperT6(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.cpp b/src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.cpp index b042fd13..31a77982 100644 --- a/src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.cpp +++ b/src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.cpp @@ -9,12 +9,12 @@ using namespace T6; namespace font_icon { - std::unique_ptr CreateDumperT6(const AssetPool& pool) + std::unique_ptr CreateDumperT6() { #ifdef DUMP_FONT_ICON_AS_CSV - return std::make_unique(pool); + return std::make_unique(); #else - return std::make_unique(pool); + return std::make_unique(); #endif } } // namespace font_icon diff --git a/src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.h b/src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.h index e150b9c2..3ef5326f 100644 --- a/src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.h +++ b/src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.h @@ -7,5 +7,5 @@ namespace font_icon { - std::unique_ptr CreateDumperT6(const AssetPool& pool); + std::unique_ptr CreateDumperT6(); } // namespace font_icon diff --git a/src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.cpp b/src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.cpp index f82ef8dc..9f856fd4 100644 --- a/src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.cpp +++ b/src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.cpp @@ -78,11 +78,6 @@ namespace namespace font_icon { - JsonDumperT6::JsonDumperT6(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void JsonDumperT6::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAssetName(asset.m_name)); diff --git a/src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.h b/src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.h index f25c0761..fe752c27 100644 --- a/src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.h +++ b/src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.h @@ -7,9 +7,6 @@ namespace font_icon { class JsonDumperT6 final : public AbstractAssetDumper { - public: - explicit JsonDumperT6(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/T6/Image/ImageDumperT6.cpp b/src/ObjWriting/Game/T6/Image/ImageDumperT6.cpp index 61914b4a..7ac1557a 100644 --- a/src/ObjWriting/Game/T6/Image/ImageDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Image/ImageDumperT6.cpp @@ -79,8 +79,7 @@ namespace namespace image { - DumperT6::DumperT6(const AssetPool& pool) - : AbstractAssetDumper(pool) + DumperT6::DumperT6() { switch (ObjWriting::Configuration.ImageOutputFormat) { diff --git a/src/ObjWriting/Game/T6/Image/ImageDumperT6.h b/src/ObjWriting/Game/T6/Image/ImageDumperT6.h index a52d497d..683658c5 100644 --- a/src/ObjWriting/Game/T6/Image/ImageDumperT6.h +++ b/src/ObjWriting/Game/T6/Image/ImageDumperT6.h @@ -11,7 +11,7 @@ namespace image class DumperT6 final : public AbstractAssetDumper { public: - explicit DumperT6(const AssetPool& pool); + DumperT6(); protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; diff --git a/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.cpp b/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.cpp index 0a68fd4a..519bd070 100644 --- a/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.cpp @@ -98,11 +98,6 @@ namespace namespace leaderboard { - JsonDumperT6::JsonDumperT6(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void JsonDumperT6::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAsset(asset.m_name)); diff --git a/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.h b/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.h index 90db9a73..95ce8b2b 100644 --- a/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.h +++ b/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.h @@ -7,9 +7,6 @@ namespace leaderboard { class JsonDumperT6 final : public AbstractAssetDumper { - public: - explicit JsonDumperT6(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.cpp b/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.cpp index 5928599b..fa21775c 100644 --- a/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.cpp @@ -5,20 +5,15 @@ #include "Utils/Logging/Log.h" #include -#include using namespace T6; namespace localize { - DumperT6::DumperT6(const AssetPool& pool) - : AbstractSingleProgressAssetDumper(pool) - { - } - void DumperT6::Dump(AssetDumpingContext& context) { - if (m_pool.m_asset_lookup.empty()) + auto localizeAssets = context.m_zone.m_pools.PoolAssets(); + if (localizeAssets.empty()) return; const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language); @@ -35,7 +30,7 @@ namespace localize stringFileDumper.SetNotes(""); - for (const auto* localizeEntry : m_pool) + for (const auto* localizeEntry : localizeAssets) { stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value); } diff --git a/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.h b/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.h index 184d7a8b..98152e24 100644 --- a/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.h +++ b/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.h @@ -8,8 +8,6 @@ namespace localize class DumperT6 final : public AbstractSingleProgressAssetDumper { public: - explicit DumperT6(const AssetPool& pool); - void Dump(AssetDumpingContext& context) override; }; } // namespace localize diff --git a/src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.cpp b/src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.cpp index ad6c87aa..e3d4b888 100644 --- a/src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.cpp @@ -6,11 +6,6 @@ using namespace T6; namespace map_ents { - DumperT6::DumperT6(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperT6::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* mapEnts = asset.Asset(); diff --git a/src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.h b/src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.h index 76270145..1aa8520b 100644 --- a/src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.h +++ b/src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.h @@ -7,9 +7,6 @@ namespace map_ents { class DumperT6 final : public AbstractAssetDumper { - public: - explicit DumperT6(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/T6/Material/MaterialConstantZoneStateT6.cpp b/src/ObjWriting/Game/T6/Material/MaterialConstantZoneStateT6.cpp index 9df3cc4d..caf9d8b3 100644 --- a/src/ObjWriting/Game/T6/Material/MaterialConstantZoneStateT6.cpp +++ b/src/ObjWriting/Game/T6/Material/MaterialConstantZoneStateT6.cpp @@ -1,7 +1,6 @@ #include "MaterialConstantZoneStateT6.h" #include "Game/T6/CommonT6.h" -#include "Game/T6/GameAssetPoolT6.h" #include "Game/T6/GameT6.h" #include "ObjWriting.h" #include "Zone/ZoneRegistry.h" @@ -479,11 +478,7 @@ namespace T6 { for (const auto* zone : ZoneRegistry::GetRegistryForGame(GameId::T6)->Zones()) { - const auto* t6AssetPools = dynamic_cast(zone->m_pools.get()); - if (!t6AssetPools) - return; - - for (const auto* techniqueSetInfo : *t6AssetPools->m_technique_set) + for (const auto* techniqueSetInfo : zone->m_pools.PoolAssets()) { const auto* techniqueSet = techniqueSetInfo->Asset(); diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index df9c60ab..9f8f7b12 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -1,14 +1,12 @@ #include "ObjWriterT6.h" #include "FontIcon/FontIconDumperT6.h" -#include "Game/T6/GameAssetPoolT6.h" #include "Game/T6/Material/MaterialJsonDumperT6.h" #include "Game/T6/XModel/XModelDumperT6.h" #include "Image/ImageDumperT6.h" #include "Leaderboard/LeaderboardJsonDumperT6.h" #include "Localize/LocalizeDumperT6.h" #include "Maps/MapEntsDumperT6.h" -#include "ObjWriting.h" #include "PhysConstraints/PhysConstraintsInfoStringDumperT6.h" #include "PhysPreset/PhysPresetInfoStringDumperT6.h" #include "Qdb/QdbDumperT6.h" @@ -29,86 +27,54 @@ using namespace T6; -bool ObjWriter::DumpZone(AssetDumpingContext& context) const +void ObjWriter::RegisterAssetDumpers(AssetDumpingContext& context) { -#define REGISTER_DUMPER(dumperType, poolName) \ - if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(dumperType::AssetType_t::EnumEntry)) \ - { \ - dumpers.emplace_back(std::make_unique(*assetPools->poolName)); \ - } -#define REGISTER_DUMPER_WITH_FACTORY(createDumper, poolName, asset) \ - if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(asset::EnumEntry)) \ - { \ - auto dumper = createDumper(*assetPools->poolName); \ - if (dumper) \ - dumpers.emplace_back(std::move(dumper)); \ - } - - const auto* assetPools = dynamic_cast(context.m_zone.m_pools.get()); - std::vector> dumpers; - - REGISTER_DUMPER(phys_preset::InfoStringDumperT6, m_phys_preset) - REGISTER_DUMPER(phys_constraints::InfoStringDumperT6, m_phys_constraints) + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); // REGISTER_DUMPER(AssetDumperDestructibleDef, m_destructible_def) // REGISTER_DUMPER(AssetDumperXAnimParts, m_xanim_parts) - REGISTER_DUMPER(xmodel::DumperT6, m_xmodel) - REGISTER_DUMPER(material::JsonDumperT6, m_material) - REGISTER_DUMPER(techset::DumperT6, m_technique_set) - REGISTER_DUMPER(image::DumperT6, m_image) - REGISTER_DUMPER(sound::SndBankDumperT6, m_sound_bank) + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); // REGISTER_DUMPER(AssetDumperSndPatch, m_sound_patch) // REGISTER_DUMPER(AssetDumperClipMap, m_clip_map) // REGISTER_DUMPER(AssetDumperComWorld, m_com_world) // REGISTER_DUMPER(AssetDumperGameWorldSp, m_game_world_sp) // REGISTER_DUMPER(AssetDumperGameWorldMp, m_game_world_mp) - REGISTER_DUMPER(map_ents::DumperT6, m_map_ents) + RegisterAssetDumper(std::make_unique()); // REGISTER_DUMPER(AssetDumperGfxWorld, m_gfx_world) // REGISTER_DUMPER(AssetDumperGfxLightDef, m_gfx_light_def) // REGISTER_DUMPER(AssetDumperFont, m_font) - REGISTER_DUMPER_WITH_FACTORY(font_icon::CreateDumperT6, m_font_icon, AssetFontIcon) + RegisterAssetDumper(font_icon::CreateDumperT6()); // REGISTER_DUMPER(AssetDumperMenuList, m_menu_list) // REGISTER_DUMPER(AssetDumperMenuDef, m_menu_def) - REGISTER_DUMPER(localize::DumperT6, m_localize) - REGISTER_DUMPER(weapon::DumperT6, m_weapon) - REGISTER_DUMPER(attachment::DumperT6, m_attachment) - REGISTER_DUMPER(attachment_unique::DumperT6, m_attachment_unique) - REGISTER_DUMPER(camo::JsonDumperT6, m_camo) - REGISTER_DUMPER(sound::SndDriverGlobalsDumperT6, m_snd_driver_globals) + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); // REGISTER_DUMPER(AssetDumperFxEffectDef, m_fx) // REGISTER_DUMPER(AssetDumperFxImpactTable, m_fx_impact_table) - REGISTER_DUMPER(raw_file::DumperT6, m_raw_file) - REGISTER_DUMPER(string_table::DumperT6, m_string_table) - REGISTER_DUMPER(leaderboard::JsonDumperT6, m_leaderboard) + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); // REGISTER_DUMPER(AssetDumperXGlobals, m_xglobals) // REGISTER_DUMPER(AssetDumperDDLRoot, m_ddl) // REGISTER_DUMPER(AssetDumperGlasses, m_glasses) // REGISTER_DUMPER(AssetDumperEmblemSet, m_emblem_set) - REGISTER_DUMPER(script::DumperT6, m_script) + RegisterAssetDumper(std::make_unique()); // REGISTER_DUMPER(AssetDumperKeyValuePairs, m_key_value_pairs) - REGISTER_DUMPER(vehicle::DumperT6, m_vehicle) + RegisterAssetDumper(std::make_unique()); // REGISTER_DUMPER(AssetDumperMemoryBlock, m_memory_block) // REGISTER_DUMPER(AssetDumperAddonMapEnts, m_addon_map_ents) - REGISTER_DUMPER(tracer::DumperT6, m_tracer) + RegisterAssetDumper(std::make_unique()); // REGISTER_DUMPER(AssetDumperSkinnedVertsDef, m_skinned_verts) - REGISTER_DUMPER(qdb::DumperT6, m_qdb) - REGISTER_DUMPER(slug::DumperT6, m_slug) + RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique()); // REGISTER_DUMPER(AssetDumperFootstepTableDef, m_footstep_table) // REGISTER_DUMPER(AssetDumperFootstepFXTableDef, m_footstep_fx_table) - REGISTER_DUMPER(z_barrier::DumperT6, m_zbarrier) - - if (context.ShouldTrackProgress()) - { - size_t totalProgress = 0uz; - for (const auto& dumper : dumpers) - totalProgress += dumper->GetProgressTotalCount(); - - context.SetTotalProgress(totalProgress); - } - - for (const auto& dumper : dumpers) - dumper->Dump(context); - - return true; - -#undef REGISTER_DUMPER + RegisterAssetDumper(std::make_unique()); } diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.h b/src/ObjWriting/Game/T6/ObjWriterT6.h index e5290738..514a54d5 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.h +++ b/src/ObjWriting/Game/T6/ObjWriterT6.h @@ -1,11 +1,12 @@ #pragma once -#include "IObjWriter.h" + +#include "ObjWriter.h" namespace T6 { class ObjWriter final : public IObjWriter { public: - bool DumpZone(AssetDumpingContext& context) const override; + void RegisterAssetDumpers(AssetDumpingContext& context) override; }; } // namespace T6 diff --git a/src/ObjWriting/Game/T6/PhysConstraints/PhysConstraintsInfoStringDumperT6.cpp b/src/ObjWriting/Game/T6/PhysConstraints/PhysConstraintsInfoStringDumperT6.cpp index 4f6dee21..4be90fa5 100644 --- a/src/ObjWriting/Game/T6/PhysConstraints/PhysConstraintsInfoStringDumperT6.cpp +++ b/src/ObjWriting/Game/T6/PhysConstraints/PhysConstraintsInfoStringDumperT6.cpp @@ -61,11 +61,6 @@ namespace namespace phys_constraints { - InfoStringDumperT6::InfoStringDumperT6(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void InfoStringDumperT6::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { // Only dump raw when no gdt available diff --git a/src/ObjWriting/Game/T6/PhysConstraints/PhysConstraintsInfoStringDumperT6.h b/src/ObjWriting/Game/T6/PhysConstraints/PhysConstraintsInfoStringDumperT6.h index 87ae940e..df0bb1d7 100644 --- a/src/ObjWriting/Game/T6/PhysConstraints/PhysConstraintsInfoStringDumperT6.h +++ b/src/ObjWriting/Game/T6/PhysConstraints/PhysConstraintsInfoStringDumperT6.h @@ -7,9 +7,6 @@ namespace phys_constraints { class InfoStringDumperT6 final : public AbstractAssetDumper { - public: - explicit InfoStringDumperT6(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/T6/PhysPreset/PhysPresetInfoStringDumperT6.cpp b/src/ObjWriting/Game/T6/PhysPreset/PhysPresetInfoStringDumperT6.cpp index b0948f97..3e91aac6 100644 --- a/src/ObjWriting/Game/T6/PhysPreset/PhysPresetInfoStringDumperT6.cpp +++ b/src/ObjWriting/Game/T6/PhysPreset/PhysPresetInfoStringDumperT6.cpp @@ -82,11 +82,6 @@ namespace namespace phys_preset { - InfoStringDumperT6::InfoStringDumperT6(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void InfoStringDumperT6::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { // Only dump raw when no gdt available diff --git a/src/ObjWriting/Game/T6/PhysPreset/PhysPresetInfoStringDumperT6.h b/src/ObjWriting/Game/T6/PhysPreset/PhysPresetInfoStringDumperT6.h index 90253b78..79ba47bf 100644 --- a/src/ObjWriting/Game/T6/PhysPreset/PhysPresetInfoStringDumperT6.h +++ b/src/ObjWriting/Game/T6/PhysPreset/PhysPresetInfoStringDumperT6.h @@ -7,9 +7,6 @@ namespace phys_preset { class InfoStringDumperT6 final : public AbstractAssetDumper { - public: - explicit InfoStringDumperT6(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/T6/Qdb/QdbDumperT6.cpp b/src/ObjWriting/Game/T6/Qdb/QdbDumperT6.cpp index 0ad923e0..d7e2c119 100644 --- a/src/ObjWriting/Game/T6/Qdb/QdbDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Qdb/QdbDumperT6.cpp @@ -4,11 +4,6 @@ using namespace T6; namespace qdb { - DumperT6::DumperT6(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperT6::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* qdb = asset.Asset(); diff --git a/src/ObjWriting/Game/T6/Qdb/QdbDumperT6.h b/src/ObjWriting/Game/T6/Qdb/QdbDumperT6.h index 6446d1eb..1bc6af76 100644 --- a/src/ObjWriting/Game/T6/Qdb/QdbDumperT6.h +++ b/src/ObjWriting/Game/T6/Qdb/QdbDumperT6.h @@ -7,9 +7,6 @@ namespace qdb { class DumperT6 final : public AbstractAssetDumper { - public: - explicit DumperT6(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.cpp b/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.cpp index beda25b7..6f94ec52 100644 --- a/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.cpp +++ b/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.cpp @@ -77,11 +77,6 @@ namespace namespace raw_file { - DumperT6::DumperT6(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperT6::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* rawFile = asset.Asset(); diff --git a/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.h b/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.h index a45aa9ac..1193d896 100644 --- a/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.h +++ b/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.h @@ -7,9 +7,6 @@ namespace raw_file { class DumperT6 final : public AbstractAssetDumper { - public: - explicit DumperT6(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/T6/Script/ScriptDumperT6.cpp b/src/ObjWriting/Game/T6/Script/ScriptDumperT6.cpp index dfe974a5..4494adad 100644 --- a/src/ObjWriting/Game/T6/Script/ScriptDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Script/ScriptDumperT6.cpp @@ -4,11 +4,6 @@ using namespace T6; namespace script { - DumperT6::DumperT6(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperT6::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* scriptParseTree = asset.Asset(); diff --git a/src/ObjWriting/Game/T6/Script/ScriptDumperT6.h b/src/ObjWriting/Game/T6/Script/ScriptDumperT6.h index bc1a9aee..6435e0af 100644 --- a/src/ObjWriting/Game/T6/Script/ScriptDumperT6.h +++ b/src/ObjWriting/Game/T6/Script/ScriptDumperT6.h @@ -7,9 +7,6 @@ namespace script { class DumperT6 final : public AbstractAssetDumper { - public: - explicit DumperT6(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/T6/Slug/SlugDumperT6.cpp b/src/ObjWriting/Game/T6/Slug/SlugDumperT6.cpp index 7e71e468..f4d79034 100644 --- a/src/ObjWriting/Game/T6/Slug/SlugDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Slug/SlugDumperT6.cpp @@ -4,11 +4,6 @@ using namespace T6; namespace slug { - DumperT6::DumperT6(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperT6::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* slug = asset.Asset(); diff --git a/src/ObjWriting/Game/T6/Slug/SlugDumperT6.h b/src/ObjWriting/Game/T6/Slug/SlugDumperT6.h index 67bba25d..80bd7821 100644 --- a/src/ObjWriting/Game/T6/Slug/SlugDumperT6.h +++ b/src/ObjWriting/Game/T6/Slug/SlugDumperT6.h @@ -7,9 +7,6 @@ namespace slug { class DumperT6 final : public AbstractAssetDumper { - public: - explicit DumperT6(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.cpp b/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.cpp index 29f0485c..95ff3869 100644 --- a/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.cpp @@ -2,7 +2,6 @@ #include "Csv/CsvStream.h" #include "Game/T6/CommonT6.h" -#include "Game/T6/GameAssetPoolT6.h" #include "Game/T6/GameT6.h" #include "Game/T6/SoundConstantsT6.h" #include "ObjContainer/SoundBank/SoundBank.h" @@ -205,7 +204,7 @@ namespace { for (const auto& zone : ZoneRegistry::GetRegistryForGame(GameId::T6)->Zones()) { - auto& sndBankPool = *dynamic_cast(zone->m_pools.get())->m_sound_bank; + auto sndBankPool = zone->m_pools.PoolAssets(); for (auto* entry : sndBankPool) { const auto& sndBank = *entry->Asset(); @@ -905,11 +904,6 @@ namespace namespace sound { - SndBankDumperT6::SndBankDumperT6(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void SndBankDumperT6::Dump(AssetDumpingContext& context) { auto* hashes = context.GetZoneAssetDumperState(); diff --git a/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.h b/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.h index 616729f1..5a7766af 100644 --- a/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.h +++ b/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.h @@ -8,10 +8,9 @@ namespace sound class SndBankDumperT6 final : public AbstractAssetDumper { public: - explicit SndBankDumperT6(const AssetPool& pool); void Dump(AssetDumpingContext& context) override; protected: - void DumpAsset(AssetDumpingContext& context, const XAssetInfo::Type>& asset) override; + void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; } // namespace sound diff --git a/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.cpp b/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.cpp index 0c862429..123de0b7 100644 --- a/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.cpp @@ -108,15 +108,18 @@ namespace { } - void DumpPool(const AssetPool& pool) + void DumpSndDriverGlobals(const XAssetInfo* sndDriverGlobalsInfo) { - for (const auto* assetInfo : pool) - { - if (!assetInfo->m_name.empty() && assetInfo->m_name[0] == ',') - continue; + const auto* sndDriverGlobals = sndDriverGlobalsInfo->Asset(); - DumpSndDriverGlobals(assetInfo); - } + DumpSndVolumesGroups(sndDriverGlobals->groups, sndDriverGlobals->groupCount); + DumpSndCurves(sndDriverGlobals->curves, sndDriverGlobals->curveCount); + DumpSndPans(sndDriverGlobals->pans, sndDriverGlobals->panCount); + DumpSndDuckGroups(sndDriverGlobals->duckGroups, sndDriverGlobals->duckGroupCount); + // DumpSndContexts(sndDriverGlobals->contexts, sndDriverGlobals->contextCount); + DumpSndMasters(sndDriverGlobals->masters, sndDriverGlobals->masterCount); + DumpSndSidechainDucks(sndDriverGlobals->voiceDucks, sndDriverGlobals->voiceDuckCount); + DumpSndFutz(sndDriverGlobals->futzes, sndDriverGlobals->futzCount); } private: @@ -365,36 +368,15 @@ namespace } } - void DumpSndDriverGlobals(const XAssetInfo* sndDriverGlobalsInfo) - { - const auto* sndDriverGlobals = sndDriverGlobalsInfo->Asset(); - - DumpSndVolumesGroups(sndDriverGlobals->groups, sndDriverGlobals->groupCount); - DumpSndCurves(sndDriverGlobals->curves, sndDriverGlobals->curveCount); - DumpSndPans(sndDriverGlobals->pans, sndDriverGlobals->panCount); - DumpSndDuckGroups(sndDriverGlobals->duckGroups, sndDriverGlobals->duckGroupCount); - // DumpSndContexts(sndDriverGlobals->contexts, sndDriverGlobals->contextCount); - DumpSndMasters(sndDriverGlobals->masters, sndDriverGlobals->masterCount); - DumpSndSidechainDucks(sndDriverGlobals->voiceDucks, sndDriverGlobals->voiceDuckCount); - DumpSndFutz(sndDriverGlobals->futzes, sndDriverGlobals->futzCount); - } - AssetDumpingContext& m_context; }; } // namespace namespace sound { - SndDriverGlobalsDumperT6::SndDriverGlobalsDumperT6(const AssetPool& pool) - : AbstractSingleProgressAssetDumper(pool) - { - } - - void SndDriverGlobalsDumperT6::Dump(AssetDumpingContext& context) + void SndDriverGlobalsDumperT6::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { Internal internal(context); - internal.DumpPool(m_pool); - - context.IncrementProgress(); + internal.DumpSndDriverGlobals(&asset); } } // namespace sound diff --git a/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.h b/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.h index 9ce2f55f..4eb4d626 100644 --- a/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.h +++ b/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.h @@ -5,11 +5,9 @@ namespace sound { - class SndDriverGlobalsDumperT6 final : public AbstractSingleProgressAssetDumper + class SndDriverGlobalsDumperT6 final : public AbstractAssetDumper { public: - explicit SndDriverGlobalsDumperT6(const AssetPool& pool); - - void Dump(AssetDumpingContext& context) override; + void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; } // namespace sound diff --git a/src/ObjWriting/Game/T6/StringTable/StringTableDumperT6.cpp b/src/ObjWriting/Game/T6/StringTable/StringTableDumperT6.cpp index 840b0f74..477a562f 100644 --- a/src/ObjWriting/Game/T6/StringTable/StringTableDumperT6.cpp +++ b/src/ObjWriting/Game/T6/StringTable/StringTableDumperT6.cpp @@ -6,11 +6,6 @@ using namespace T6; namespace string_table { - DumperT6::DumperT6(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperT6::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto* stringTable = asset.Asset(); diff --git a/src/ObjWriting/Game/T6/StringTable/StringTableDumperT6.h b/src/ObjWriting/Game/T6/StringTable/StringTableDumperT6.h index 7e6256cb..df6f0c0d 100644 --- a/src/ObjWriting/Game/T6/StringTable/StringTableDumperT6.h +++ b/src/ObjWriting/Game/T6/StringTable/StringTableDumperT6.h @@ -7,9 +7,6 @@ namespace string_table { class DumperT6 final : public AbstractAssetDumper { - public: - explicit DumperT6(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.cpp b/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.cpp index af1d8f22..6b346fcb 100644 --- a/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.cpp @@ -329,11 +329,6 @@ namespace namespace techset { - DumperT6::DumperT6(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperT6::Dump(AssetDumpingContext& context) { context.GetZoneAssetDumperState()->EnsureInitialized(); diff --git a/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.h b/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.h index bcc14246..d69edb93 100644 --- a/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.h +++ b/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.h @@ -8,8 +8,6 @@ namespace techset class DumperT6 final : public AbstractAssetDumper { public: - explicit DumperT6(const AssetPool& pool); - void Dump(AssetDumpingContext& context) override; protected: diff --git a/src/ObjWriting/Game/T6/Tracer/TracerDumperT6.cpp b/src/ObjWriting/Game/T6/Tracer/TracerDumperT6.cpp index 2767db5c..b063065f 100644 --- a/src/ObjWriting/Game/T6/Tracer/TracerDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Tracer/TracerDumperT6.cpp @@ -60,11 +60,6 @@ namespace namespace tracer { - DumperT6::DumperT6(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperT6::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { // Only dump raw when no gdt available diff --git a/src/ObjWriting/Game/T6/Tracer/TracerDumperT6.h b/src/ObjWriting/Game/T6/Tracer/TracerDumperT6.h index 08b62c86..5911bd63 100644 --- a/src/ObjWriting/Game/T6/Tracer/TracerDumperT6.h +++ b/src/ObjWriting/Game/T6/Tracer/TracerDumperT6.h @@ -7,9 +7,6 @@ namespace tracer { class DumperT6 final : public AbstractAssetDumper { - public: - explicit DumperT6(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/T6/Vehicle/VehicleDumperT6.cpp b/src/ObjWriting/Game/T6/Vehicle/VehicleDumperT6.cpp index ec71d6e0..eb2a75d3 100644 --- a/src/ObjWriting/Game/T6/Vehicle/VehicleDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Vehicle/VehicleDumperT6.cpp @@ -111,11 +111,6 @@ namespace namespace vehicle { - DumperT6::DumperT6(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperT6::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { // Only dump raw when no gdt available diff --git a/src/ObjWriting/Game/T6/Vehicle/VehicleDumperT6.h b/src/ObjWriting/Game/T6/Vehicle/VehicleDumperT6.h index 58b64757..623393de 100644 --- a/src/ObjWriting/Game/T6/Vehicle/VehicleDumperT6.h +++ b/src/ObjWriting/Game/T6/Vehicle/VehicleDumperT6.h @@ -7,9 +7,6 @@ namespace vehicle { class DumperT6 final : public AbstractAssetDumper { - public: - explicit DumperT6(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/T6/Weapon/AttachmentDumperT6.cpp b/src/ObjWriting/Game/T6/Weapon/AttachmentDumperT6.cpp index d7649885..e53c4538 100644 --- a/src/ObjWriting/Game/T6/Weapon/AttachmentDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Weapon/AttachmentDumperT6.cpp @@ -67,11 +67,6 @@ namespace namespace attachment { - DumperT6::DumperT6(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperT6::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { // Only dump raw when no gdt available diff --git a/src/ObjWriting/Game/T6/Weapon/AttachmentDumperT6.h b/src/ObjWriting/Game/T6/Weapon/AttachmentDumperT6.h index ad9aaee9..5ccb0a3e 100644 --- a/src/ObjWriting/Game/T6/Weapon/AttachmentDumperT6.h +++ b/src/ObjWriting/Game/T6/Weapon/AttachmentDumperT6.h @@ -7,9 +7,6 @@ namespace attachment { class DumperT6 final : public AbstractAssetDumper { - public: - explicit DumperT6(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.cpp b/src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.cpp index e61a2567..0aacd2eb 100644 --- a/src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.cpp @@ -131,11 +131,6 @@ namespace namespace attachment_unique { - DumperT6::DumperT6(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperT6::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { // Only dump raw when no gdt available diff --git a/src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.h b/src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.h index 65da39bc..db444952 100644 --- a/src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.h +++ b/src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.h @@ -7,9 +7,6 @@ namespace attachment_unique { class DumperT6 final : public AbstractAssetDumper { - public: - explicit DumperT6(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/T6/Weapon/CamoJsonDumperT6.cpp b/src/ObjWriting/Game/T6/Weapon/CamoJsonDumperT6.cpp index e7fda73e..d2bd4351 100644 --- a/src/ObjWriting/Game/T6/Weapon/CamoJsonDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Weapon/CamoJsonDumperT6.cpp @@ -104,11 +104,6 @@ namespace namespace camo { - JsonDumperT6::JsonDumperT6(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void JsonDumperT6::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { const auto fileName = GetJsonFileNameForAssetName(asset.m_name); diff --git a/src/ObjWriting/Game/T6/Weapon/CamoJsonDumperT6.h b/src/ObjWriting/Game/T6/Weapon/CamoJsonDumperT6.h index 7bf2d45b..bc960c98 100644 --- a/src/ObjWriting/Game/T6/Weapon/CamoJsonDumperT6.h +++ b/src/ObjWriting/Game/T6/Weapon/CamoJsonDumperT6.h @@ -7,9 +7,6 @@ namespace camo { class JsonDumperT6 final : public AbstractAssetDumper { - public: - explicit JsonDumperT6(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/T6/Weapon/WeaponDumperT6.cpp b/src/ObjWriting/Game/T6/Weapon/WeaponDumperT6.cpp index 4c7c991d..19c843a6 100644 --- a/src/ObjWriting/Game/T6/Weapon/WeaponDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Weapon/WeaponDumperT6.cpp @@ -461,11 +461,6 @@ namespace namespace weapon { - DumperT6::DumperT6(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperT6::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { // Only dump raw when no gdt available diff --git a/src/ObjWriting/Game/T6/Weapon/WeaponDumperT6.h b/src/ObjWriting/Game/T6/Weapon/WeaponDumperT6.h index 18fddd9d..239787d7 100644 --- a/src/ObjWriting/Game/T6/Weapon/WeaponDumperT6.h +++ b/src/ObjWriting/Game/T6/Weapon/WeaponDumperT6.h @@ -7,9 +7,6 @@ namespace weapon { class DumperT6 final : public AbstractAssetDumper { - public: - explicit DumperT6(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/Game/T6/ZBarrier/ZBarrierDumperT6.cpp b/src/ObjWriting/Game/T6/ZBarrier/ZBarrierDumperT6.cpp index f9e56c21..bca5a7a2 100644 --- a/src/ObjWriting/Game/T6/ZBarrier/ZBarrierDumperT6.cpp +++ b/src/ObjWriting/Game/T6/ZBarrier/ZBarrierDumperT6.cpp @@ -50,11 +50,6 @@ namespace namespace z_barrier { - DumperT6::DumperT6(const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void DumperT6::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { // Only dump raw when no gdt available diff --git a/src/ObjWriting/Game/T6/ZBarrier/ZBarrierDumperT6.h b/src/ObjWriting/Game/T6/ZBarrier/ZBarrierDumperT6.h index a16c3705..862bd4e3 100644 --- a/src/ObjWriting/Game/T6/ZBarrier/ZBarrierDumperT6.h +++ b/src/ObjWriting/Game/T6/ZBarrier/ZBarrierDumperT6.h @@ -7,9 +7,6 @@ namespace z_barrier { class DumperT6 final : public AbstractAssetDumper { - public: - explicit DumperT6(const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/ObjWriting/IObjWriter.cpp b/src/ObjWriting/IObjWriter.cpp deleted file mode 100644 index 685e7b4d..00000000 --- a/src/ObjWriting/IObjWriter.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "IObjWriter.h" - -#include "Game/IW3/ObjWriterIW3.h" -#include "Game/IW4/ObjWriterIW4.h" -#include "Game/IW5/ObjWriterIW5.h" -#include "Game/T5/ObjWriterT5.h" -#include "Game/T6/ObjWriterT6.h" - -#include - -const IObjWriter* IObjWriter::GetObjWriterForGame(GameId game) -{ - static const IObjWriter* zoneCreators[static_cast(GameId::COUNT)]{ - new IW3::ObjWriter(), - new IW4::ObjWriter(), - new IW5::ObjWriter(), - new T5::ObjWriter(), - new T6::ObjWriter(), - }; - static_assert(std::extent_v == static_cast(GameId::COUNT)); - - assert(static_cast(game) < static_cast(GameId::COUNT)); - const auto* result = zoneCreators[static_cast(game)]; - assert(result); - - return result; -} diff --git a/src/ObjWriting/IObjWriter.h b/src/ObjWriting/IObjWriter.h deleted file mode 100644 index 515d5f4f..00000000 --- a/src/ObjWriting/IObjWriter.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include "Dumping/AssetDumpingContext.h" - -class IObjWriter -{ -public: - IObjWriter() = default; - virtual ~IObjWriter() = default; - IObjWriter(const IObjWriter& other) = default; - IObjWriter(IObjWriter&& other) noexcept = default; - IObjWriter& operator=(const IObjWriter& other) = default; - IObjWriter& operator=(IObjWriter&& other) noexcept = default; - - virtual bool DumpZone(AssetDumpingContext& assetDumpingContext) const = 0; - - static const IObjWriter* GetObjWriterForGame(GameId game); -}; diff --git a/src/ObjWriting/Material/MaterialJsonDumper.cpp.template b/src/ObjWriting/Material/MaterialJsonDumper.cpp.template index b566e1c6..0e769bbc 100644 --- a/src/ObjWriting/Material/MaterialJsonDumper.cpp.template +++ b/src/ObjWriting/Material/MaterialJsonDumper.cpp.template @@ -361,11 +361,6 @@ namespace namespace material { - CLASS_NAME::CLASS_NAME (const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void CLASS_NAME::Dump(AssetDumpingContext& context) { auto* materialConstantState = context.GetZoneAssetDumperState(); diff --git a/src/ObjWriting/Material/MaterialJsonDumper.h.template b/src/ObjWriting/Material/MaterialJsonDumper.h.template index c58bd3f4..a089e691 100644 --- a/src/ObjWriting/Material/MaterialJsonDumper.h.template +++ b/src/ObjWriting/Material/MaterialJsonDumper.h.template @@ -20,7 +20,6 @@ namespace material class CLASS_NAME final : public AbstractAssetDumper { public: - explicit CLASS_NAME (const AssetPool& pool); void Dump(AssetDumpingContext& context) override; protected: diff --git a/src/ObjWriting/ObjWriter.cpp b/src/ObjWriting/ObjWriter.cpp new file mode 100644 index 00000000..ea3004c5 --- /dev/null +++ b/src/ObjWriting/ObjWriter.cpp @@ -0,0 +1,57 @@ +#include "ObjWriter.h" + +#include "Game/IW3/ObjWriterIW3.h" +#include "Game/IW4/ObjWriterIW4.h" +#include "Game/IW5/ObjWriterIW5.h" +#include "Game/T5/ObjWriterT5.h" +#include "Game/T6/ObjWriterT6.h" +#include "ObjWriting.h" + +#include + +bool IObjWriter::DumpZone(AssetDumpingContext& context) +{ + m_asset_dumpers.clear(); + RegisterAssetDumpers(context); + + if (context.ShouldTrackProgress()) + { + size_t totalProgress = 0uz; + for (const auto& dumper : m_asset_dumpers) + totalProgress += dumper->GetProgressTotalCount(context); + + context.SetTotalProgress(totalProgress); + } + + for (const auto& dumper : m_asset_dumpers) + dumper->Dump(context); + + return true; +} + +void IObjWriter::RegisterAssetDumper(std::unique_ptr dumper) +{ + const auto maybeHandlingAssetType = dumper->GetHandlingAssetType(); + if (maybeHandlingAssetType.has_value() && !ObjWriting::ShouldHandleAssetType(*maybeHandlingAssetType)) + return; + + m_asset_dumpers.emplace_back(std::move(dumper)); +} + +IObjWriter* IObjWriter::GetObjWriterForGame(GameId game) +{ + static IObjWriter* objWriters[static_cast(GameId::COUNT)]{ + new IW3::ObjWriter(), + new IW4::ObjWriter(), + new IW5::ObjWriter(), + new T5::ObjWriter(), + new T6::ObjWriter(), + }; + static_assert(std::extent_v == static_cast(GameId::COUNT)); + + assert(static_cast(game) < static_cast(GameId::COUNT)); + auto* result = objWriters[static_cast(game)]; + assert(result); + + return result; +} diff --git a/src/ObjWriting/ObjWriter.h b/src/ObjWriting/ObjWriter.h new file mode 100644 index 00000000..e6a14e1b --- /dev/null +++ b/src/ObjWriting/ObjWriter.h @@ -0,0 +1,29 @@ +#pragma once + +#include "Dumping/AssetDumpingContext.h" +#include "Dumping/IAssetDumper.h" + +#include +#include + +class IObjWriter +{ +public: + IObjWriter() = default; + virtual ~IObjWriter() = default; + IObjWriter(const IObjWriter& other) = default; + IObjWriter(IObjWriter&& other) noexcept = default; + IObjWriter& operator=(const IObjWriter& other) = default; + IObjWriter& operator=(IObjWriter&& other) noexcept = default; + + bool DumpZone(AssetDumpingContext& context); + + static IObjWriter* GetObjWriterForGame(GameId game); + +protected: + virtual void RegisterAssetDumpers(AssetDumpingContext& context) = 0; + void RegisterAssetDumper(std::unique_ptr dumper); + +private: + std::vector> m_asset_dumpers; +}; diff --git a/src/ObjWriting/XModel/XModelDumper.cpp.template b/src/ObjWriting/XModel/XModelDumper.cpp.template index c3bb23c8..4150f784 100644 --- a/src/ObjWriting/XModel/XModelDumper.cpp.template +++ b/src/ObjWriting/XModel/XModelDumper.cpp.template @@ -854,11 +854,6 @@ namespace namespace xmodel { - CLASS_NAME::CLASS_NAME (const AssetPool& pool) - : AbstractAssetDumper(pool) - { - } - void CLASS_NAME::DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) { DumpXModelJson(context, asset); diff --git a/src/ObjWriting/XModel/XModelDumper.h.template b/src/ObjWriting/XModel/XModelDumper.h.template index 8dce3422..88a56ea4 100644 --- a/src/ObjWriting/XModel/XModelDumper.h.template +++ b/src/ObjWriting/XModel/XModelDumper.h.template @@ -19,9 +19,6 @@ namespace xmodel { class CLASS_NAME final : public AbstractAssetDumper { - public: - explicit CLASS_NAME (const AssetPool& pool); - protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; }; diff --git a/src/Unlinking/ContentLister/ContentPrinter.cpp b/src/Unlinking/ContentLister/ContentPrinter.cpp index bdd00134..3ff7fb1e 100644 --- a/src/Unlinking/ContentLister/ContentPrinter.cpp +++ b/src/Unlinking/ContentLister/ContentPrinter.cpp @@ -12,12 +12,12 @@ ContentPrinter::ContentPrinter(const Zone& zone) void ContentPrinter::PrintContent() const { - const auto* pools = m_zone.m_pools.get(); + const auto& pools = m_zone.m_pools; const auto* game = IGame::GetGameById(m_zone.m_game_id); con::info("Zone '{}' ({})", m_zone.m_name, game->GetShortName()); con::info("Content:"); - for (const auto& asset : *pools) + for (const auto& asset : pools) con::info("{}, {}", *game->GetAssetTypeName(asset->m_type), asset->m_name); con::info(""); diff --git a/src/Unlinking/Unlinker.cpp b/src/Unlinking/Unlinker.cpp index 1175a9eb..213d6c6b 100644 --- a/src/Unlinking/Unlinker.cpp +++ b/src/Unlinking/Unlinker.cpp @@ -2,7 +2,7 @@ #include "ContentLister/ContentPrinter.h" #include "IObjLoader.h" -#include "IObjWriter.h" +#include "ObjWriter.h" #include "ObjWriting.h" #include "SearchPath/IWD.h" #include "SearchPath/OutputPathFilesystem.h" @@ -183,7 +183,7 @@ namespace UpdateAssetIncludesAndExcludes(context); - const auto* objWriter = IObjWriter::GetObjWriterForGame(zone.m_game_id); + auto* objWriter = IObjWriter::GetObjWriterForGame(zone.m_game_id); auto result = objWriter->DumpZone(context); diff --git a/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneWriteTemplate.cpp b/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneWriteTemplate.cpp index 683440eb..cee2e80b 100644 --- a/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneWriteTemplate.cpp +++ b/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneWriteTemplate.cpp @@ -357,7 +357,7 @@ namespace "{0}::{0}({1}* asset, const Zone& zone, ZoneOutputStream& stream)", WriterClassName(m_env.m_asset), m_env.m_asset->m_definition->GetFullName()) m_intendation++; - LINEF(": AssetWriter(zone.m_pools->GetAssetOrAssetReference({0}::EnumEntry, NonReferenceAssetName(AssetName<{0}>(*asset))), zone, stream)", + LINEF(": AssetWriter(zone.m_pools.GetAssetOrAssetReference({0}::EnumEntry, NonReferenceAssetName(AssetName<{0}>(*asset))), zone, stream)", m_env.m_asset->m_asset_name) m_intendation--; diff --git a/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.cpp b/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.cpp deleted file mode 100644 index 6344a4e5..00000000 --- a/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.cpp +++ /dev/null @@ -1,140 +0,0 @@ -#include "GameAssetPoolIW3.h" - -#include "Pool/AssetPoolDynamic.h" - -#include - -using namespace IW3; - -GameAssetPoolIW3::GameAssetPoolIW3(Zone* zone, const zone_priority_t priority) - : ZoneAssetPools(zone), - m_priority(priority) -{ -#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) -{ -#define CASE_ADD_TO_POOL(assetType, poolName) \ - case assetType: \ - { \ - assert(poolName); \ - return (poolName)->AddAsset(std::unique_ptr>( \ - static_cast*>(xAssetInfo.release()))); \ - } - - switch (static_cast(xAssetInfo->m_type)) - { - CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset) - CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts) - CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel) - CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material) - CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set) - CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image) - CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound) - CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve) - CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound) - CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map) - CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_PVS, m_clip_map) - CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world) - CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp) - CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp) - CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents) - CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world) - CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def) - CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font) - CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list) - CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def) - CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize) - CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon) - CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx) - CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table) - CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file) - CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table) - - default: - assert(false); - break; - } - - return nullptr; - -#undef CASE_ADD_TO_POOL -} - -XAssetInfoGeneric* GameAssetPoolIW3::GetAsset(const asset_type_t type, const std::string& name) const -{ -#define CASE_GET_ASSET(assetType, poolName) \ - case assetType: \ - { \ - if (poolName) \ - return (poolName)->GetAsset(std::move(name)); \ - break; \ - } - - switch (type) - { - CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset) - 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) - CASE_GET_ASSET(ASSET_TYPE_SOUND_CURVE, m_sound_curve) - CASE_GET_ASSET(ASSET_TYPE_LOADED_SOUND, m_loaded_sound) - 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_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_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) - - default: - assert(false); - break; - } - - return nullptr; - -#undef CASE_GET_ASSET -} diff --git a/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.h b/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.h deleted file mode 100644 index 8a023886..00000000 --- a/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include "Game/IW3/IW3.h" -#include "Pool/AssetPool.h" -#include "Pool/ZoneAssetPools.h" - -#include - -class GameAssetPoolIW3 final : public ZoneAssetPools -{ -public: - std::unique_ptr> m_phys_preset; - std::unique_ptr> m_xanim_parts; - std::unique_ptr> m_xmodel; - std::unique_ptr> m_material; - std::unique_ptr> m_technique_set; - std::unique_ptr> m_image; - std::unique_ptr> m_sound; - std::unique_ptr> m_sound_curve; - std::unique_ptr> m_loaded_sound; - std::unique_ptr> m_clip_map; - std::unique_ptr> m_com_world; - std::unique_ptr> m_game_world_sp; - std::unique_ptr> m_game_world_mp; - std::unique_ptr> m_map_ents; - std::unique_ptr> m_gfx_world; - std::unique_ptr> m_gfx_light_def; - std::unique_ptr> m_font; - std::unique_ptr> m_menu_list; - std::unique_ptr> m_menu_def; - std::unique_ptr> m_localize; - std::unique_ptr> m_weapon; - std::unique_ptr> m_fx; - std::unique_ptr> m_fx_impact_table; - std::unique_ptr> m_raw_file; - std::unique_ptr> m_string_table; - - GameAssetPoolIW3(Zone* zone, zone_priority_t priority); - ~GameAssetPoolIW3() override = default; - - [[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override; - -protected: - XAssetInfoGeneric* AddAssetToPool(std::unique_ptr xAssetInfo) override; - -private: - zone_priority_t m_priority; -}; diff --git a/src/ZoneCommon/Game/IW3/Zone/Definition/ZoneDefWriterIW3.cpp b/src/ZoneCommon/Game/IW3/Zone/Definition/ZoneDefWriterIW3.cpp index f1d22693..be9c658e 100644 --- a/src/ZoneCommon/Game/IW3/Zone/Definition/ZoneDefWriterIW3.cpp +++ b/src/ZoneCommon/Game/IW3/Zone/Definition/ZoneDefWriterIW3.cpp @@ -1,8 +1,6 @@ #include "ZoneDefWriterIW3.h" -#include "Game/IW3/GameAssetPoolIW3.h" - -#include +#include "Game/IW3/IW3.h" using namespace IW3; @@ -11,17 +9,13 @@ void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const Zone void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Zone& zone) const { const auto* game = IGame::GetGameById(zone.m_game_id); - const auto* pools = dynamic_cast(zone.m_pools.get()); - - assert(pools); - if (!pools) - return; // Localized strings are all collected in one string file. So only add this to the zone file. - if (!pools->m_localize->m_asset_lookup.empty()) + auto localizePoolAssets = zone.m_pools.PoolAssets(); + if (localizePoolAssets.begin() != localizePoolAssets.end()) stream.WriteEntry(*game->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name); - for (const auto& asset : *pools) + for (const auto& asset : zone.m_pools) { switch (asset->m_type) { diff --git a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp deleted file mode 100644 index 8b6c0fbd..00000000 --- a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp +++ /dev/null @@ -1,170 +0,0 @@ -#include "GameAssetPoolIW4.h" - -#include "Pool/AssetPoolDynamic.h" - -#include - -using namespace IW4; - -GameAssetPoolIW4::GameAssetPoolIW4(Zone* zone, const zone_priority_t priority) - : ZoneAssetPools(zone), - m_priority(priority) -{ -#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) -{ -#define CASE_ADD_TO_POOL(assetType, poolName) \ - case assetType: \ - { \ - assert(poolName); \ - return (poolName)->AddAsset(std::unique_ptr>( \ - static_cast*>(xAssetInfo.release()))); \ - } - - switch (static_cast(xAssetInfo->m_type)) - { - CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset) - CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap) - CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts) - CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel) - CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material) - CASE_ADD_TO_POOL(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader) - CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader) - CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl) - CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set) - CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image) - CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound) - CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve) - CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound) - CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_SP, m_clip_map) - CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_MP, m_clip_map) - CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world) - CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp) - CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp) - CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents) - CASE_ADD_TO_POOL(ASSET_TYPE_FXWORLD, m_fx_world) - CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world) - CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def) - CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font) - CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list) - CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def) - CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize) - CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon) - CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx) - CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table) - CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file) - CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table) - CASE_ADD_TO_POOL(ASSET_TYPE_LEADERBOARD, m_leaderboard) - CASE_ADD_TO_POOL(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set) - CASE_ADD_TO_POOL(ASSET_TYPE_TRACER, m_tracer) - CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLE, m_vehicle) - CASE_ADD_TO_POOL(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents) - - default: - assert(false); - break; - } - - return nullptr; - -#undef CASE_ADD_TO_POOL -} - -XAssetInfoGeneric* GameAssetPoolIW4::GetAsset(const asset_type_t type, const std::string& name) const -{ -#define CASE_GET_ASSET(assetType, poolName) \ - case assetType: \ - { \ - if (poolName) \ - return (poolName)->GetAsset(name); \ - break; \ - } - - switch (type) - { - CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset) - CASE_GET_ASSET(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap) - 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_PIXELSHADER, m_material_pixel_shader) - CASE_GET_ASSET(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader) - CASE_GET_ASSET(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl) - 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) - CASE_GET_ASSET(ASSET_TYPE_SOUND_CURVE, m_sound_curve) - CASE_GET_ASSET(ASSET_TYPE_LOADED_SOUND, m_loaded_sound) - CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_SP, m_clip_map) - CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_MP, 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_FXWORLD, m_fx_world) - 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_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_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_STRUCTURED_DATA_DEF, m_structed_data_def_set) - CASE_GET_ASSET(ASSET_TYPE_TRACER, m_tracer) - CASE_GET_ASSET(ASSET_TYPE_VEHICLE, m_vehicle) - CASE_GET_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents) - - default: - assert(false); - break; - } - - return nullptr; - -#undef CASE_GET_ASSET -} diff --git a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h deleted file mode 100644 index 9c900d5a..00000000 --- a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h +++ /dev/null @@ -1,58 +0,0 @@ -#pragma once - -#include "Game/IW4/IW4.h" -#include "Pool/AssetPool.h" -#include "Pool/ZoneAssetPools.h" - -#include - -class GameAssetPoolIW4 final : public ZoneAssetPools -{ -public: - std::unique_ptr> m_phys_preset; - std::unique_ptr> m_phys_collmap; - std::unique_ptr> m_xanim_parts; - std::unique_ptr> m_xmodel; - std::unique_ptr> m_material; - std::unique_ptr> m_material_pixel_shader; - std::unique_ptr> m_material_vertex_shader; - std::unique_ptr> m_material_vertex_decl; - std::unique_ptr> m_technique_set; - std::unique_ptr> m_image; - std::unique_ptr> m_sound; - std::unique_ptr> m_sound_curve; - std::unique_ptr> m_loaded_sound; - std::unique_ptr> m_clip_map; - std::unique_ptr> m_com_world; - std::unique_ptr> m_game_world_sp; - std::unique_ptr> m_game_world_mp; - std::unique_ptr> m_map_ents; - std::unique_ptr> m_fx_world; - std::unique_ptr> m_gfx_world; - std::unique_ptr> m_gfx_light_def; - std::unique_ptr> m_font; - std::unique_ptr> m_menu_list; - std::unique_ptr> m_menu_def; - std::unique_ptr> m_localize; - std::unique_ptr> m_weapon; - std::unique_ptr> m_fx; - std::unique_ptr> m_fx_impact_table; - std::unique_ptr> m_raw_file; - std::unique_ptr> m_string_table; - std::unique_ptr> m_leaderboard; - std::unique_ptr> m_structed_data_def_set; - std::unique_ptr> m_tracer; - std::unique_ptr> m_vehicle; - std::unique_ptr> m_addon_map_ents; - - GameAssetPoolIW4(Zone* zone, zone_priority_t priority); - ~GameAssetPoolIW4() override = default; - - [[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override; - -protected: - XAssetInfoGeneric* AddAssetToPool(std::unique_ptr xAssetInfo) override; - -private: - zone_priority_t m_priority; -}; diff --git a/src/ZoneCommon/Game/IW4/Zone/Definition/ZoneDefWriterIW4.cpp b/src/ZoneCommon/Game/IW4/Zone/Definition/ZoneDefWriterIW4.cpp index 778e08ad..805aa822 100644 --- a/src/ZoneCommon/Game/IW4/Zone/Definition/ZoneDefWriterIW4.cpp +++ b/src/ZoneCommon/Game/IW4/Zone/Definition/ZoneDefWriterIW4.cpp @@ -1,8 +1,6 @@ #include "ZoneDefWriterIW4.h" -#include "Game/IW4/GameAssetPoolIW4.h" - -#include +#include "Game/IW4/IW4.h" using namespace IW4; @@ -11,17 +9,13 @@ void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const Zone void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Zone& zone) const { const auto* game = IGame::GetGameById(zone.m_game_id); - const auto* pools = dynamic_cast(zone.m_pools.get()); - - assert(pools); - if (!pools) - return; // Localized strings are all collected in one string file. So only add this to the zone file. - if (!pools->m_localize->m_asset_lookup.empty()) + auto localizePoolAssets = zone.m_pools.PoolAssets(); + if (localizePoolAssets.begin() != localizePoolAssets.end()) stream.WriteEntry(*game->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name); - for (const auto& asset : *pools) + for (const auto& asset : zone.m_pools) { switch (asset->m_type) { diff --git a/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.cpp b/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.cpp deleted file mode 100644 index 6fd87bfa..00000000 --- a/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.cpp +++ /dev/null @@ -1,183 +0,0 @@ -#include "GameAssetPoolIW5.h" - -#include "Pool/AssetPoolDynamic.h" - -#include - -using namespace IW5; - -GameAssetPoolIW5::GameAssetPoolIW5(Zone* zone, const zone_priority_t priority) - : ZoneAssetPools(zone), - m_priority(priority) -{ -#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_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 INIT_POOL -} - -XAssetInfoGeneric* GameAssetPoolIW5::AddAssetToPool(std::unique_ptr xAssetInfo) -{ -#define CASE_ADD_TO_POOL(assetType, poolName) \ - case assetType: \ - { \ - assert(poolName); \ - return (poolName)->AddAsset(std::unique_ptr>( \ - static_cast*>(xAssetInfo.release()))); \ - } - - switch (static_cast(xAssetInfo->m_type)) - { - CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset) - CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap) - CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts) - CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs) - CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel) - CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material) - CASE_ADD_TO_POOL(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader) - CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader) - CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl) - CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set) - CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image) - CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound) - CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve) - CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound) - CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map) - CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world) - CASE_ADD_TO_POOL(ASSET_TYPE_GLASSWORLD, m_glass_world) - CASE_ADD_TO_POOL(ASSET_TYPE_PATHDATA, m_path_data) - CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track) - CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents) - CASE_ADD_TO_POOL(ASSET_TYPE_FXWORLD, m_fx_world) - CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world) - CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def) - CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font) - CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list) - CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def) - CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize) - CASE_ADD_TO_POOL(ASSET_TYPE_ATTACHMENT, m_attachment) - CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon) - CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx) - CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table) - CASE_ADD_TO_POOL(ASSET_TYPE_SURFACE_FX, m_surface_fx_table) - CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file) - CASE_ADD_TO_POOL(ASSET_TYPE_SCRIPTFILE, m_script_file) - CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table) - CASE_ADD_TO_POOL(ASSET_TYPE_LEADERBOARD, m_leaderboard) - CASE_ADD_TO_POOL(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set) - CASE_ADD_TO_POOL(ASSET_TYPE_TRACER, m_tracer) - CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLE, m_vehicle) - CASE_ADD_TO_POOL(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents) - - default: - assert(false); - break; - } - - return nullptr; - -#undef CASE_ADD_TO_POOL -} - -XAssetInfoGeneric* GameAssetPoolIW5::GetAsset(const asset_type_t type, const std::string& name) const -{ -#define CASE_GET_ASSET(assetType, poolName) \ - case assetType: \ - { \ - if (poolName) \ - return (poolName)->GetAsset(name); \ - break; \ - } - - switch (type) - { - CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset) - CASE_GET_ASSET(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap) - CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts) - CASE_GET_ASSET(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs) - CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel) - CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material) - CASE_GET_ASSET(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader) - CASE_GET_ASSET(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader) - CASE_GET_ASSET(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl) - 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) - CASE_GET_ASSET(ASSET_TYPE_SOUND_CURVE, m_sound_curve) - CASE_GET_ASSET(ASSET_TYPE_LOADED_SOUND, m_loaded_sound) - CASE_GET_ASSET(ASSET_TYPE_CLIPMAP, m_clip_map) - CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world) - CASE_GET_ASSET(ASSET_TYPE_GLASSWORLD, m_glass_world) - CASE_GET_ASSET(ASSET_TYPE_PATHDATA, m_path_data) - CASE_GET_ASSET(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track) - CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents) - CASE_GET_ASSET(ASSET_TYPE_FXWORLD, m_fx_world) - 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_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_ATTACHMENT, m_attachment) - CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon) - CASE_GET_ASSET(ASSET_TYPE_FX, m_fx) - CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table) - CASE_GET_ASSET(ASSET_TYPE_SURFACE_FX, m_surface_fx_table) - CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file) - CASE_GET_ASSET(ASSET_TYPE_SCRIPTFILE, m_script_file) - CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table) - CASE_GET_ASSET(ASSET_TYPE_LEADERBOARD, m_leaderboard) - CASE_GET_ASSET(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set) - CASE_GET_ASSET(ASSET_TYPE_TRACER, m_tracer) - CASE_GET_ASSET(ASSET_TYPE_VEHICLE, m_vehicle) - CASE_GET_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents) - - default: - assert(false); - break; - } - - return nullptr; - -#undef CASE_GET_ASSET -} diff --git a/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.h b/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.h deleted file mode 100644 index 43157699..00000000 --- a/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.h +++ /dev/null @@ -1,63 +0,0 @@ -#pragma once - -#include "Game/IW5/IW5.h" -#include "Pool/AssetPool.h" -#include "Pool/ZoneAssetPools.h" - -#include - -class GameAssetPoolIW5 final : public ZoneAssetPools -{ -public: - std::unique_ptr> m_phys_preset; - std::unique_ptr> m_phys_collmap; - std::unique_ptr> m_xanim_parts; - std::unique_ptr> m_xmodel_surfs; - std::unique_ptr> m_xmodel; - std::unique_ptr> m_material; - std::unique_ptr> m_material_pixel_shader; - std::unique_ptr> m_material_vertex_shader; - std::unique_ptr> m_material_vertex_decl; - std::unique_ptr> m_technique_set; - std::unique_ptr> m_image; - std::unique_ptr> m_sound; - std::unique_ptr> m_sound_curve; - std::unique_ptr> m_loaded_sound; - std::unique_ptr> m_clip_map; - std::unique_ptr> m_com_world; - std::unique_ptr> m_glass_world; - std::unique_ptr> m_path_data; - std::unique_ptr> m_vehicle_track; - std::unique_ptr> m_map_ents; - std::unique_ptr> m_fx_world; - std::unique_ptr> m_gfx_world; - std::unique_ptr> m_gfx_light_def; - std::unique_ptr> m_font; - std::unique_ptr> m_menu_list; - std::unique_ptr> m_menu_def; - std::unique_ptr> m_localize; - std::unique_ptr> m_attachment; - std::unique_ptr> m_weapon; - std::unique_ptr> m_fx; - std::unique_ptr> m_fx_impact_table; - std::unique_ptr> m_surface_fx_table; - std::unique_ptr> m_raw_file; - std::unique_ptr> m_script_file; - std::unique_ptr> m_string_table; - std::unique_ptr> m_leaderboard; - std::unique_ptr> m_structed_data_def_set; - std::unique_ptr> m_tracer; - std::unique_ptr> m_vehicle; - std::unique_ptr> m_addon_map_ents; - - GameAssetPoolIW5(Zone* zone, zone_priority_t priority); - ~GameAssetPoolIW5() override = default; - - [[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override; - -protected: - XAssetInfoGeneric* AddAssetToPool(std::unique_ptr xAssetInfo) override; - -private: - zone_priority_t m_priority; -}; diff --git a/src/ZoneCommon/Game/IW5/Zone/Definition/ZoneDefWriterIW5.cpp b/src/ZoneCommon/Game/IW5/Zone/Definition/ZoneDefWriterIW5.cpp index 948b97c1..6c77ee31 100644 --- a/src/ZoneCommon/Game/IW5/Zone/Definition/ZoneDefWriterIW5.cpp +++ b/src/ZoneCommon/Game/IW5/Zone/Definition/ZoneDefWriterIW5.cpp @@ -1,8 +1,6 @@ #include "ZoneDefWriterIW5.h" -#include "Game/IW5/GameAssetPoolIW5.h" - -#include +#include "Game/IW5/AssetMarkerIW5.h" using namespace IW5; @@ -11,17 +9,13 @@ void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const Zone void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Zone& zone) const { const auto* game = IGame::GetGameById(zone.m_game_id); - const auto* pools = dynamic_cast(zone.m_pools.get()); - - assert(pools); - if (!pools) - return; // Localized strings are all collected in one string file. So only add this to the zone file. - if (!pools->m_localize->m_asset_lookup.empty()) + auto localizePoolAssets = zone.m_pools.PoolAssets(); + if (localizePoolAssets.begin() != localizePoolAssets.end()) stream.WriteEntry(*game->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name); - for (const auto& asset : *pools) + for (const auto& asset : zone.m_pools) { switch (asset->m_type) { diff --git a/src/ZoneCommon/Game/T5/GameAssetPoolT5.cpp b/src/ZoneCommon/Game/T5/GameAssetPoolT5.cpp deleted file mode 100644 index 7af93bd0..00000000 --- a/src/ZoneCommon/Game/T5/GameAssetPoolT5.cpp +++ /dev/null @@ -1,161 +0,0 @@ -#include "GameAssetPoolT5.h" - -#include "Pool/AssetPoolDynamic.h" - -#include - -using namespace T5; - -GameAssetPoolT5::GameAssetPoolT5(Zone* zone, const zone_priority_t priority) - : ZoneAssetPools(zone), - m_priority(priority) -{ -#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) -{ -#define CASE_ADD_TO_POOL(assetType, poolName) \ - case assetType: \ - { \ - assert(poolName); \ - return (poolName)->AddAsset(std::unique_ptr>( \ - static_cast*>(xAssetInfo.release()))); \ - } - - switch (static_cast(xAssetInfo->m_type)) - { - CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset) - CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints) - CASE_ADD_TO_POOL(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def) - CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts) - CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel) - CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material) - CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set) - CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image) - CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound_bank) - CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_PATCH, m_sound_patch) - CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map) - CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_PVS, m_clip_map) - CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world) - CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp) - CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp) - CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents) - CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world) - CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def) - CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font) - CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list) - CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def) - CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize) - CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon) - CASE_ADD_TO_POOL(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals) - CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx) - CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table) - CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file) - CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table) - CASE_ADD_TO_POOL(ASSET_TYPE_PACK_INDEX, m_pack_index) - CASE_ADD_TO_POOL(ASSET_TYPE_XGLOBALS, m_xglobals) - CASE_ADD_TO_POOL(ASSET_TYPE_DDL, m_ddl) - CASE_ADD_TO_POOL(ASSET_TYPE_GLASSES, m_glasses) - CASE_ADD_TO_POOL(ASSET_TYPE_EMBLEMSET, m_emblem_set) - - default: - assert(false); - break; - } - - return nullptr; - -#undef CASE_ADD_TO_POOL -} - -XAssetInfoGeneric* GameAssetPoolT5::GetAsset(const asset_type_t type, const std::string& name) const -{ -#define CASE_GET_ASSET(assetType, poolName) \ - case assetType: \ - { \ - if (poolName) \ - return (poolName)->GetAsset(name); \ - break; \ - } - - 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_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_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_PACK_INDEX, m_pack_index) - 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) - - default: - assert(false); - break; - } - - return nullptr; - -#undef CASE_GET_ASSET -} diff --git a/src/ZoneCommon/Game/T5/GameAssetPoolT5.h b/src/ZoneCommon/Game/T5/GameAssetPoolT5.h deleted file mode 100644 index 08ee4567..00000000 --- a/src/ZoneCommon/Game/T5/GameAssetPoolT5.h +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once - -#include "Game/T5/T5.h" -#include "Pool/AssetPool.h" -#include "Pool/ZoneAssetPools.h" - -#include - -class GameAssetPoolT5 final : public ZoneAssetPools -{ -public: - std::unique_ptr> m_phys_preset; - std::unique_ptr> m_phys_constraints; - std::unique_ptr> m_destructible_def; - std::unique_ptr> m_xanim_parts; - std::unique_ptr> m_xmodel; - std::unique_ptr> m_material; - std::unique_ptr> m_technique_set; - std::unique_ptr> m_image; - std::unique_ptr> m_sound_bank; - std::unique_ptr> m_sound_patch; - std::unique_ptr> m_clip_map; - std::unique_ptr> m_com_world; - std::unique_ptr> m_game_world_sp; - std::unique_ptr> m_game_world_mp; - std::unique_ptr> m_map_ents; - std::unique_ptr> m_gfx_world; - std::unique_ptr> m_gfx_light_def; - std::unique_ptr> m_font; - std::unique_ptr> m_menu_list; - std::unique_ptr> m_menu_def; - std::unique_ptr> m_localize; - std::unique_ptr> m_weapon; - std::unique_ptr> m_snd_driver_globals; - std::unique_ptr> m_fx; - std::unique_ptr> m_fx_impact_table; - std::unique_ptr> m_raw_file; - std::unique_ptr> m_string_table; - std::unique_ptr> m_pack_index; - std::unique_ptr> m_xglobals; - std::unique_ptr> m_ddl; - std::unique_ptr> m_glasses; - std::unique_ptr> m_emblem_set; - - GameAssetPoolT5(Zone* zone, zone_priority_t priority); - ~GameAssetPoolT5() override = default; - - [[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override; - -protected: - XAssetInfoGeneric* AddAssetToPool(std::unique_ptr xAssetInfo) override; - -private: - zone_priority_t m_priority; -}; diff --git a/src/ZoneCommon/Game/T5/Zone/Definition/ZoneDefWriterT5.cpp b/src/ZoneCommon/Game/T5/Zone/Definition/ZoneDefWriterT5.cpp index 4aac8f64..a079938d 100644 --- a/src/ZoneCommon/Game/T5/Zone/Definition/ZoneDefWriterT5.cpp +++ b/src/ZoneCommon/Game/T5/Zone/Definition/ZoneDefWriterT5.cpp @@ -1,8 +1,6 @@ #include "ZoneDefWriterT5.h" -#include "Game/T5/GameAssetPoolT5.h" - -#include +#include "Game/T5/AssetMarkerT5.h" using namespace T5; @@ -11,17 +9,13 @@ void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const Zone void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Zone& zone) const { const auto* game = IGame::GetGameById(zone.m_game_id); - const auto* pools = dynamic_cast(zone.m_pools.get()); - - assert(pools); - if (!pools) - return; // Localized strings are all collected in one string file. So only add this to the zone file. - if (!pools->m_localize->m_asset_lookup.empty()) + auto localizePoolAssets = zone.m_pools.PoolAssets(); + if (localizePoolAssets.begin() != localizePoolAssets.end()) stream.WriteEntry(*game->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name); - for (const auto& asset : *pools) + for (const auto& asset : zone.m_pools) { switch (asset->m_type) { diff --git a/src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp b/src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp deleted file mode 100644 index 8c7a59ca..00000000 --- a/src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp +++ /dev/null @@ -1,209 +0,0 @@ -#include "GameAssetPoolT6.h" - -#include "Pool/AssetPoolDynamic.h" - -#include - -using namespace T6; - -GameAssetPoolT6::GameAssetPoolT6(Zone* zone, const zone_priority_t priority) - : ZoneAssetPools(zone), - m_priority(priority) -{ -#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_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 INIT_POOL -} - -XAssetInfoGeneric* GameAssetPoolT6::AddAssetToPool(std::unique_ptr xAssetInfo) -{ -#define CASE_ADD_TO_POOL(assetType, poolName) \ - case assetType: \ - { \ - assert(poolName); \ - return (poolName)->AddAsset(std::unique_ptr>( \ - static_cast*>(xAssetInfo.release()))); \ - } - - switch (static_cast(xAssetInfo->m_type)) - { - CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset) - CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints) - CASE_ADD_TO_POOL(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def) - CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts) - CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel) - CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material) - CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set) - CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image) - CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound_bank) - CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_PATCH, m_sound_patch) - CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map) - CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_PVS, m_clip_map) - CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world) - CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp) - CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp) - CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents) - CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world) - CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def) - CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font) - CASE_ADD_TO_POOL(ASSET_TYPE_FONTICON, m_font_icon) - CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list) - CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def) - CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize) - CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon) - CASE_ADD_TO_POOL(ASSET_TYPE_ATTACHMENT, m_attachment) - CASE_ADD_TO_POOL(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique) - CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON_CAMO, m_camo) - CASE_ADD_TO_POOL(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals) - CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx) - CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table) - CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file) - CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table) - CASE_ADD_TO_POOL(ASSET_TYPE_LEADERBOARD, m_leaderboard) - CASE_ADD_TO_POOL(ASSET_TYPE_XGLOBALS, m_xglobals) - CASE_ADD_TO_POOL(ASSET_TYPE_DDL, m_ddl) - CASE_ADD_TO_POOL(ASSET_TYPE_GLASSES, m_glasses) - CASE_ADD_TO_POOL(ASSET_TYPE_EMBLEMSET, m_emblem_set) - CASE_ADD_TO_POOL(ASSET_TYPE_SCRIPTPARSETREE, m_script) - CASE_ADD_TO_POOL(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs) - CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLEDEF, m_vehicle) - CASE_ADD_TO_POOL(ASSET_TYPE_MEMORYBLOCK, m_memory_block) - CASE_ADD_TO_POOL(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents) - CASE_ADD_TO_POOL(ASSET_TYPE_TRACER, m_tracer) - CASE_ADD_TO_POOL(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts) - CASE_ADD_TO_POOL(ASSET_TYPE_QDB, m_qdb) - CASE_ADD_TO_POOL(ASSET_TYPE_SLUG, m_slug) - CASE_ADD_TO_POOL(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table) - CASE_ADD_TO_POOL(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table) - CASE_ADD_TO_POOL(ASSET_TYPE_ZBARRIER, m_zbarrier) - - default: - assert(false); - break; - } - - return nullptr; - -#undef CASE_ADD_TO_POOL -} - -XAssetInfoGeneric* GameAssetPoolT6::GetAsset(const asset_type_t type, const std::string& name) const -{ -#define CASE_GET_ASSET(assetType, poolName) \ - case assetType: \ - { \ - if (poolName) \ - return (poolName)->GetAsset(name); \ - break; \ - } - - 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) - - default: - assert(false); - break; - } - - return nullptr; - -#undef CASE_GET_ASSET -} diff --git a/src/ZoneCommon/Game/T6/GameAssetPoolT6.h b/src/ZoneCommon/Game/T6/GameAssetPoolT6.h deleted file mode 100644 index 90e595f2..00000000 --- a/src/ZoneCommon/Game/T6/GameAssetPoolT6.h +++ /dev/null @@ -1,71 +0,0 @@ -#pragma once - -#include "Game/T6/T6.h" -#include "Pool/AssetPool.h" -#include "Pool/ZoneAssetPools.h" - -#include - -class GameAssetPoolT6 final : public ZoneAssetPools -{ -public: - std::unique_ptr> m_phys_preset; - std::unique_ptr> m_phys_constraints; - std::unique_ptr> m_destructible_def; - std::unique_ptr> m_xanim_parts; - std::unique_ptr> m_xmodel; - std::unique_ptr> m_material; - std::unique_ptr> m_technique_set; - std::unique_ptr> m_image; - std::unique_ptr> m_sound_bank; - std::unique_ptr> m_sound_patch; - std::unique_ptr> m_clip_map; - std::unique_ptr> m_com_world; - std::unique_ptr> m_game_world_sp; - std::unique_ptr> m_game_world_mp; - std::unique_ptr> m_map_ents; - std::unique_ptr> m_gfx_world; - std::unique_ptr> m_gfx_light_def; - std::unique_ptr> m_font; - std::unique_ptr> m_font_icon; - std::unique_ptr> m_menu_list; - std::unique_ptr> m_menu_def; - std::unique_ptr> m_localize; - std::unique_ptr> m_weapon; - std::unique_ptr> m_attachment; - std::unique_ptr> m_attachment_unique; - std::unique_ptr> m_camo; - std::unique_ptr> m_snd_driver_globals; - std::unique_ptr> m_fx; - std::unique_ptr> m_fx_impact_table; - std::unique_ptr> m_raw_file; - std::unique_ptr> m_string_table; - std::unique_ptr> m_leaderboard; - std::unique_ptr> m_xglobals; - std::unique_ptr> m_ddl; - std::unique_ptr> m_glasses; - std::unique_ptr> m_emblem_set; - std::unique_ptr> m_script; - std::unique_ptr> m_key_value_pairs; - std::unique_ptr> m_vehicle; - std::unique_ptr> m_memory_block; - std::unique_ptr> m_addon_map_ents; - std::unique_ptr> m_tracer; - std::unique_ptr> m_skinned_verts; - std::unique_ptr> m_qdb; - std::unique_ptr> m_slug; - std::unique_ptr> m_footstep_table; - std::unique_ptr> m_footstep_fx_table; - std::unique_ptr> m_zbarrier; - - GameAssetPoolT6(Zone* zone, zone_priority_t priority); - ~GameAssetPoolT6() override = default; - - [[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override; - -protected: - XAssetInfoGeneric* AddAssetToPool(std::unique_ptr xAssetInfo) override; - -private: - zone_priority_t m_priority; -}; diff --git a/src/ZoneCommon/Game/T6/Zone/Definition/ZoneDefWriterT6.cpp b/src/ZoneCommon/Game/T6/Zone/Definition/ZoneDefWriterT6.cpp index ef5d6520..dd0dabd0 100644 --- a/src/ZoneCommon/Game/T6/Zone/Definition/ZoneDefWriterT6.cpp +++ b/src/ZoneCommon/Game/T6/Zone/Definition/ZoneDefWriterT6.cpp @@ -1,9 +1,7 @@ #include "ZoneDefWriterT6.h" #include "Game/T6/CommonT6.h" -#include "Game/T6/GameAssetPoolT6.h" -#include #include #include @@ -15,12 +13,12 @@ namespace { public: std::string m_key; - int m_hash; + unsigned m_hash; explicit KeyValuePairKnownKey(std::string key) { m_key = std::move(key); - m_hash = Common::Com_HashKey(m_key.c_str(), 64); + m_hash = static_cast(Common::Com_HashKey(m_key.c_str(), 64)); } }; @@ -31,7 +29,7 @@ namespace KeyValuePairKnownKey("initial_materials"), }; - void WriteKeyValuePair(ZoneDefinitionOutputStream& stream, const KeyValuePair& kvp) + void WriteKeyValuePair(const ZoneDefinitionOutputStream& stream, const KeyValuePair& kvp) { for (const auto& knownKey : KEY_VALUE_PAIR_KNOWN_KEYS) { @@ -50,10 +48,10 @@ namespace void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const Zone& zone) const { - const auto* assetPoolT6 = dynamic_cast(zone.m_pools.get()); - if (assetPoolT6 && !assetPoolT6->m_key_value_pairs->m_asset_lookup.empty()) + auto kvpPoolAssets = zone.m_pools.PoolAssets(); + if (kvpPoolAssets.begin() != kvpPoolAssets.end()) { - for (const auto* kvpAsset : *assetPoolT6->m_key_value_pairs) + for (const auto* kvpAsset : kvpPoolAssets) { const auto* keyValuePairs = kvpAsset->Asset(); for (auto varIndex = 0u; varIndex < keyValuePairs->numVariables; varIndex++) @@ -67,17 +65,13 @@ void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const Zone void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Zone& zone) const { const auto* game = IGame::GetGameById(zone.m_game_id); - const auto* pools = dynamic_cast(zone.m_pools.get()); - - assert(pools); - if (!pools) - return; // Localized strings are all collected in one string file. So only add this to the zone file. - if (!pools->m_localize->m_asset_lookup.empty()) + auto localizePoolAssets = zone.m_pools.PoolAssets(); + if (localizePoolAssets.begin() != localizePoolAssets.end()) stream.WriteEntry(*game->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name); - for (const auto& asset : *pools) + for (const auto& asset : zone.m_pools) { switch (asset->m_type) { diff --git a/src/ZoneCommon/Marking/BaseAssetMarker.h b/src/ZoneCommon/Marking/BaseAssetMarker.h index 2a0cd3f3..c00c7915 100644 --- a/src/ZoneCommon/Marking/BaseAssetMarker.h +++ b/src/ZoneCommon/Marking/BaseAssetMarker.h @@ -11,13 +11,11 @@ class BaseAssetMarker protected: explicit BaseAssetMarker(AssetVisitor& visitor); - template void Mark_Dependency(std::add_lvalue_reference_t> asset) + template void Mark_Dependency(std::add_lvalue_reference_t> asset) { - static_assert(std::is_base_of_v); - - const auto result = m_visitor.Visit_Dependency(AssetType::EnumEntry, AssetName(*asset)); + const auto result = m_visitor.Visit_Dependency(Asset_t::EnumEntry, AssetName(*asset)); if (result.has_value()) - asset = static_cast>((*result)->m_ptr); + asset = static_cast>((*result)->m_ptr); } void Mark_ScriptString(scr_string_t& scriptString) const; @@ -29,9 +27,8 @@ protected: AssetVisitor& m_visitor; }; -template struct AssetMarkerWrapper +template struct AssetMarkerWrapper { - static_assert(std::is_base_of_v); // using WrapperClass = WrapperClass; }; @@ -40,6 +37,5 @@ template using AssetMarker = AssetMarkerWrapper:: #define DEFINE_MARKER_CLASS_FOR_ASSET(asset, markerClass) \ template<> struct AssetMarkerWrapper \ { \ - static_assert(std::is_base_of_v); \ using WrapperClass = markerClass; \ }; diff --git a/src/ZoneCommon/Pool/AssetPool.cpp b/src/ZoneCommon/Pool/AssetPool.cpp new file mode 100644 index 00000000..2f04fce0 --- /dev/null +++ b/src/ZoneCommon/Pool/AssetPool.cpp @@ -0,0 +1,193 @@ +#include "AssetPool.h" + +#include "GlobalAssetPool.h" + +#include +#include + +AssetPool::Iterator::Iterator(std::unordered_map::iterator i) + : m_iterator(std::move(i)) +{ +} + +bool AssetPool::Iterator::operator!=(const Iterator& rhs) const +{ + return m_iterator != rhs.m_iterator; +} + +XAssetInfoGeneric* AssetPool::Iterator::operator*() const +{ + return m_iterator.operator*().second; +} + +void AssetPool::Iterator::operator++() +{ + ++m_iterator; +} + +AssetPool::CIterator::CIterator(std::unordered_map::const_iterator i) + : m_iterator(std::move(i)) +{ +} + +bool AssetPool::CIterator::operator!=(const CIterator& rhs) const +{ + return m_iterator != rhs.m_iterator; +} + +const XAssetInfoGeneric* AssetPool::CIterator::operator*() const +{ + return m_iterator.operator*().second; +} + +void AssetPool::CIterator::operator++() +{ + ++m_iterator; +} + +// +// AssetPool +// + +XAssetInfoGeneric* AssetPool::AddAsset(std::unique_ptr xAssetInfo) +{ + const auto normalizedName = XAssetInfoGeneric::NormalizeAssetName(xAssetInfo->m_name); + + auto* pAssetInfo = xAssetInfo.get(); + m_asset_lookup[normalizedName] = pAssetInfo; + m_assets.emplace_back(std::move(xAssetInfo)); + + return pAssetInfo; +} + +XAssetInfoGeneric* AssetPool::GetAsset(const std::string& name) +{ + const auto normalizedName = XAssetInfoGeneric::NormalizeAssetName(name); + + const auto foundAsset = m_asset_lookup.find(normalizedName); + if (foundAsset == m_asset_lookup.end()) + return nullptr; + + return foundAsset->second; +} + +size_t AssetPool::size() const +{ + return m_asset_lookup.size(); +} + +bool AssetPool::empty() const +{ + return m_asset_lookup.empty(); +} + +AssetPool::Iterator AssetPool::begin() +{ + return Iterator(m_asset_lookup.begin()); +} + +AssetPool::Iterator AssetPool::end() +{ + return Iterator(m_asset_lookup.end()); +} + +AssetPool::CIterator AssetPool::begin() const +{ + return CIterator(m_asset_lookup.cbegin()); +} + +AssetPool::CIterator AssetPool::end() const +{ + return CIterator(m_asset_lookup.cend()); +} + +// +// ZoneAssetPools +// + +ZoneAssetPools::ZoneAssetPools(Zone& zone, const zone_priority_t priority) + : m_zone(zone) +{ + const auto assetTypeCount = IGame::GetGameById(zone.m_game_id)->GetAssetTypeCount(); + const auto* gameGlobalAssetPools = GameGlobalAssetPools::GetGlobalPoolsForGame(zone.m_game_id); + + m_asset_pools.resize(assetTypeCount); + for (asset_type_t assetType = 0; assetType < assetTypeCount; assetType++) + { + m_asset_pools[assetType] = std::make_unique(); + gameGlobalAssetPools->LinkAssetPool(assetType, m_asset_pools[assetType].get(), priority); + } +} + +ZoneAssetPools::~ZoneAssetPools() +{ + const auto assetTypeCount = IGame::GetGameById(m_zone.m_game_id)->GetAssetTypeCount(); + const auto* gameGlobalAssetPools = GameGlobalAssetPools::GetGlobalPoolsForGame(m_zone.m_game_id); + + assert(assetTypeCount == m_asset_pools.size()); + for (asset_type_t assetType = 0; assetType < assetTypeCount; assetType++) + { + assert(m_asset_pools[assetType]); + gameGlobalAssetPools->UnlinkAssetPool(assetType, m_asset_pools[assetType].get()); + } +} + +XAssetInfoGeneric* ZoneAssetPools::AddAsset(const asset_type_t type, + std::string name, + void* asset, + std::vector dependencies, + std::vector usedScriptStrings, + std::vector indirectAssetReferences) +{ + return AddAsset(std::make_unique( + type, std::move(name), asset, std::move(dependencies), std::move(usedScriptStrings), std::move(indirectAssetReferences), &m_zone)); +} + +XAssetInfoGeneric* ZoneAssetPools::AddAsset(std::unique_ptr xAssetInfo) +{ + const auto type = xAssetInfo->m_type; + assert(m_asset_pools.size() > type); + + auto* assetInfo = m_asset_pools[type]->AddAsset(std::move(xAssetInfo)); + + const auto normalizedName = XAssetInfoGeneric::NormalizeAssetName(assetInfo->m_name); + GameGlobalAssetPools::GetGlobalPoolsForGame(m_zone.m_game_id)->LinkAsset(type, m_asset_pools[type].get(), normalizedName, assetInfo); + + assert(assetInfo); + m_assets_in_order.emplace_back(assetInfo); + + return assetInfo; +} + +XAssetInfoGeneric* ZoneAssetPools::GetAsset(const asset_type_t type, const std::string& name) const +{ + assert(m_asset_pools.size() > type); + + return m_asset_pools[type]->GetAsset(name); +} + +XAssetInfoGeneric* ZoneAssetPools::GetAssetOrAssetReference(const asset_type_t type, const std::string& name) const +{ + auto* result = GetAsset(type, name); + + if (result != nullptr || (!name.empty() && name[0] == ',')) + return result; + + result = GetAsset(type, std::format(",{}", name)); + return result; +} + +size_t ZoneAssetPools::GetTotalAssetCount() const +{ + return m_assets_in_order.size(); +} + +ZoneAssetPools::all_iterator ZoneAssetPools::begin() const +{ + return m_assets_in_order.begin(); +} + +ZoneAssetPools::all_iterator ZoneAssetPools::end() const +{ + return m_assets_in_order.end(); +} diff --git a/src/ZoneCommon/Pool/AssetPool.h b/src/ZoneCommon/Pool/AssetPool.h index f22c71cd..55f25cd0 100644 --- a/src/ZoneCommon/Pool/AssetPool.h +++ b/src/ZoneCommon/Pool/AssetPool.h @@ -1,109 +1,183 @@ #pragma once -#include "XAssetInfo.h" -#include "Zone/Zone.h" +#include "Game/IAsset.h" +#include "Zone/ZoneTypes.h" -#include +#include #include +#include +#include class Zone; +template class XAssetInfo; +class XAssetInfoGeneric; +class IndirectAssetReference; -template class AssetPool +class AssetPool { public: - using type = T; - - std::map*> m_asset_lookup; - class Iterator { - typename std::map*>::iterator m_iterator; - public: - explicit Iterator(typename std::map*>::iterator i) - { - m_iterator = i; - } + explicit Iterator(std::unordered_map::iterator i); - bool operator!=(Iterator rhs) - { - return m_iterator != rhs.m_iterator; - } + bool operator!=(const Iterator& rhs) const; + XAssetInfoGeneric* operator*() const; + void operator++(); - XAssetInfo* operator*() - { - return m_iterator.operator*().second; - } - - void operator++() - { - ++m_iterator; - } + private: + std::unordered_map::iterator m_iterator; }; class CIterator { - typename std::map*>::const_iterator m_iterator; - public: - explicit CIterator(typename std::map*>::const_iterator i) - { - m_iterator = i; - } + explicit CIterator(std::unordered_map::const_iterator i); - bool operator!=(CIterator rhs) - { - return m_iterator != rhs.m_iterator; - } + bool operator!=(const CIterator& rhs) const; + const XAssetInfoGeneric* operator*() const; + void operator++(); - const XAssetInfo* operator*() - { - return m_iterator.operator*().second; - } - - void operator++() - { - ++m_iterator; - } + private: + std::unordered_map::const_iterator m_iterator; }; - AssetPool() - { - m_asset_lookup = std::map*>(); - } + AssetPool() = default; + ~AssetPool() = default; - virtual ~AssetPool() = default; + AssetPool(AssetPool&) = delete; + AssetPool(AssetPool&&) = delete; + AssetPool& operator=(AssetPool&) = delete; + AssetPool& operator=(AssetPool&&) = delete; - virtual XAssetInfo* AddAsset(std::unique_ptr> xAssetInfo) = 0; + XAssetInfoGeneric* AddAsset(std::unique_ptr xAssetInfo); + XAssetInfoGeneric* GetAsset(const std::string& name); - XAssetInfo* GetAsset(const std::string& name) - { - const auto normalizedName = XAssetInfo::NormalizeAssetName(name); - auto foundAsset = m_asset_lookup.find(normalizedName); + [[nodiscard]] size_t size() const; + [[nodiscard]] bool empty() const; - if (foundAsset == m_asset_lookup.end()) - return nullptr; + [[nodiscard]] Iterator begin(); + [[nodiscard]] Iterator end(); - return foundAsset->second; - } + [[nodiscard]] CIterator begin() const; + [[nodiscard]] CIterator end() const; - Iterator begin() - { - return Iterator(m_asset_lookup.begin()); - } - - Iterator end() - { - return Iterator(m_asset_lookup.end()); - } - - CIterator begin() const - { - return CIterator(m_asset_lookup.cbegin()); - } - - CIterator end() const - { - return CIterator(m_asset_lookup.cend()); - } +private: + std::unordered_map m_asset_lookup; + std::vector> m_assets; }; + +template class AssetPoolIterator +{ +public: + explicit AssetPoolIterator(AssetPool::Iterator i) + : m_iterator(std::move(i)) + { + } + + bool operator!=(const AssetPoolIterator& rhs) const + { + return m_iterator != rhs.m_iterator; + } + + XAssetInfo* operator*() const + { + return reinterpret_cast*>(*m_iterator); + } + + void operator++() + { + ++m_iterator; + } + +private: + AssetPool::Iterator m_iterator; +}; + +template class AssetPoolIterators +{ +public: + explicit AssetPoolIterators(AssetPool& assetPool) + : m_asset_pool(assetPool) + { + } + + AssetPoolIterator begin() + { + return AssetPoolIterator(m_asset_pool.begin()); + } + + AssetPoolIterator end() + { + return AssetPoolIterator(m_asset_pool.end()); + } + + [[nodiscard]] size_t size() const + { + return m_asset_pool.size(); + } + + [[nodiscard]] bool empty() const + { + return m_asset_pool.empty(); + } + +private: + AssetPool& m_asset_pool; +}; + +class ZoneAssetPools +{ +public: + using all_iterator = std::vector::const_iterator; + + ZoneAssetPools(Zone& zone, zone_priority_t priority); + ~ZoneAssetPools(); + ZoneAssetPools(const ZoneAssetPools& other) = delete; + ZoneAssetPools(ZoneAssetPools&& other) noexcept = delete; + ZoneAssetPools& operator=(const ZoneAssetPools& other) = delete; + ZoneAssetPools& operator=(ZoneAssetPools&& other) noexcept = delete; + + XAssetInfoGeneric* AddAsset(std::unique_ptr xAssetInfo); + XAssetInfoGeneric* AddAsset(asset_type_t type, + std::string name, + void* asset, + std::vector dependencies, + std::vector usedScriptStrings, + std::vector indirectAssetReferences); + [[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const; + [[nodiscard]] XAssetInfoGeneric* GetAssetOrAssetReference(asset_type_t type, const std::string& name) const; + + template XAssetInfo* AddAsset(std::unique_ptr> xAssetInfo) + { + return reinterpret_cast*>(AddAsset(std::unique_ptr(xAssetInfo.release()))); + } + + template [[nodiscard]] XAssetInfo* GetAsset(const std::string& name) const + { + return reinterpret_cast*>(GetAsset(Asset_t::EnumEntry, name)); + } + + template [[nodiscard]] XAssetInfo* GetAssetOrAssetReference(const std::string& name) const + { + return reinterpret_cast*>(GetAssetOrAssetReference(Asset_t::EnumEntry, name)); + } + + template [[nodiscard]] AssetPoolIterators PoolAssets() const + { + return AssetPoolIterators(*m_asset_pools[Asset_t::EnumEntry]); + } + + [[nodiscard]] size_t GetTotalAssetCount() const; + + [[nodiscard]] all_iterator begin() const; + [[nodiscard]] all_iterator end() const; + +private: + Zone& m_zone; + std::vector> m_asset_pools; + std::vector m_assets_in_order; +}; + +#include "XAssetInfo.h" +#include "Zone/Zone.h" diff --git a/src/ZoneCommon/Pool/AssetPoolDynamic.h b/src/ZoneCommon/Pool/AssetPoolDynamic.h deleted file mode 100644 index 3b9c54ac..00000000 --- a/src/ZoneCommon/Pool/AssetPoolDynamic.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -#include "AssetPool.h" -#include "GlobalAssetPool.h" -#include "XAssetInfo.h" - -#include - -template class AssetPoolDynamic final : public AssetPool -{ - using AssetPool::m_asset_lookup; - - std::vector>> m_assets; - -public: - explicit AssetPoolDynamic(const zone_priority_t priority) - { - GlobalAssetPool::LinkAssetPool(this, priority); - } - - AssetPoolDynamic(AssetPoolDynamic&) = delete; - AssetPoolDynamic(AssetPoolDynamic&&) = delete; - AssetPoolDynamic& operator=(AssetPoolDynamic&) = delete; - AssetPoolDynamic& operator=(AssetPoolDynamic&&) = default; - - ~AssetPoolDynamic() override - { - GlobalAssetPool::UnlinkAssetPool(this); - - m_assets.clear(); - m_asset_lookup.clear(); - } - - XAssetInfo* AddAsset(std::unique_ptr> xAssetInfo) override - { - const auto normalizedName = XAssetInfo::NormalizeAssetName(xAssetInfo->m_name); - - auto* pAssetInfo = xAssetInfo.get(); - m_asset_lookup[normalizedName] = pAssetInfo; - m_assets.emplace_back(std::move(xAssetInfo)); - - GlobalAssetPool::LinkAsset(this, normalizedName, pAssetInfo); - - return pAssetInfo; - } -}; diff --git a/src/ZoneCommon/Pool/GlobalAssetPool.cpp b/src/ZoneCommon/Pool/GlobalAssetPool.cpp new file mode 100644 index 00000000..e5769778 --- /dev/null +++ b/src/ZoneCommon/Pool/GlobalAssetPool.cpp @@ -0,0 +1,212 @@ +#include "GlobalAssetPool.h" + +#include +#include + +void GlobalAssetPool::LinkAssetPool(AssetPool* assetPool, const zone_priority_t priority) +{ + auto newLink = std::make_unique(); + newLink->m_asset_pool = assetPool; + newLink->m_priority = priority; + + auto* newLinkPtr = newLink.get(); + m_linked_asset_pools.emplace_back(std::move(newLink)); + SortLinkedAssetPools(); + + for (auto* asset : *assetPool) + { + const auto normalizedAssetName = XAssetInfoGeneric::NormalizeAssetName(asset->m_name); + LinkAsset(newLinkPtr, normalizedAssetName, asset); + } +} + +void GlobalAssetPool::LinkAsset(const AssetPool* assetPool, const std::string& normalizedAssetName, XAssetInfoGeneric* asset) +{ + LinkedAssetPool* link = nullptr; + + for (const auto& existingLink : m_linked_asset_pools) + { + if (existingLink->m_asset_pool == assetPool) + { + link = existingLink.get(); + break; + } + } + + assert(link != nullptr); + if (link == nullptr) + return; + + LinkAsset(link, normalizedAssetName, asset); +} + +void GlobalAssetPool::UnlinkAssetPool(const AssetPool* assetPool) +{ + auto iLinkEntry = m_linked_asset_pools.begin(); + + for (; iLinkEntry != m_linked_asset_pools.end(); ++iLinkEntry) + { + const auto* linkEntry = iLinkEntry->get(); + if (linkEntry->m_asset_pool == assetPool) + break; + } + + assert(iLinkEntry != m_linked_asset_pools.end()); + if (iLinkEntry == m_linked_asset_pools.end()) + return; + + const auto assetPoolToUnlink = std::move(*iLinkEntry); + m_linked_asset_pools.erase(iLinkEntry); + + for (auto iAssetEntry = m_assets.begin(); iAssetEntry != m_assets.end();) + { + auto& assetEntry = *iAssetEntry; + + if (assetEntry.second.m_asset_pool != assetPoolToUnlink.get()) + { + ++iAssetEntry; + continue; + } + + if (assetEntry.second.m_duplicate && ReplaceAssetPoolEntry(assetEntry.second)) + { + ++iAssetEntry; + continue; + } + + iAssetEntry = m_assets.erase(iAssetEntry); + } +} + +XAssetInfoGeneric* GlobalAssetPool::GetAsset(const std::string& name) +{ + const auto normalizedName = XAssetInfoGeneric::NormalizeAssetName(name); + const auto foundEntry = m_assets.find(normalizedName); + if (foundEntry == m_assets.end()) + return nullptr; + + return foundEntry->second.m_asset; +} + +void GlobalAssetPool::SortLinkedAssetPools() +{ + std::ranges::sort(m_linked_asset_pools, + [](const std::unique_ptr& a, const std::unique_ptr& b) -> bool + { + return a->m_priority < b->m_priority; + }); +} + +bool GlobalAssetPool::ReplaceAssetPoolEntry(GameAssetPoolEntry& assetEntry) const +{ + int occurrences = 0; + + for (const auto& linkedAssetPool : m_linked_asset_pools) + { + auto* foundAsset = linkedAssetPool->m_asset_pool->GetAsset(assetEntry.m_asset->m_name); + + if (foundAsset != nullptr) + { + if (++occurrences == 1) + { + assetEntry.m_asset = foundAsset; + assetEntry.m_duplicate = false; + assetEntry.m_asset_pool = linkedAssetPool.get(); + } + else + { + assetEntry.m_duplicate = true; + break; + } + } + } + + return occurrences > 0; +} + +void GlobalAssetPool::LinkAsset(LinkedAssetPool* link, const std::string& normalizedAssetName, XAssetInfoGeneric* asset) +{ + const auto existingAsset = m_assets.find(normalizedAssetName); + + if (existingAsset == m_assets.end()) + { + const GameAssetPoolEntry entry{ + .m_asset = asset, + .m_asset_pool = link, + .m_duplicate = false, + }; + + m_assets[normalizedAssetName] = entry; + } + else + { + auto& existingEntry = existingAsset->second; + + existingEntry.m_duplicate = true; + + if (existingEntry.m_asset_pool->m_priority < link->m_priority) + { + existingEntry.m_asset_pool = link; + existingEntry.m_asset = asset; + } + } +} + +GameGlobalAssetPools::GameGlobalAssetPools(const GameId gameId) +{ + const auto assetTypeCount = IGame::GetGameById(gameId)->GetAssetTypeCount(); + m_global_asset_pools.resize(assetTypeCount); + + for (auto assetType = 0u; assetType < assetTypeCount; assetType++) + { + m_global_asset_pools[assetType] = std::make_unique(); + } +} + +void GameGlobalAssetPools::LinkAssetPool(const asset_type_t assetType, AssetPool* assetPool, const zone_priority_t priority) const +{ + assert(assetType < m_global_asset_pools.size()); + + m_global_asset_pools[assetType]->LinkAssetPool(assetPool, priority); +} + +void GameGlobalAssetPools::LinkAsset(const asset_type_t assetType, + const AssetPool* assetPool, + const std::string& normalizedAssetName, + XAssetInfoGeneric* asset) const +{ + assert(assetType < m_global_asset_pools.size()); + + m_global_asset_pools[assetType]->LinkAsset(assetPool, normalizedAssetName, asset); +} + +void GameGlobalAssetPools::UnlinkAssetPool(const asset_type_t assetType, const AssetPool* assetPool) const +{ + assert(assetType < m_global_asset_pools.size()); + + m_global_asset_pools[assetType]->UnlinkAssetPool(assetPool); +} + +XAssetInfoGeneric* GameGlobalAssetPools::GetAsset(const asset_type_t assetType, const std::string& name) const +{ + assert(assetType < m_global_asset_pools.size()); + + return m_global_asset_pools[assetType]->GetAsset(name); +} + +GameGlobalAssetPools* GameGlobalAssetPools::GetGlobalPoolsForGame(GameId gameId) +{ + static GameGlobalAssetPools* globalAssetPools[static_cast(GameId::COUNT)]{ + new GameGlobalAssetPools(GameId::IW3), + new GameGlobalAssetPools(GameId::IW4), + new GameGlobalAssetPools(GameId::IW5), + new GameGlobalAssetPools(GameId::T5), + new GameGlobalAssetPools(GameId::T6), + }; + + assert(static_cast(gameId) < static_cast(GameId::COUNT)); + auto* result = globalAssetPools[static_cast(gameId)]; + assert(result); + + return result; +} diff --git a/src/ZoneCommon/Pool/GlobalAssetPool.h b/src/ZoneCommon/Pool/GlobalAssetPool.h index 7fdbdfab..6ae94c7d 100644 --- a/src/ZoneCommon/Pool/GlobalAssetPool.h +++ b/src/ZoneCommon/Pool/GlobalAssetPool.h @@ -3,188 +3,60 @@ #include "AssetPool.h" #include "Zone/ZoneTypes.h" -#include -#include #include #include #include #include -template class GlobalAssetPool +struct LinkedAssetPool { - struct LinkedAssetPool - { - AssetPool* m_asset_pool; - zone_priority_t m_priority; - }; - - struct GameAssetPoolEntry - { - XAssetInfo* m_asset; - bool m_duplicate; - LinkedAssetPool* m_asset_pool; - }; - - static std::vector> m_linked_asset_pools; - static std::unordered_map m_assets; - - static void SortLinkedAssetPools() - { - std::sort(m_linked_asset_pools.begin(), - m_linked_asset_pools.end(), - [](const std::unique_ptr& a, const std::unique_ptr& b) -> bool - { - return a->m_priority < b->m_priority; - }); - } - - static bool ReplaceAssetPoolEntry(GameAssetPoolEntry& assetEntry) - { - int occurrences = 0; - - for (const auto& linkedAssetPool : m_linked_asset_pools) - { - XAssetInfo* foundAsset = linkedAssetPool->m_asset_pool->GetAsset(assetEntry.m_asset->m_name); - - if (foundAsset != nullptr) - { - if (++occurrences == 1) - { - assetEntry.m_asset = foundAsset; - assetEntry.m_duplicate = false; - assetEntry.m_asset_pool = linkedAssetPool.get(); - } - else - { - assetEntry.m_duplicate = true; - break; - } - } - } - - return occurrences > 0; - } - - static void LinkAsset(LinkedAssetPool* link, const std::string& normalizedAssetName, XAssetInfo* asset) - { - auto existingAsset = m_assets.find(normalizedAssetName); - - if (existingAsset == m_assets.end()) - { - GameAssetPoolEntry entry{}; - entry.m_asset = asset; - entry.m_asset_pool = link; - entry.m_duplicate = false; - - m_assets[normalizedAssetName] = entry; - } - else - { - auto& existingEntry = existingAsset->second; - - existingEntry.m_duplicate = true; - - if (existingEntry.m_asset_pool->m_priority < link->m_priority) - { - existingEntry.m_asset_pool = link; - existingEntry.m_asset = asset; - } - } - } - -public: - static void LinkAssetPool(AssetPool* assetPool, const zone_priority_t priority) - { - auto newLink = std::make_unique(); - newLink->m_asset_pool = assetPool; - newLink->m_priority = priority; - - auto* newLinkPtr = newLink.get(); - m_linked_asset_pools.emplace_back(std::move(newLink)); - SortLinkedAssetPools(); - - for (auto asset : *assetPool) - { - const auto normalizedAssetName = XAssetInfo::NormalizeAssetName(asset->m_name); - LinkAsset(newLinkPtr, normalizedAssetName, asset); - } - } - - static void LinkAsset(AssetPool* assetPool, const std::string& normalizedAssetName, XAssetInfo* asset) - { - LinkedAssetPool* link = nullptr; - - for (const auto& existingLink : m_linked_asset_pools) - { - if (existingLink->m_asset_pool == assetPool) - { - link = existingLink.get(); - break; - } - } - - assert(link != nullptr); - if (link == nullptr) - return; - - LinkAsset(link, normalizedAssetName, asset); - } - - static void UnlinkAssetPool(AssetPool* assetPool) - { - auto iLinkEntry = m_linked_asset_pools.begin(); - - for (; iLinkEntry != m_linked_asset_pools.end(); ++iLinkEntry) - { - LinkedAssetPool* linkEntry = iLinkEntry->get(); - if (linkEntry->m_asset_pool == assetPool) - { - break; - } - } - - assert(iLinkEntry != m_linked_asset_pools.end()); - if (iLinkEntry == m_linked_asset_pools.end()) - return; - - auto assetPoolToUnlink = std::move(*iLinkEntry); - m_linked_asset_pools.erase(iLinkEntry); - - for (auto iAssetEntry = m_assets.begin(); iAssetEntry != m_assets.end();) - { - auto& assetEntry = *iAssetEntry; - - if (assetEntry.second.m_asset_pool != assetPoolToUnlink.get()) - { - ++iAssetEntry; - continue; - } - - if (assetEntry.second.m_duplicate && ReplaceAssetPoolEntry(assetEntry.second)) - { - ++iAssetEntry; - continue; - } - - iAssetEntry = m_assets.erase(iAssetEntry); - } - } - - static XAssetInfo* GetAssetByName(const std::string& name) - { - const auto normalizedName = XAssetInfo::NormalizeAssetName(name); - const auto foundEntry = m_assets.find(normalizedName); - if (foundEntry == m_assets.end()) - return nullptr; - - return foundEntry->second.m_asset; - } + AssetPool* m_asset_pool; + zone_priority_t m_priority; }; -template -std::vector::LinkedAssetPool>> GlobalAssetPool::m_linked_asset_pools = - std::vector>(); +struct GameAssetPoolEntry +{ + XAssetInfoGeneric* m_asset; + LinkedAssetPool* m_asset_pool; + bool m_duplicate; +}; -template -std::unordered_map::GameAssetPoolEntry> GlobalAssetPool::m_assets = - std::unordered_map(); +class GlobalAssetPool +{ +public: + void LinkAssetPool(AssetPool* assetPool, zone_priority_t priority); + void LinkAsset(const AssetPool* assetPool, const std::string& normalizedAssetName, XAssetInfoGeneric* asset); + void UnlinkAssetPool(const AssetPool* assetPool); + + XAssetInfoGeneric* GetAsset(const std::string& name); + +private: + void SortLinkedAssetPools(); + bool ReplaceAssetPoolEntry(GameAssetPoolEntry& assetEntry) const; + void LinkAsset(LinkedAssetPool* link, const std::string& normalizedAssetName, XAssetInfoGeneric* asset); + + std::vector> m_linked_asset_pools; + std::unordered_map m_assets; +}; + +class GameGlobalAssetPools +{ +public: + explicit GameGlobalAssetPools(GameId gameId); + + void LinkAssetPool(asset_type_t assetType, AssetPool* assetPool, zone_priority_t priority) const; + void LinkAsset(asset_type_t assetType, const AssetPool* assetPool, const std::string& normalizedAssetName, XAssetInfoGeneric* asset) const; + void UnlinkAssetPool(asset_type_t assetType, const AssetPool* assetPool) const; + + [[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t assetType, const std::string& name) const; + + template [[nodiscard]] XAssetInfo* GetAsset(const std::string& name) const + { + return reinterpret_cast*>(GetAsset(Asset_t::EnumEntry, name)); + } + + static GameGlobalAssetPools* GetGlobalPoolsForGame(GameId gameId); + +private: + std::vector> m_global_asset_pools; +}; diff --git a/src/ZoneCommon/Pool/XAssetInfo.h b/src/ZoneCommon/Pool/XAssetInfo.h index 30946927..b6256682 100644 --- a/src/ZoneCommon/Pool/XAssetInfo.h +++ b/src/ZoneCommon/Pool/XAssetInfo.h @@ -1,4 +1,5 @@ #pragma once + #include "Zone/Zone.h" #include "Zone/ZoneTypes.h" diff --git a/src/ZoneCommon/Pool/ZoneAssetPools.cpp b/src/ZoneCommon/Pool/ZoneAssetPools.cpp deleted file mode 100644 index 56b42abf..00000000 --- a/src/ZoneCommon/Pool/ZoneAssetPools.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "ZoneAssetPools.h" - -#include "Game/IW3/GameAssetPoolIW3.h" -#include "Game/IW4/GameAssetPoolIW4.h" -#include "Game/IW5/GameAssetPoolIW5.h" -#include "Game/T5/GameAssetPoolT5.h" -#include "Game/T6/GameAssetPoolT6.h" -#include "Game/T6/ZoneConstantsT6.h" - -#include -#include - -ZoneAssetPools::ZoneAssetPools(Zone* zone) - : m_zone(zone) -{ -} - -XAssetInfoGeneric* ZoneAssetPools::AddAsset(const asset_type_t type, - std::string name, - void* asset, - std::vector dependencies, - std::vector usedScriptStrings, - std::vector indirectAssetReferences) -{ - return AddAsset(std::make_unique( - type, std::move(name), asset, std::move(dependencies), std::move(usedScriptStrings), std::move(indirectAssetReferences), m_zone)); -} - -XAssetInfoGeneric* ZoneAssetPools::AddAsset(std::unique_ptr xAssetInfo) -{ - auto* assetInfo = AddAssetToPool(std::move(xAssetInfo)); - if (assetInfo) - m_assets_in_order.push_back(assetInfo); - - return assetInfo; -} - -XAssetInfoGeneric* ZoneAssetPools::GetAssetOrAssetReference(const asset_type_t type, const std::string& name) const -{ - auto* result = GetAsset(type, name); - - if (result != nullptr || (!name.empty() && name[0] == ',')) - return result; - - result = GetAsset(type, std::format(",{}", name)); - return result; -} - -size_t ZoneAssetPools::GetTotalAssetCount() const -{ - return m_assets_in_order.size(); -} - -ZoneAssetPools::iterator ZoneAssetPools::begin() const -{ - return m_assets_in_order.begin(); -} - -ZoneAssetPools::iterator ZoneAssetPools::end() const -{ - return m_assets_in_order.end(); -} - -std::unique_ptr ZoneAssetPools::CreateForGame(const GameId game, Zone* zone, const zone_priority_t priority) -{ - switch (game) - { - case GameId::IW3: - return std::make_unique(zone, priority); - case GameId::IW4: - return std::make_unique(zone, priority); - case GameId::IW5: - return std::make_unique(zone, priority); - case GameId::T5: - return std::make_unique(zone, priority); - case GameId::T6: - return std::make_unique(zone, priority); - default: - assert(false); - return nullptr; - } -} diff --git a/src/ZoneCommon/Pool/ZoneAssetPools.h b/src/ZoneCommon/Pool/ZoneAssetPools.h deleted file mode 100644 index 973115f3..00000000 --- a/src/ZoneCommon/Pool/ZoneAssetPools.h +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once - -#include "XAssetInfo.h" -#include "Zone/Zone.h" -#include "Zone/ZoneTypes.h" - -#include -#include -#include -#include -#include - -class Zone; -class IndirectAssetReference; -class XAssetInfoGeneric; - -class ZoneAssetPools -{ -public: - using iterator = std::vector::const_iterator; - - explicit ZoneAssetPools(Zone* zone); - virtual ~ZoneAssetPools() = default; - ZoneAssetPools(const ZoneAssetPools& other) = delete; - ZoneAssetPools(ZoneAssetPools&& other) noexcept = default; - ZoneAssetPools& operator=(const ZoneAssetPools& other) = delete; - ZoneAssetPools& operator=(ZoneAssetPools&& other) noexcept = default; - - XAssetInfoGeneric* AddAsset(std::unique_ptr xAssetInfo); - XAssetInfoGeneric* AddAsset(asset_type_t type, - std::string name, - void* asset, - std::vector dependencies, - std::vector usedScriptStrings, - std::vector indirectAssetReferences); - [[nodiscard]] virtual XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const = 0; - [[nodiscard]] virtual XAssetInfoGeneric* GetAssetOrAssetReference(asset_type_t type, const std::string& name) const; - - [[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 4f0fe2b5..be80ce23 100644 --- a/src/ZoneCommon/Zone/Zone.cpp +++ b/src/ZoneCommon/Zone/Zone.cpp @@ -8,7 +8,7 @@ Zone::Zone(std::string name, const zone_priority_t priority, const GameId gameId m_language(GameLanguage::LANGUAGE_NONE), m_game_id(gameId), m_platform(platform), - m_pools(ZoneAssetPools::CreateForGame(gameId, this, priority)), + m_pools(*this, priority), m_memory(std::make_unique()), m_registered(false) { diff --git a/src/ZoneCommon/Zone/Zone.h b/src/ZoneCommon/Zone/Zone.h index a4f57018..1c34fbf4 100644 --- a/src/ZoneCommon/Zone/Zone.h +++ b/src/ZoneCommon/Zone/Zone.h @@ -2,7 +2,7 @@ #include "Game/GameLanguage.h" #include "Game/IGame.h" -#include "Pool/ZoneAssetPools.h" +#include "Pool/AssetPool.h" #include "Zone/ZoneTypes.h" #include "ZoneMemory.h" #include "ZoneScriptStrings.h" @@ -10,17 +10,15 @@ #include #include -class ZoneAssetPools; - class Zone { public: Zone(std::string name, zone_priority_t priority, GameId gameId, GamePlatform platform); ~Zone(); Zone(const Zone& other) = delete; - Zone(Zone&& other) noexcept = default; + Zone(Zone&& other) noexcept = delete; Zone& operator=(const Zone& other) = delete; - Zone& operator=(Zone&& other) noexcept = default; + Zone& operator=(Zone&& other) noexcept = delete; void Register(); @@ -32,7 +30,7 @@ public: GameId m_game_id; GamePlatform m_platform; ZoneScriptStrings m_script_strings; - std::unique_ptr m_pools; + ZoneAssetPools m_pools; private: std::unique_ptr m_memory; diff --git a/src/ZoneLoading/Game/IW3/ZoneLoaderFactoryIW3.cpp b/src/ZoneLoading/Game/IW3/ZoneLoaderFactoryIW3.cpp index 7f06f3f3..69e629ce 100644 --- a/src/ZoneLoading/Game/IW3/ZoneLoaderFactoryIW3.cpp +++ b/src/ZoneLoading/Game/IW3/ZoneLoaderFactoryIW3.cpp @@ -2,7 +2,6 @@ #include "ContentLoaderIW3.h" #include "Game/GameLanguage.h" -#include "Game/IW3/GameAssetPoolIW3.h" #include "Game/IW3/GameIW3.h" #include "Game/IW3/IW3.h" #include "Game/IW3/ZoneConstantsIW3.h" @@ -184,7 +183,6 @@ std::unique_ptr ZoneLoaderFactory::CreateLoaderForHeader(const ZoneH // Create new zone auto zone = std::make_unique(fileName, 0, GameId::IW3, inspectResult->m_platform); auto* zonePtr = zone.get(); - zone->m_pools = std::make_unique(zonePtr, 0); zone->m_language = GameLanguage::LANGUAGE_NONE; // File is supported. Now setup all required steps for loading this file. diff --git a/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp b/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp index 8a48a880..1ace539a 100644 --- a/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp +++ b/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp @@ -2,7 +2,6 @@ #include "ContentLoaderIW4.h" #include "Game/GameLanguage.h" -#include "Game/IW4/GameAssetPoolIW4.h" #include "Game/IW4/GameIW4.h" #include "Game/IW4/IW4.h" #include "Game/IW4/ZoneConstantsIW4.h" @@ -269,7 +268,6 @@ std::unique_ptr ZoneLoaderFactory::CreateLoaderForHeader(const ZoneH // Create new zone auto zone = std::make_unique(fileName, 0, GameId::IW4, inspectResult->m_generic_result.m_platform); auto* zonePtr = zone.get(); - zone->m_pools = std::make_unique(zonePtr, 0); zone->m_language = GameLanguage::LANGUAGE_NONE; // File is supported. Now setup all required steps for loading this file. diff --git a/src/ZoneLoading/Game/IW5/ZoneLoaderFactoryIW5.cpp b/src/ZoneLoading/Game/IW5/ZoneLoaderFactoryIW5.cpp index 557d5537..e09e4dc9 100644 --- a/src/ZoneLoading/Game/IW5/ZoneLoaderFactoryIW5.cpp +++ b/src/ZoneLoading/Game/IW5/ZoneLoaderFactoryIW5.cpp @@ -2,7 +2,6 @@ #include "ContentLoaderIW5.h" #include "Game/GameLanguage.h" -#include "Game/IW5/GameAssetPoolIW5.h" #include "Game/IW5/GameIW5.h" #include "Game/IW5/IW5.h" #include "Game/IW5/ZoneConstantsIW5.h" @@ -62,7 +61,7 @@ namespace return nullptr; } - return rsa; + return std::move(rsa); } else { @@ -167,7 +166,6 @@ std::unique_ptr ZoneLoaderFactory::CreateLoaderForHeader(const ZoneH // Create new zone auto zone = std::make_unique(fileName, 0, GameId::IW5, inspectResult->m_platform); auto* zonePtr = zone.get(); - zone->m_pools = std::make_unique(zonePtr, 0); zone->m_language = GameLanguage::LANGUAGE_NONE; // File is supported. Now setup all required steps for loading this file. diff --git a/src/ZoneLoading/Game/T5/ZoneLoaderFactoryT5.cpp b/src/ZoneLoading/Game/T5/ZoneLoaderFactoryT5.cpp index 7d93b5d2..485cd882 100644 --- a/src/ZoneLoading/Game/T5/ZoneLoaderFactoryT5.cpp +++ b/src/ZoneLoading/Game/T5/ZoneLoaderFactoryT5.cpp @@ -2,7 +2,6 @@ #include "ContentLoaderT5.h" #include "Game/GameLanguage.h" -#include "Game/T5/GameAssetPoolT5.h" #include "Game/T5/GameT5.h" #include "Game/T5/T5.h" #include "Game/T5/ZoneConstantsT5.h" @@ -70,7 +69,6 @@ std::unique_ptr ZoneLoaderFactory::CreateLoaderForHeader(const ZoneH // Create new zone auto zone = std::make_unique(fileName, 0, GameId::T5, inspectResult->m_platform); auto* zonePtr = zone.get(); - zone->m_pools = std::make_unique(zonePtr, 0); zone->m_language = GameLanguage::LANGUAGE_NONE; // File is supported. Now setup all required steps for loading this file. diff --git a/src/ZoneLoading/Game/T6/ZoneLoaderFactoryT6.cpp b/src/ZoneLoading/Game/T6/ZoneLoaderFactoryT6.cpp index f4a40755..0d377ee7 100644 --- a/src/ZoneLoading/Game/T6/ZoneLoaderFactoryT6.cpp +++ b/src/ZoneLoading/Game/T6/ZoneLoaderFactoryT6.cpp @@ -2,7 +2,6 @@ #include "ContentLoaderT6.h" #include "Game/GameLanguage.h" -#include "Game/T6/GameAssetPoolT6.h" #include "Game/T6/GameT6.h" #include "Game/T6/T6.h" #include "Game/T6/ZoneConstantsT6.h" @@ -286,7 +285,6 @@ std::unique_ptr ZoneLoaderFactory::CreateLoaderForHeader(const ZoneH // Create new zone auto zone = std::make_unique(fileName, 0, GameId::T6, inspectResult->m_generic_result.m_platform); auto* zonePtr = zone.get(); - zone->m_pools = std::make_unique(zonePtr, 0); zone->m_language = GetZoneLanguage(fileName); // File is supported. Now setup all required steps for loading this file. diff --git a/src/ZoneLoading/Loading/AssetInfoCollector.cpp b/src/ZoneLoading/Loading/AssetInfoCollector.cpp index 7ab17c36..92c01268 100644 --- a/src/ZoneLoading/Loading/AssetInfoCollector.cpp +++ b/src/ZoneLoading/Loading/AssetInfoCollector.cpp @@ -51,7 +51,7 @@ std::vector AssetInfoCollector::GetIndirectAssetReferenc std::optional AssetInfoCollector::Visit_Dependency(const asset_type_t assetType, const char* assetName) { - auto* assetInfo = m_zone.m_pools->GetAsset(assetType, assetName); + auto* assetInfo = m_zone.m_pools.GetAsset(assetType, assetName); if (assetInfo == nullptr) return std::nullopt; diff --git a/src/ZoneLoading/Loading/AssetLoader.cpp b/src/ZoneLoading/Loading/AssetLoader.cpp index 18c660a6..068fe060 100644 --- a/src/ZoneLoading/Loading/AssetLoader.cpp +++ b/src/ZoneLoading/Loading/AssetLoader.cpp @@ -16,11 +16,10 @@ XAssetInfoGeneric* AssetLoader::LinkAsset(std::string name, std::vector scriptStrings, std::vector indirectAssetReferences) const { - return m_zone.m_pools->AddAsset( - m_asset_type, std::move(name), asset, std::move(dependencies), std::move(scriptStrings), std::move(indirectAssetReferences)); + return m_zone.m_pools.AddAsset(m_asset_type, std::move(name), asset, std::move(dependencies), std::move(scriptStrings), std::move(indirectAssetReferences)); } XAssetInfoGeneric* AssetLoader::GetAssetInfo(const std::string& name) const { - return m_zone.m_pools->GetAsset(m_asset_type, name); + return m_zone.m_pools.GetAsset(m_asset_type, name); } diff --git a/src/ZoneWriting/Game/IW3/ContentWriterIW3.cpp b/src/ZoneWriting/Game/IW3/ContentWriterIW3.cpp index e904524d..d0992724 100644 --- a/src/ZoneWriting/Game/IW3/ContentWriterIW3.cpp +++ b/src/ZoneWriting/Game/IW3/ContentWriterIW3.cpp @@ -33,15 +33,15 @@ void ContentWriter::CreateXAssetList(XAssetList& xAssetList, MemoryManager& memo xAssetList.stringList.strings = nullptr; } - const auto assetCount = m_zone.m_pools->GetTotalAssetCount(); + const auto assetCount = m_zone.m_pools.GetTotalAssetCount(); if (assetCount > 0) { xAssetList.assetCount = static_cast(assetCount); xAssetList.assets = memory.Alloc(assetCount); - const auto end = m_zone.m_pools->end(); + const auto end = m_zone.m_pools.end(); auto index = 0u; - for (auto i = m_zone.m_pools->begin(); i != end; ++i) + for (auto i = m_zone.m_pools.begin(); i != end; ++i) { auto& asset = xAssetList.assets[index++]; asset.type = static_cast((*i)->m_type); diff --git a/src/ZoneWriting/Game/IW4/ContentWriterIW4.cpp b/src/ZoneWriting/Game/IW4/ContentWriterIW4.cpp index c0fbc85a..afac3863 100644 --- a/src/ZoneWriting/Game/IW4/ContentWriterIW4.cpp +++ b/src/ZoneWriting/Game/IW4/ContentWriterIW4.cpp @@ -33,15 +33,15 @@ void ContentWriter::CreateXAssetList(XAssetList& xAssetList, MemoryManager& memo xAssetList.stringList.strings = nullptr; } - const auto assetCount = m_zone.m_pools->GetTotalAssetCount(); + const auto assetCount = m_zone.m_pools.GetTotalAssetCount(); if (assetCount > 0) { xAssetList.assetCount = static_cast(assetCount); xAssetList.assets = memory.Alloc(assetCount); - const auto end = m_zone.m_pools->end(); + const auto end = m_zone.m_pools.end(); auto index = 0u; - for (auto i = m_zone.m_pools->begin(); i != end; ++i) + for (auto i = m_zone.m_pools.begin(); i != end; ++i) { auto& asset = xAssetList.assets[index++]; asset.type = static_cast((*i)->m_type); diff --git a/src/ZoneWriting/Game/IW5/ContentWriterIW5.cpp b/src/ZoneWriting/Game/IW5/ContentWriterIW5.cpp index d701903c..d1e72462 100644 --- a/src/ZoneWriting/Game/IW5/ContentWriterIW5.cpp +++ b/src/ZoneWriting/Game/IW5/ContentWriterIW5.cpp @@ -33,15 +33,15 @@ void ContentWriter::CreateXAssetList(XAssetList& xAssetList, MemoryManager& memo xAssetList.stringList.strings = nullptr; } - const auto assetCount = m_zone.m_pools->GetTotalAssetCount(); + const auto assetCount = m_zone.m_pools.GetTotalAssetCount(); if (assetCount > 0) { xAssetList.assetCount = static_cast(assetCount); xAssetList.assets = memory.Alloc(assetCount); - const auto end = m_zone.m_pools->end(); + const auto end = m_zone.m_pools.end(); auto index = 0u; - for (auto i = m_zone.m_pools->begin(); i != end; ++i) + for (auto i = m_zone.m_pools.begin(); i != end; ++i) { auto& asset = xAssetList.assets[index++]; asset.type = static_cast((*i)->m_type); diff --git a/src/ZoneWriting/Game/T5/ContentWriterT5.cpp b/src/ZoneWriting/Game/T5/ContentWriterT5.cpp index 253a022a..98197980 100644 --- a/src/ZoneWriting/Game/T5/ContentWriterT5.cpp +++ b/src/ZoneWriting/Game/T5/ContentWriterT5.cpp @@ -33,15 +33,15 @@ void ContentWriter::CreateXAssetList(XAssetList& xAssetList, MemoryManager& memo xAssetList.stringList.strings = nullptr; } - const auto assetCount = m_zone.m_pools->GetTotalAssetCount(); + const auto assetCount = m_zone.m_pools.GetTotalAssetCount(); if (assetCount > 0) { xAssetList.assetCount = static_cast(assetCount); xAssetList.assets = memory.Alloc(assetCount); - const auto end = m_zone.m_pools->end(); + const auto end = m_zone.m_pools.end(); auto index = 0u; - for (auto i = m_zone.m_pools->begin(); i != end; ++i) + for (auto i = m_zone.m_pools.begin(); i != end; ++i) { auto& asset = xAssetList.assets[index++]; asset.type = static_cast((*i)->m_type); diff --git a/src/ZoneWriting/Game/T6/ContentWriterT6.cpp b/src/ZoneWriting/Game/T6/ContentWriterT6.cpp index 14af265a..eea9fee4 100644 --- a/src/ZoneWriting/Game/T6/ContentWriterT6.cpp +++ b/src/ZoneWriting/Game/T6/ContentWriterT6.cpp @@ -36,15 +36,15 @@ void ContentWriter::CreateXAssetList(XAssetList& xAssetList, MemoryManager& memo xAssetList.dependCount = 0; xAssetList.depends = nullptr; - const auto assetCount = m_zone.m_pools->GetTotalAssetCount(); + const auto assetCount = m_zone.m_pools.GetTotalAssetCount(); if (assetCount > 0) { xAssetList.assetCount = static_cast(assetCount); xAssetList.assets = memory.Alloc(assetCount); - const auto end = m_zone.m_pools->end(); + const auto end = m_zone.m_pools.end(); auto index = 0u; - for (auto i = m_zone.m_pools->begin(); i != end; ++i) + for (auto i = m_zone.m_pools.begin(); i != end; ++i) { auto& asset = xAssetList.assets[index++]; asset.type = static_cast((*i)->m_type); diff --git a/test/ObjCompilingTests/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6Test.cpp b/test/ObjCompilingTests/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6Test.cpp index 7e81cf1b..1a41d9e5 100644 --- a/test/ObjCompilingTests/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6Test.cpp +++ b/test/ObjCompilingTests/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6Test.cpp @@ -1,7 +1,6 @@ #include "Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.h" #include "Game/T6/CommonT6.h" -#include "Game/T6/GameAssetPoolT6.h" #include "KeyValuePairs/KeyValuePairsCreator.h" #include "Utils/TestMemoryManager.h" @@ -73,7 +72,7 @@ namespace test::game::t6::keyvaluepairs sut->FinalizeZone(testContext.m_context); REQUIRE(testContext.m_memory.GetAllocationCount() == 0u); - REQUIRE(testContext.m_zone.m_pools->GetTotalAssetCount() == 0u); + REQUIRE(testContext.m_zone.m_pools.GetTotalAssetCount() == 0u); } TEST_CASE("KeyValuePairsCompilerT6: Creates KeyValuePairs asset with identical name to the zone", "[keyvaluepairs][t6]") @@ -86,9 +85,9 @@ namespace test::game::t6::keyvaluepairs sut->FinalizeZone(testContext.m_context); REQUIRE(testContext.m_memory.GetAllocationCount() > 0u); - REQUIRE(testContext.m_zone.m_pools->GetTotalAssetCount() == 1u); + REQUIRE(testContext.m_zone.m_pools.GetTotalAssetCount() == 1u); - XAssetInfo* assetInfo = *dynamic_cast(testContext.m_zone.m_pools.get())->m_key_value_pairs->begin(); + XAssetInfo* assetInfo = *testContext.m_zone.m_pools.PoolAssets().begin(); REQUIRE(assetInfo); REQUIRE(assetInfo->m_name == "test"); @@ -112,9 +111,9 @@ namespace test::game::t6::keyvaluepairs sut->FinalizeZone(testContext.m_context); REQUIRE(testContext.m_memory.GetAllocationCount() > 0u); - REQUIRE(testContext.m_zone.m_pools->GetTotalAssetCount() == 1u); + REQUIRE(testContext.m_zone.m_pools.GetTotalAssetCount() == 1u); - XAssetInfo* assetInfo = *dynamic_cast(testContext.m_zone.m_pools.get())->m_key_value_pairs->begin(); + XAssetInfo* assetInfo = *testContext.m_zone.m_pools.PoolAssets().begin(); REQUIRE(assetInfo); REQUIRE(assetInfo->m_name == "test"); diff --git a/test/ObjLoadingTests/Game/IW3/StringTable/AssetLoaderStringTableIW3Test.cpp b/test/ObjLoadingTests/Game/IW3/StringTable/AssetLoaderStringTableIW3Test.cpp index c98e09be..f90b8a59 100644 --- a/test/ObjLoadingTests/Game/IW3/StringTable/AssetLoaderStringTableIW3Test.cpp +++ b/test/ObjLoadingTests/Game/IW3/StringTable/AssetLoaderStringTableIW3Test.cpp @@ -1,7 +1,6 @@ #include "Game/IW3/StringTable/AssetLoaderStringTableIW3.h" #include "Game/IW3/GameIW3.h" -#include "Pool/ZoneAssetPools.h" #include "SearchPath/MockSearchPath.h" #include "Utils/MemoryManager.h" diff --git a/test/ObjLoadingTests/Game/IW4/Menu/LoaderMenuListIW4Test.cpp b/test/ObjLoadingTests/Game/IW4/Menu/LoaderMenuListIW4Test.cpp index ec4cc5bb..2f98cce4 100644 --- a/test/ObjLoadingTests/Game/IW4/Menu/LoaderMenuListIW4Test.cpp +++ b/test/ObjLoadingTests/Game/IW4/Menu/LoaderMenuListIW4Test.cpp @@ -65,7 +65,7 @@ namespace test::game::iw4::menu::parsing::it menuDef_t* GetMenuAsset(const std::string& menuName) { - const auto addedAsset = m_zone.m_pools->GetAsset(ASSET_TYPE_MENU, menuName); + const auto addedAsset = m_zone.m_pools.GetAsset(ASSET_TYPE_MENU, menuName); REQUIRE(addedAsset); REQUIRE(addedAsset->m_type == ASSET_TYPE_MENU); diff --git a/test/ObjWritingTests/Game/IW3/Material/MaterialJsonDumperIW3Test.cpp b/test/ObjWritingTests/Game/IW3/Material/MaterialJsonDumperIW3Test.cpp index 0a1ad83c..8759ce94 100644 --- a/test/ObjWritingTests/Game/IW3/Material/MaterialJsonDumperIW3Test.cpp +++ b/test/ObjWritingTests/Game/IW3/Material/MaterialJsonDumperIW3Test.cpp @@ -4,7 +4,6 @@ #include "Game/IW3/CommonIW3.h" #include "Game/IW3/GameIW3.h" #include "NormalizedJson.h" -#include "Pool/AssetPoolDynamic.h" #include "SearchPath/MockOutputPath.h" #include "SearchPath/MockSearchPath.h" #include "Utils/MemoryManager.h" @@ -35,7 +34,7 @@ namespace return techset; } - void GivenMaterial(const std::string& name, AssetPool& pool, MemoryManager& memory) + void GivenMaterial(const std::string& name, Zone& zone, MemoryManager& memory) { auto* material = memory.Alloc(); material->info.name = memory.Dup(name.c_str()); @@ -310,7 +309,7 @@ namespace stateBits6.loadBits.structured.stencilBackZFail = 0; stateBits6.loadBits.structured.stencilBackFunc = 0; - pool.AddAsset(std::make_unique>(ASSET_TYPE_MATERIAL, name, material)); + zone.m_pools.AddAsset(std::make_unique>(ASSET_TYPE_MATERIAL, name, material)); } TEST_CASE("DumperMaterial(IW3): Can dump material", "[iw3][material][assetdumper]") @@ -558,11 +557,9 @@ namespace MockOutputPath mockOutput; AssetDumpingContext context(zone, "", mockOutput, mockObjPath, std::nullopt); - AssetPoolDynamic materialPool(0); + GivenMaterial("wc/ch_plasterwall_long", zone, memory); - GivenMaterial("wc/ch_plasterwall_long", materialPool, memory); - - material::JsonDumperIW3 dumper(materialPool); + material::JsonDumperIW3 dumper; dumper.Dump(context); const auto* file = mockOutput.GetMockedFile("materials/wc/ch_plasterwall_long.json"); diff --git a/test/ObjWritingTests/Game/IW4/Material/MaterialJsonDumperIW4Test.cpp b/test/ObjWritingTests/Game/IW4/Material/MaterialJsonDumperIW4Test.cpp index f5397cd0..571838c4 100644 --- a/test/ObjWritingTests/Game/IW4/Material/MaterialJsonDumperIW4Test.cpp +++ b/test/ObjWritingTests/Game/IW4/Material/MaterialJsonDumperIW4Test.cpp @@ -4,7 +4,6 @@ #include "Game/IW4/CommonIW4.h" #include "Game/IW4/GameIW4.h" #include "NormalizedJson.h" -#include "Pool/AssetPoolDynamic.h" #include "SearchPath/MockOutputPath.h" #include "SearchPath/MockSearchPath.h" #include "Utils/MemoryManager.h" @@ -35,7 +34,7 @@ namespace return techset; } - void GivenMaterial(const std::string& name, AssetPool& pool, MemoryManager& memory) + void GivenMaterial(const std::string& name, Zone& zone, MemoryManager& memory) { auto* material = memory.Alloc(); material->info.name = memory.Dup(name.c_str()); @@ -288,7 +287,7 @@ namespace stateBits5.loadBits.structured.stencilBackZFail = 0; stateBits5.loadBits.structured.stencilBackFunc = 0; - pool.AddAsset(std::make_unique>(ASSET_TYPE_MATERIAL, name, material)); + zone.m_pools.AddAsset(std::make_unique>(ASSET_TYPE_MATERIAL, name, material)); } TEST_CASE("DumperMaterial(IW4): Can dump material", "[iw4][material][assetdumper]") @@ -539,11 +538,9 @@ namespace MockOutputPath mockOutput; AssetDumpingContext context(zone, "", mockOutput, mockObjPath, std::nullopt); - AssetPoolDynamic materialPool(0); + GivenMaterial("mc/ch_rubble01", zone, memory); - GivenMaterial("mc/ch_rubble01", materialPool, memory); - - material::JsonDumperIW4 dumper(materialPool); + material::JsonDumperIW4 dumper; dumper.Dump(context); const auto* file = mockOutput.GetMockedFile("materials/mc/ch_rubble01.json"); diff --git a/test/ObjWritingTests/Game/IW5/Material/MaterialJsonDumperIW5Test.cpp b/test/ObjWritingTests/Game/IW5/Material/MaterialJsonDumperIW5Test.cpp index 3196f28a..205a1ad3 100644 --- a/test/ObjWritingTests/Game/IW5/Material/MaterialJsonDumperIW5Test.cpp +++ b/test/ObjWritingTests/Game/IW5/Material/MaterialJsonDumperIW5Test.cpp @@ -4,7 +4,6 @@ #include "Game/IW5/CommonIW5.h" #include "Game/IW5/GameIW5.h" #include "NormalizedJson.h" -#include "Pool/AssetPoolDynamic.h" #include "SearchPath/MockOutputPath.h" #include "SearchPath/MockSearchPath.h" #include "Utils/MemoryManager.h" @@ -35,7 +34,7 @@ namespace return techset; } - void GivenMaterial(const std::string& name, AssetPool& pool, MemoryManager& memory) + void GivenMaterial(const std::string& name, Zone& zone, MemoryManager& memory) { auto* material = memory.Alloc(); material->info.name = memory.Dup(name.c_str()); @@ -317,7 +316,7 @@ namespace stateBits6.loadBits.structured.stencilBackZFail = 0; stateBits6.loadBits.structured.stencilBackFunc = 0; - pool.AddAsset(std::make_unique>(ASSET_TYPE_MATERIAL, name, material)); + zone.m_pools.AddAsset(std::make_unique>(ASSET_TYPE_MATERIAL, name, material)); } TEST_CASE("DumperMaterial(IW5): Can dump material", "[iw5][material][assetdumper]") @@ -592,11 +591,9 @@ namespace MockOutputPath mockOutput; AssetDumpingContext context(zone, "", mockOutput, mockObjPath, std::nullopt); - AssetPoolDynamic materialPool(0); + GivenMaterial("wc/me_metal_rust_02", zone, memory); - GivenMaterial("wc/me_metal_rust_02", materialPool, memory); - - material::JsonDumperIW5 dumper(materialPool); + material::JsonDumperIW5 dumper; dumper.Dump(context); const auto* file = mockOutput.GetMockedFile("materials/wc/me_metal_rust_02.json"); diff --git a/test/ObjWritingTests/Game/T5/Material/MaterialJsonDumperT5Test.cpp b/test/ObjWritingTests/Game/T5/Material/MaterialJsonDumperT5Test.cpp index d2664be6..f1639f1c 100644 --- a/test/ObjWritingTests/Game/T5/Material/MaterialJsonDumperT5Test.cpp +++ b/test/ObjWritingTests/Game/T5/Material/MaterialJsonDumperT5Test.cpp @@ -4,7 +4,6 @@ #include "Game/T5/CommonT5.h" #include "Game/T5/GameT5.h" #include "NormalizedJson.h" -#include "Pool/AssetPoolDynamic.h" #include "SearchPath/MockOutputPath.h" #include "SearchPath/MockSearchPath.h" #include "Utils/MemoryManager.h" @@ -35,7 +34,7 @@ namespace return techset; } - void GivenMaterial(const std::string& name, AssetPool& pool, MemoryManager& memory) + void GivenMaterial(const std::string& name, Zone& zone, MemoryManager& memory) { auto* material = memory.Alloc(); material->info.name = memory.Dup(name.c_str()); @@ -289,7 +288,7 @@ namespace stateBits5.loadBits.structured.stencilBackZFail = 0; stateBits5.loadBits.structured.stencilBackFunc = 0; - pool.AddAsset(std::make_unique>(ASSET_TYPE_MATERIAL, name, material)); + zone.m_pools.AddAsset(std::make_unique>(ASSET_TYPE_MATERIAL, name, material)); } TEST_CASE("DumperMaterial(T5): Can dump material", "[t5][material][assetdumper]") @@ -621,11 +620,9 @@ namespace MockOutputPath mockOutput; AssetDumpingContext context(zone, "", mockOutput, mockObjPath, std::nullopt); - AssetPoolDynamic materialPool(0); + GivenMaterial("mc/ch_rubble01", zone, memory); - GivenMaterial("mc/ch_rubble01", materialPool, memory); - - material::JsonDumperT5 dumper(materialPool); + material::JsonDumperT5 dumper; dumper.Dump(context); const auto* file = mockOutput.GetMockedFile("materials/mc/ch_rubble01.json"); diff --git a/test/ObjWritingTests/Game/T6/FontIcon/FontIconJsonDumperT6Test.cpp b/test/ObjWritingTests/Game/T6/FontIcon/FontIconJsonDumperT6Test.cpp index db107bca..9d901f19 100644 --- a/test/ObjWritingTests/Game/T6/FontIcon/FontIconJsonDumperT6Test.cpp +++ b/test/ObjWritingTests/Game/T6/FontIcon/FontIconJsonDumperT6Test.cpp @@ -4,7 +4,6 @@ #include "Game/T6/CommonT6.h" #include "Game/T6/GameT6.h" #include "NormalizedJson.h" -#include "Pool/AssetPoolDynamic.h" #include "SearchPath/MockOutputPath.h" #include "SearchPath/MockSearchPath.h" #include "Utils/MemoryManager.h" @@ -27,7 +26,7 @@ namespace return material; } - void GivenFontIcon(const std::string& name, AssetPool& pool, MemoryManager& memory) + void GivenFontIcon(const std::string& name, Zone& zone, MemoryManager& memory) { auto* fontIcon = memory.Alloc(); fontIcon->name = memory.Dup(name.c_str()); @@ -86,7 +85,7 @@ namespace alias5.aliasHash = Common::Com_HashString("BUTTON_MOVESTICK"); alias5.buttonHash = entry2.fontIconName.hash; - pool.AddAsset(std::make_unique>(ASSET_TYPE_FONTICON, name, fontIcon)); + zone.m_pools.AddAsset(std::make_unique>(ASSET_TYPE_FONTICON, name, fontIcon)); } TEST_CASE("DumperFontIconJson(T6): Can dump font icon", "[t6][font-icon][assetdumper]") @@ -148,10 +147,9 @@ namespace MockOutputPath mockOutput; AssetDumpingContext context(zone, "", mockOutput, mockObjPath, std::nullopt); - AssetPoolDynamic fontIconPool(0); - GivenFontIcon("fonticon/test.csv", fontIconPool, memory); + GivenFontIcon("fonticon/test.csv", zone, memory); - font_icon::JsonDumperT6 dumper(fontIconPool); + font_icon::JsonDumperT6 dumper; dumper.Dump(context); const auto* file = mockOutput.GetMockedFile("fonticon/test.json"); diff --git a/test/ObjWritingTests/Game/T6/Material/MaterialJsonDumperT6Test.cpp b/test/ObjWritingTests/Game/T6/Material/MaterialJsonDumperT6Test.cpp index 49b4a59b..b3e2509b 100644 --- a/test/ObjWritingTests/Game/T6/Material/MaterialJsonDumperT6Test.cpp +++ b/test/ObjWritingTests/Game/T6/Material/MaterialJsonDumperT6Test.cpp @@ -4,7 +4,6 @@ #include "Game/T6/CommonT6.h" #include "Game/T6/GameT6.h" #include "NormalizedJson.h" -#include "Pool/AssetPoolDynamic.h" #include "SearchPath/MockOutputPath.h" #include "SearchPath/MockSearchPath.h" #include "Utils/MemoryManager.h" @@ -35,7 +34,7 @@ namespace return techset; } - void GivenMaterial(const std::string& name, AssetPool& pool, MemoryManager& memory) + void GivenMaterial(const std::string& name, Zone& zone, MemoryManager& memory) { auto* material = memory.Alloc(); material->info.name = memory.Dup(name.c_str()); @@ -254,7 +253,7 @@ namespace material->thermalMaterial = nullptr; - pool.AddAsset(std::make_unique>(ASSET_TYPE_MATERIAL, name, material)); + zone.m_pools.AddAsset(std::make_unique>(ASSET_TYPE_MATERIAL, name, material)); } TEST_CASE("DumperMaterial(T6): Can dump material", "[t6][material][assetdumper]") @@ -469,10 +468,9 @@ namespace MockOutputPath mockOutput; AssetDumpingContext context(zone, "", mockOutput, mockObjPath, std::nullopt); - AssetPoolDynamic materialPool(0); - GivenMaterial("wpc/metal_ac_duct", materialPool, memory); + GivenMaterial("wpc/metal_ac_duct", zone, memory); - material::JsonDumperT6 dumper(materialPool); + material::JsonDumperT6 dumper; dumper.Dump(context); const auto* file = mockOutput.GetMockedFile("materials/wpc/metal_ac_duct.json"); diff --git a/test/SystemTests/Game/IW3/SimpleZoneIW3.cpp b/test/SystemTests/Game/IW3/SimpleZoneIW3.cpp index d2d989b7..a8c49ac9 100644 --- a/test/SystemTests/Game/IW3/SimpleZoneIW3.cpp +++ b/test/SystemTests/Game/IW3/SimpleZoneIW3.cpp @@ -1,4 +1,4 @@ -#include "Game/IW3/GameAssetPoolIW3.h" +#include "Game/IW3/IW3.h" #include "Linker.h" #include "OatTestPaths.h" #include "SystemTestsPaths.h" @@ -51,12 +51,11 @@ namespace REQUIRE(maybeZone); auto zone = std::move(*maybeZone); - auto pools = dynamic_cast(zone->m_pools.get()); REQUIRE(zone->m_game_id == GameId::IW3); REQUIRE(zone->m_platform == GamePlatform::PC); REQUIRE(zone->m_name == "SimpleZoneIW3"); - REQUIRE(pools->GetTotalAssetCount() == 1); - REQUIRE(pools->m_raw_file->GetAsset("SimpleZone.txt")); + REQUIRE(zone->m_pools.GetTotalAssetCount() == 1); + REQUIRE(zone->m_pools.GetAsset("SimpleZone.txt")); } } // namespace diff --git a/test/SystemTests/Game/IW4/SimpleZoneIW4.cpp b/test/SystemTests/Game/IW4/SimpleZoneIW4.cpp index b41799ee..a672e133 100644 --- a/test/SystemTests/Game/IW4/SimpleZoneIW4.cpp +++ b/test/SystemTests/Game/IW4/SimpleZoneIW4.cpp @@ -1,4 +1,4 @@ -#include "Game/IW4/GameAssetPoolIW4.h" +#include "Game/IW4/IW4.h" #include "Linker.h" #include "OatTestPaths.h" #include "SystemTestsPaths.h" @@ -51,12 +51,11 @@ namespace REQUIRE(maybeZone); auto zone = std::move(*maybeZone); - auto pools = dynamic_cast(zone->m_pools.get()); REQUIRE(zone->m_game_id == GameId::IW4); REQUIRE(zone->m_platform == GamePlatform::PC); REQUIRE(zone->m_name == "SimpleZoneIW4"); - REQUIRE(pools->GetTotalAssetCount() == 1); - REQUIRE(pools->m_raw_file->GetAsset("SimpleZone.txt")); + REQUIRE(zone->m_pools.GetTotalAssetCount() == 1); + REQUIRE(zone->m_pools.GetAsset("SimpleZone.txt")); } } // namespace diff --git a/test/SystemTests/Game/IW5/SimpleZoneIW5.cpp b/test/SystemTests/Game/IW5/SimpleZoneIW5.cpp index 3d5979ce..a4af5b4d 100644 --- a/test/SystemTests/Game/IW5/SimpleZoneIW5.cpp +++ b/test/SystemTests/Game/IW5/SimpleZoneIW5.cpp @@ -1,4 +1,5 @@ -#include "Game/IW5/GameAssetPoolIW5.h" + +#include "Game/IW5/IW5.h" #include "Linker.h" #include "OatTestPaths.h" #include "SystemTestsPaths.h" @@ -51,12 +52,11 @@ namespace REQUIRE(maybeZone); auto zone = std::move(*maybeZone); - auto pools = dynamic_cast(zone->m_pools.get()); REQUIRE(zone->m_game_id == GameId::IW5); REQUIRE(zone->m_platform == GamePlatform::PC); REQUIRE(zone->m_name == "SimpleZoneIW5"); - REQUIRE(pools->GetTotalAssetCount() == 1); - REQUIRE(pools->m_raw_file->GetAsset("SimpleZone.txt")); + REQUIRE(zone->m_pools.GetTotalAssetCount() == 1); + REQUIRE(zone->m_pools.GetAsset("SimpleZone.txt")); } } // namespace diff --git a/test/SystemTests/Game/T5/SimpleZoneT5.cpp b/test/SystemTests/Game/T5/SimpleZoneT5.cpp index 6f85e0de..080f6eb9 100644 --- a/test/SystemTests/Game/T5/SimpleZoneT5.cpp +++ b/test/SystemTests/Game/T5/SimpleZoneT5.cpp @@ -1,4 +1,4 @@ -#include "Game/T5/GameAssetPoolT5.h" +#include "Game/T5/T5.h" #include "Linker.h" #include "OatTestPaths.h" #include "SystemTestsPaths.h" @@ -51,12 +51,11 @@ namespace REQUIRE(maybeZone); auto zone = std::move(*maybeZone); - auto pools = dynamic_cast(zone->m_pools.get()); REQUIRE(zone->m_game_id == GameId::T5); REQUIRE(zone->m_platform == GamePlatform::PC); REQUIRE(zone->m_name == "SimpleZoneT5"); - REQUIRE(pools->GetTotalAssetCount() == 1); - REQUIRE(pools->m_raw_file->GetAsset("SimpleZone.txt")); + REQUIRE(zone->m_pools.GetTotalAssetCount() == 1); + REQUIRE(zone->m_pools.GetAsset("SimpleZone.txt")); } } // namespace diff --git a/test/SystemTests/Game/T6/ExtendAndDereferenceT6.cpp b/test/SystemTests/Game/T6/ExtendAndDereferenceT6.cpp index 17ad84bc..57b25763 100644 --- a/test/SystemTests/Game/T6/ExtendAndDereferenceT6.cpp +++ b/test/SystemTests/Game/T6/ExtendAndDereferenceT6.cpp @@ -9,7 +9,7 @@ In this case: (actual asset, not a reference) techniqueset `trivial_floatz_2992w610` */ -#include "Game/T6/GameAssetPoolT6.h" +#include "Game/T6/T6.h" #include "Linker.h" #include "OatTestPaths.h" #include "SystemTestsPaths.h" @@ -100,15 +100,14 @@ namespace REQUIRE(maybeZone); auto zone = std::move(*maybeZone); - auto pools = dynamic_cast(zone->m_pools.get()); REQUIRE(zone->m_game_id == GameId::T6); REQUIRE(zone->m_platform == GamePlatform::PC); REQUIRE(zone->m_name == "CombinedZoneT6"); - REQUIRE(pools->GetTotalAssetCount() == 2); - REQUIRE(pools->m_technique_set->GetAsset("trivial_floatz_2992w610")); + REQUIRE(zone->m_pools.GetTotalAssetCount() == 2); + REQUIRE(zone->m_pools.GetAsset("trivial_floatz_2992w610")); - const auto* material = pools->m_material->GetAsset("test"); + const auto* material = zone->m_pools.GetAsset("test"); REQUIRE(material); REQUIRE(material->Asset()->techniqueSet); REQUIRE(material->Asset()->techniqueSet->name == "trivial_floatz_2992w610"s); diff --git a/test/SystemTests/Game/T6/ReuseGlobalAssetPoolsAssetsT6.cpp b/test/SystemTests/Game/T6/ReuseGlobalAssetPoolsAssetsT6.cpp index 44975b54..3e98e1b1 100644 --- a/test/SystemTests/Game/T6/ReuseGlobalAssetPoolsAssetsT6.cpp +++ b/test/SystemTests/Game/T6/ReuseGlobalAssetPoolsAssetsT6.cpp @@ -9,7 +9,7 @@ In this case: (actual asset, not a reference) techniqueset `trivial_floatz_2992w610` */ -#include "Game/T6/GameAssetPoolT6.h" +#include "Game/T6/T6.h" #include "Linker.h" #include "OatTestPaths.h" #include "SystemTestsPaths.h" @@ -103,16 +103,15 @@ namespace REQUIRE(maybeZone); auto zone = std::move(*maybeZone); - auto pools = dynamic_cast(zone->m_pools.get()); REQUIRE(zone->m_game_id == GameId::T6); REQUIRE(zone->m_platform == GamePlatform::PC); REQUIRE(zone->m_name == "TestZone"); - REQUIRE(pools->GetTotalAssetCount() == 3); - REQUIRE(pools->m_material->GetAsset("Suzanne2")); - REQUIRE(pools->m_technique_set->GetAsset(",trivial_floatz_2992w610")); + REQUIRE(zone->m_pools.GetTotalAssetCount() == 3); + REQUIRE(zone->m_pools.GetAsset("Suzanne2")); + REQUIRE(zone->m_pools.GetAsset(",trivial_floatz_2992w610")); - const auto* xmodel = pools->m_xmodel->GetAsset("Suzanne2"); + const auto* xmodel = zone->m_pools.GetAsset("Suzanne2"); REQUIRE(xmodel); REQUIRE(xmodel->Asset()->boneNames); REQUIRE(xmodel->Asset()->numRootBones == 1); diff --git a/test/SystemTests/Game/T6/SimpleZoneT6.cpp b/test/SystemTests/Game/T6/SimpleZoneT6.cpp index 8cb4076f..c9e9b678 100644 --- a/test/SystemTests/Game/T6/SimpleZoneT6.cpp +++ b/test/SystemTests/Game/T6/SimpleZoneT6.cpp @@ -1,4 +1,4 @@ -#include "Game/T6/GameAssetPoolT6.h" +#include "Game/T6/T6.h" #include "Linker.h" #include "OatTestPaths.h" #include "SystemTestsPaths.h" @@ -51,12 +51,11 @@ namespace REQUIRE(maybeZone); auto zone = std::move(*maybeZone); - auto pools = dynamic_cast(zone->m_pools.get()); REQUIRE(zone->m_game_id == GameId::T6); REQUIRE(zone->m_platform == GamePlatform::PC); REQUIRE(zone->m_name == "SimpleZoneT6"); - REQUIRE(pools->GetTotalAssetCount() == 1); - REQUIRE(pools->m_raw_file->GetAsset("SimpleZone.txt")); + REQUIRE(zone->m_pools.GetTotalAssetCount() == 1); + REQUIRE(zone->m_pools.GetAsset("SimpleZone.txt")); } } // namespace diff --git a/test/SystemTests/RebuildVanillaZonesTests.cpp b/test/SystemTests/RebuildVanillaZonesTests.cpp index 82fa2567..f9e11b2e 100644 --- a/test/SystemTests/RebuildVanillaZonesTests.cpp +++ b/test/SystemTests/RebuildVanillaZonesTests.cpp @@ -1,4 +1,4 @@ -#include "Game/T6/GameAssetPoolT6.h" +#include "Game/T6/T6.h" #include "OatTestPaths.h" #include "Utils/Logging/Log.h" #include "Utils/StringUtils.h" @@ -47,8 +47,8 @@ namespace auto rebuiltZone = std::move(*maybeRebuiltZone); - const auto& pools = *zone->m_pools; - const auto& rebuiltPools = *rebuiltZone->m_pools; + const auto& pools = zone->m_pools; + const auto& rebuiltPools = rebuiltZone->m_pools; const auto totalAssetCount = pools.GetTotalAssetCount(); REQUIRE(totalAssetCount == rebuiltPools.GetTotalAssetCount());