From eb0cec1d813fad1a789b1dccadf062a9d685da06 Mon Sep 17 00:00:00 2001 From: Jan Date: Mon, 22 Apr 2024 23:36:21 +0200 Subject: [PATCH 1/4] refactor: make LoadDependency and LoadIndirectAssetReference functions work with Asset template types --- .../AssetLoading/IAssetLoadingManager.h | 16 ++++++++++ .../AssetLoaders/AssetLoaderGfxLightDef.cpp | 2 +- .../IW4/AssetLoaders/AssetLoaderMaterial.cpp | 4 +-- .../AssetLoaders/AssetLoaderTechniqueSet.cpp | 10 +++---- .../IW4/AssetLoaders/AssetLoaderWeapon.cpp | 2 +- .../InfoStringToStructConverter.cpp | 30 +++++++++---------- .../Game/IW4/Menu/MenuConverterIW4.cpp | 8 ++--- .../IW5/AssetLoaders/AssetLoaderWeapon.cpp | 10 +++---- .../InfoStringToStructConverter.cpp | 30 +++++++++---------- .../Game/IW5/Menu/MenuConverterIW5.cpp | 8 ++--- .../T6/AssetLoaders/AssetLoaderFontIcon.cpp | 4 +-- .../T6/AssetLoaders/AssetLoaderWeapon.cpp | 16 +++++----- .../AssetLoaderWeaponAttachmentUnique.cpp | 8 ++--- .../InfoStringToStructConverter.cpp | 30 +++++++++---------- .../Game/T6/Material/JsonMaterialLoader.cpp | 6 ++-- .../T6/WeaponCamo/JsonWeaponCamoLoader.cpp | 12 ++++---- 16 files changed, 106 insertions(+), 90 deletions(-) diff --git a/src/ObjLoading/AssetLoading/IAssetLoadingManager.h b/src/ObjLoading/AssetLoading/IAssetLoadingManager.h index b7283769..398a6515 100644 --- a/src/ObjLoading/AssetLoading/IAssetLoadingManager.h +++ b/src/ObjLoading/AssetLoading/IAssetLoadingManager.h @@ -1,5 +1,6 @@ #pragma once #include "AssetLoadingContext.h" +#include "Game/IAsset.h" #include "Pool/XAssetInfo.h" #include "Utils/ClassUtils.h" #include "Zone/ZoneTypes.h" @@ -50,6 +51,21 @@ public: assetType, assetName, asset, std::move(dependencies), std::move(usedScriptStrings), std::move(indirectAssetReferences))); } + template XAssetInfo* LoadDependency(const std::string& assetName) + { + static_assert(std::is_base_of_v); + + return static_cast*>(LoadDependency(AssetType::EnumEntry, assetName)); + } + + template IndirectAssetReference LoadIndirectAssetReference(const std::string& assetName) + { + static_assert(std::is_base_of_v); + + return LoadIndirectAssetReference(AssetType::EnumEntry, assetName); + } + +protected: virtual XAssetInfoGeneric* LoadDependency(asset_type_t assetType, const std::string& assetName) = 0; virtual IndirectAssetReference LoadIndirectAssetReference(asset_type_t assetType, const std::string& assetName) = 0; }; diff --git a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderGfxLightDef.cpp b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderGfxLightDef.cpp index 816766f3..de01df08 100644 --- a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderGfxLightDef.cpp +++ b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderGfxLightDef.cpp @@ -52,7 +52,7 @@ bool AssetLoaderGfxLightDef::LoadFromRaw( file.m_stream->read(&imageName[0], static_cast(imageNameSize)); file.m_stream->read(reinterpret_cast(&lmapLookupStart), sizeof(int8_t)); - auto* imageDependency = reinterpret_cast*>(manager->LoadDependency(ASSET_TYPE_IMAGE, imageName)); + auto* imageDependency = manager->LoadDependency(imageName); if (!imageDependency) { diff --git a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderMaterial.cpp b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderMaterial.cpp index 3750403e..1d9d472f 100644 --- a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderMaterial.cpp +++ b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderMaterial.cpp @@ -808,7 +808,7 @@ namespace IW4 void SetTechniqueSet(const std::string& techsetName) { - auto* techset = reinterpret_cast*>(m_manager->LoadDependency(ASSET_TYPE_TECHNIQUE_SET, techsetName)); + auto* techset = m_manager->LoadDependency(techsetName); if (techset == nullptr) { @@ -994,7 +994,7 @@ namespace IW4 break; } - auto* image = reinterpret_cast*>(m_manager->LoadDependency(ASSET_TYPE_IMAGE, textureName)); + auto* image = m_manager->LoadDependency(textureName); if (image == nullptr) { diff --git a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderTechniqueSet.cpp b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderTechniqueSet.cpp index 90308388..e51a7a3b 100644 --- a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderTechniqueSet.cpp +++ b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderTechniqueSet.cpp @@ -391,7 +391,7 @@ namespace IW4 ss << materialStreamSourceAbbreviation[stream.source] << materialStreamDestinationAbbreviation[stream.dest]; } - pass.m_vertex_decl_asset = reinterpret_cast*>(m_manager->LoadDependency(ASSET_TYPE_VERTEXDECL, ss.str())); + pass.m_vertex_decl_asset = m_manager->LoadDependency(ss.str()); } bool AcceptEndPass(std::string& errorMessage) override @@ -461,7 +461,7 @@ namespace IW4 bool AcceptVertexShader(const std::string& vertexShaderName, std::string& errorMessage) override { - auto* vertexShaderDependency = m_manager->LoadDependency(ASSET_TYPE_VERTEXSHADER, vertexShaderName); + auto* vertexShaderDependency = m_manager->LoadDependency(vertexShaderName); if (vertexShaderDependency == nullptr) { std::ostringstream ss; @@ -472,7 +472,7 @@ namespace IW4 assert(!m_passes.empty()); auto& pass = m_passes.at(m_passes.size() - 1); - pass.m_vertex_shader = reinterpret_cast*>(vertexShaderDependency); + pass.m_vertex_shader = vertexShaderDependency; if (pass.m_vertex_shader->Asset()->name && pass.m_vertex_shader->Asset()->name[0] == ',') { @@ -501,7 +501,7 @@ namespace IW4 bool AcceptPixelShader(const std::string& pixelShaderName, std::string& errorMessage) override { - auto* pixelShaderDependency = m_manager->LoadDependency(ASSET_TYPE_PIXELSHADER, pixelShaderName); + auto* pixelShaderDependency = m_manager->LoadDependency(pixelShaderName); if (pixelShaderDependency == nullptr) { std::ostringstream ss; @@ -512,7 +512,7 @@ namespace IW4 assert(!m_passes.empty()); auto& pass = m_passes.at(m_passes.size() - 1); - pass.m_pixel_shader = reinterpret_cast*>(pixelShaderDependency); + pass.m_pixel_shader = pixelShaderDependency; if (pass.m_pixel_shader->Asset()->name && pass.m_pixel_shader->Asset()->name[0] == ',') { diff --git a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderWeapon.cpp b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderWeapon.cpp index 5fda3048..c7221d1d 100644 --- a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderWeapon.cpp +++ b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderWeapon.cpp @@ -137,7 +137,7 @@ namespace if (ConvertString(value, field.iOffset)) { if (!value.empty()) - m_indirect_asset_references.emplace(m_loading_manager->LoadIndirectAssetReference(ASSET_TYPE_XANIMPARTS, value)); + m_indirect_asset_references.emplace(m_loading_manager->LoadIndirectAssetReference(value)); return true; } diff --git a/src/ObjLoading/Game/IW4/InfoString/InfoStringToStructConverter.cpp b/src/ObjLoading/Game/IW4/InfoString/InfoStringToStructConverter.cpp index c18cbd97..4ac8d81a 100644 --- a/src/ObjLoading/Game/IW4/InfoString/InfoStringToStructConverter.cpp +++ b/src/ObjLoading/Game/IW4/InfoString/InfoStringToStructConverter.cpp @@ -54,11 +54,11 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons { if (value.empty()) { - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; return true; } - auto* fx = m_loading_manager->LoadDependency(ASSET_TYPE_FX, value); + auto* fx = m_loading_manager->LoadDependency(value); if (fx == nullptr) { @@ -67,7 +67,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons } m_dependencies.emplace(fx); - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = fx->m_ptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = fx->Asset(); return true; } @@ -76,11 +76,11 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons { if (value.empty()) { - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; return true; } - auto* xmodel = m_loading_manager->LoadDependency(ASSET_TYPE_XMODEL, value); + auto* xmodel = m_loading_manager->LoadDependency(value); if (xmodel == nullptr) { @@ -89,7 +89,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons } m_dependencies.emplace(xmodel); - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = xmodel->m_ptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = xmodel->Asset(); return true; } @@ -98,11 +98,11 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons { if (value.empty()) { - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; return true; } - auto* material = m_loading_manager->LoadDependency(ASSET_TYPE_MATERIAL, value); + auto* material = m_loading_manager->LoadDependency(value); if (material == nullptr) { @@ -111,7 +111,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons } m_dependencies.emplace(material); - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = material->m_ptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = material->Asset(); return true; } @@ -120,11 +120,11 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons { if (value.empty()) { - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; return true; } - auto* tracer = m_loading_manager->LoadDependency(ASSET_TYPE_TRACER, value); + auto* tracer = m_loading_manager->LoadDependency(value); if (tracer == nullptr) { @@ -133,7 +133,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons } m_dependencies.emplace(tracer); - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = tracer->m_ptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = tracer->Asset(); return true; } @@ -156,11 +156,11 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons { if (value.empty()) { - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; return true; } - auto* collmap = m_loading_manager->LoadDependency(ASSET_TYPE_PHYSCOLLMAP, value); + auto* collmap = m_loading_manager->LoadDependency(value); if (collmap == nullptr) { @@ -169,7 +169,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons } m_dependencies.emplace(collmap); - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = collmap->m_ptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = collmap->Asset(); return true; } diff --git a/src/ObjLoading/Game/IW4/Menu/MenuConverterIW4.cpp b/src/ObjLoading/Game/IW4/Menu/MenuConverterIW4.cpp index 2b29488f..4c27dbd5 100644 --- a/src/ObjLoading/Game/IW4/Menu/MenuConverterIW4.cpp +++ b/src/ObjLoading/Game/IW4/Menu/MenuConverterIW4.cpp @@ -83,11 +83,11 @@ namespace IW4 if (materialName.empty()) return nullptr; - auto* materialDependency = m_manager->LoadDependency(ASSET_TYPE_MATERIAL, materialName); + auto* materialDependency = m_manager->LoadDependency(materialName); if (!materialDependency) throw MenuConversionException("Failed to load material \"" + materialName + "\"", menu, item); - return static_cast(materialDependency->m_ptr); + return materialDependency->Asset(); } _NODISCARD snd_alias_list_t* ConvertSound(const std::string& soundName, const CommonMenuDef* menu, const CommonItemDef* item = nullptr) const @@ -95,11 +95,11 @@ namespace IW4 if (soundName.empty()) return nullptr; - auto* soundDependency = m_manager->LoadDependency(ASSET_TYPE_SOUND, soundName); + auto* soundDependency = m_manager->LoadDependency(soundName); if (!soundDependency) throw MenuConversionException("Failed to load sound \"" + soundName + "\"", menu, item); - return static_cast(soundDependency->m_ptr); + return soundDependency->Asset(); } bool HandleStaticDvarFunctionCall(Statement_s* gameStatement, diff --git a/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderWeapon.cpp b/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderWeapon.cpp index 2eeed39d..c81441a0 100644 --- a/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderWeapon.cpp +++ b/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderWeapon.cpp @@ -135,7 +135,7 @@ namespace if (ConvertString(value, field.iOffset)) { if (!value.empty()) - m_indirect_asset_references.emplace(m_loading_manager->LoadIndirectAssetReference(ASSET_TYPE_XANIMPARTS, value)); + m_indirect_asset_references.emplace(m_loading_manager->LoadIndirectAssetReference(value)); return true; } @@ -157,7 +157,7 @@ namespace auto currentOther = 0u; for (const auto& attachmentName : valueArray) { - auto* attachmentInfo = static_cast*>(m_loading_manager->LoadDependency(ASSET_TYPE_ATTACHMENT, attachmentName)); + auto* attachmentInfo = m_loading_manager->LoadDependency(attachmentName); if (!attachmentInfo) return false; m_dependencies.emplace(attachmentInfo); @@ -448,7 +448,7 @@ namespace } animName = m_memory->Dup(value.c_str()); - m_indirect_asset_references.emplace(m_loading_manager->LoadIndirectAssetReference(ASSET_TYPE_XANIMPARTS, value)); + m_indirect_asset_references.emplace(m_loading_manager->LoadIndirectAssetReference(value)); } void ParseSoundAlias(const std::string& value, SndAliasCustom& soundAlias) @@ -461,7 +461,7 @@ namespace soundAlias.name = m_memory->Alloc(); soundAlias.name->soundName = m_memory->Dup(value.c_str()); - m_indirect_asset_references.emplace(m_loading_manager->LoadIndirectAssetReference(ASSET_TYPE_SOUND, value)); + m_indirect_asset_references.emplace(m_loading_manager->LoadIndirectAssetReference(value)); } bool ParseFxEffectDef(const std::string& value, FxEffectDef*& fx) @@ -472,7 +472,7 @@ namespace return true; } - auto* fxInfo = static_cast*>(m_loading_manager->LoadDependency(ASSET_TYPE_FX, value)); + auto* fxInfo = m_loading_manager->LoadDependency(value); if (!fxInfo) { std::cerr << "Failed to load fx for override \"" << value << "\"\n"; diff --git a/src/ObjLoading/Game/IW5/InfoString/InfoStringToStructConverter.cpp b/src/ObjLoading/Game/IW5/InfoString/InfoStringToStructConverter.cpp index 3f8f7e55..4d312202 100644 --- a/src/ObjLoading/Game/IW5/InfoString/InfoStringToStructConverter.cpp +++ b/src/ObjLoading/Game/IW5/InfoString/InfoStringToStructConverter.cpp @@ -54,11 +54,11 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons { if (value.empty()) { - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; return true; } - auto* fx = m_loading_manager->LoadDependency(ASSET_TYPE_FX, value); + auto* fx = m_loading_manager->LoadDependency(value); if (fx == nullptr) { @@ -67,7 +67,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons } m_dependencies.emplace(fx); - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = fx->m_ptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = fx->Asset(); return true; } @@ -76,11 +76,11 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons { if (value.empty()) { - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; return true; } - auto* xmodel = m_loading_manager->LoadDependency(ASSET_TYPE_XMODEL, value); + auto* xmodel = m_loading_manager->LoadDependency(value); if (xmodel == nullptr) { @@ -89,7 +89,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons } m_dependencies.emplace(xmodel); - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = xmodel->m_ptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = xmodel->Asset(); return true; } @@ -98,11 +98,11 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons { if (value.empty()) { - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; return true; } - auto* material = m_loading_manager->LoadDependency(ASSET_TYPE_MATERIAL, value); + auto* material = m_loading_manager->LoadDependency(value); if (material == nullptr) { @@ -111,7 +111,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons } m_dependencies.emplace(material); - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = material->m_ptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = material->Asset(); return true; } @@ -120,11 +120,11 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons { if (value.empty()) { - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; return true; } - auto* tracer = m_loading_manager->LoadDependency(ASSET_TYPE_TRACER, value); + auto* tracer = m_loading_manager->LoadDependency(value); if (tracer == nullptr) { @@ -133,7 +133,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons } m_dependencies.emplace(tracer); - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = tracer->m_ptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = tracer->Asset(); return true; } @@ -156,11 +156,11 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons { if (value.empty()) { - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; return true; } - auto* collmap = m_loading_manager->LoadDependency(ASSET_TYPE_PHYSCOLLMAP, value); + auto* collmap = m_loading_manager->LoadDependency(value); if (collmap == nullptr) { @@ -169,7 +169,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons } m_dependencies.emplace(collmap); - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = collmap->m_ptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = collmap->Asset(); return true; } diff --git a/src/ObjLoading/Game/IW5/Menu/MenuConverterIW5.cpp b/src/ObjLoading/Game/IW5/Menu/MenuConverterIW5.cpp index ba55f60c..e36a7b37 100644 --- a/src/ObjLoading/Game/IW5/Menu/MenuConverterIW5.cpp +++ b/src/ObjLoading/Game/IW5/Menu/MenuConverterIW5.cpp @@ -83,11 +83,11 @@ namespace IW5 if (materialName.empty()) return nullptr; - auto* materialDependency = m_manager->LoadDependency(ASSET_TYPE_MATERIAL, materialName); + auto* materialDependency = m_manager->LoadDependency(materialName); if (!materialDependency) throw MenuConversionException("Failed to load material \"" + materialName + "\"", menu, item); - return static_cast(materialDependency->m_ptr); + return materialDependency->Asset(); } _NODISCARD snd_alias_list_t* ConvertSound(const std::string& soundName, const CommonMenuDef* menu, const CommonItemDef* item = nullptr) const @@ -95,11 +95,11 @@ namespace IW5 if (soundName.empty()) return nullptr; - auto* soundDependency = m_manager->LoadDependency(ASSET_TYPE_SOUND, soundName); + auto* soundDependency = m_manager->LoadDependency(soundName); if (!soundDependency) throw MenuConversionException("Failed to load sound \"" + soundName + "\"", menu, item); - return static_cast(soundDependency->m_ptr); + return soundDependency->Asset(); } bool HandleStaticDvarFunctionCall(Statement_s* gameStatement, diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderFontIcon.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderFontIcon.cpp index b86b2661..b89b4f8c 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderFontIcon.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderFontIcon.cpp @@ -117,14 +117,14 @@ bool AssetLoaderFontIcon::ReadIconRow(const std::vector& row, return false; } - auto* materialDependency = manager->LoadDependency(ASSET_TYPE_MATERIAL, row[ROW_ICON_MATERIAL]); + auto* materialDependency = manager->LoadDependency(row[ROW_ICON_MATERIAL]); if (materialDependency == nullptr) { std::cout << ErrorPrefix(assetName, rowIndex) << "Failed to load material \"" << row[ROW_ICON_MATERIAL] << "\"\n"; return false; } - icon.fontIconMaterialHandle = static_cast(materialDependency->m_ptr); + icon.fontIconMaterialHandle = materialDependency->Asset(); icon.fontIconName.string = memory->Dup(row[ROW_ICON_NAME].c_str()); icon.fontIconName.hash = Common::Com_HashString(icon.fontIconName.string); diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeapon.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeapon.cpp index 7d17d30a..96f21e6f 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeapon.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeapon.cpp @@ -132,11 +132,11 @@ namespace T6 { if (value.empty()) { - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; return true; } - auto* camo = m_loading_manager->LoadDependency(ASSET_TYPE_WEAPON_CAMO, value); + auto* camo = m_loading_manager->LoadDependency(value); if (camo == nullptr) { @@ -145,7 +145,7 @@ namespace T6 } m_dependencies.emplace(camo); - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = camo->m_ptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = camo->Asset(); return true; } @@ -163,14 +163,14 @@ namespace T6 for (const auto& attachmentName : valueArray) { - auto* attachmentAssetInfo = m_loading_manager->LoadDependency(ASSET_TYPE_ATTACHMENT, attachmentName); + auto* attachmentAssetInfo = m_loading_manager->LoadDependency(attachmentName); if (attachmentAssetInfo == nullptr) { std::cerr << "Failed to load attachment asset \"" << attachmentName << "\"\n"; return false; } - auto* attachmentAsset = static_cast(attachmentAssetInfo->m_ptr); + auto* attachmentAsset = attachmentAssetInfo->Asset(); if (static_cast(attachmentAsset->attachmentType) >= ATTACHMENT_TYPE_COUNT) { @@ -212,14 +212,14 @@ namespace T6 for (const auto& attachmentUniqueName : valueArray) { - auto* attachmentUniqueAssetInfo = m_loading_manager->LoadDependency(ASSET_TYPE_ATTACHMENT_UNIQUE, attachmentUniqueName); + auto* attachmentUniqueAssetInfo = m_loading_manager->LoadDependency(attachmentUniqueName); if (attachmentUniqueAssetInfo == nullptr) { std::cerr << "Failed to load attachment unique asset \"" << attachmentUniqueName << "\"\n"; return false; } - auto* attachmentUniqueAsset = static_cast(attachmentUniqueAssetInfo->m_ptr); + auto* attachmentUniqueAsset = attachmentUniqueAssetInfo->Asset(); if (HasMoreThanOneAttachmentSetInMask(attachmentUniqueAsset->combinedAttachmentTypeMask)) { @@ -263,7 +263,7 @@ namespace T6 if (ConvertString(value, field.iOffset)) { if (!value.empty()) - m_indirect_asset_references.emplace(m_loading_manager->LoadIndirectAssetReference(ASSET_TYPE_XANIMPARTS, value)); + m_indirect_asset_references.emplace(m_loading_manager->LoadIndirectAssetReference(value)); return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponAttachmentUnique.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponAttachmentUnique.cpp index 4081af74..1e3cd64a 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponAttachmentUnique.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponAttachmentUnique.cpp @@ -62,11 +62,11 @@ namespace T6 { if (value.empty()) { - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; return true; } - auto* camo = m_loading_manager->LoadDependency(ASSET_TYPE_WEAPON_CAMO, value); + auto* camo = m_loading_manager->LoadDependency(value); if (camo == nullptr) { @@ -75,7 +75,7 @@ namespace T6 } m_dependencies.emplace(camo); - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = camo->m_ptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = camo->Asset(); return true; } @@ -85,7 +85,7 @@ namespace T6 if (ConvertString(value, field.iOffset)) { if (!value.empty()) - m_indirect_asset_references.emplace(m_loading_manager->LoadIndirectAssetReference(ASSET_TYPE_XANIMPARTS, value)); + m_indirect_asset_references.emplace(m_loading_manager->LoadIndirectAssetReference(value)); return true; } diff --git a/src/ObjLoading/Game/T6/InfoString/InfoStringToStructConverter.cpp b/src/ObjLoading/Game/T6/InfoString/InfoStringToStructConverter.cpp index 11a039e4..6866a586 100644 --- a/src/ObjLoading/Game/T6/InfoString/InfoStringToStructConverter.cpp +++ b/src/ObjLoading/Game/T6/InfoString/InfoStringToStructConverter.cpp @@ -72,11 +72,11 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons { if (value.empty()) { - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; return true; } - auto* fx = m_loading_manager->LoadDependency(ASSET_TYPE_FX, value); + auto* fx = m_loading_manager->LoadDependency(value); if (fx == nullptr) { @@ -85,7 +85,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons } m_dependencies.emplace(fx); - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = fx->m_ptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = fx->Asset(); return true; } @@ -94,11 +94,11 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons { if (value.empty()) { - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; return true; } - auto* xmodel = m_loading_manager->LoadDependency(ASSET_TYPE_XMODEL, value); + auto* xmodel = m_loading_manager->LoadDependency(value); if (xmodel == nullptr) { @@ -107,7 +107,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons } m_dependencies.emplace(xmodel); - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = xmodel->m_ptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = xmodel->Asset(); return true; } @@ -117,11 +117,11 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons { if (value.empty()) { - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; return true; } - auto* material = m_loading_manager->LoadDependency(ASSET_TYPE_MATERIAL, value); + auto* material = m_loading_manager->LoadDependency(value); if (material == nullptr) { @@ -130,7 +130,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons } m_dependencies.emplace(material); - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = material->m_ptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = material->Asset(); return true; } @@ -139,11 +139,11 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons { if (value.empty()) { - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; return true; } - auto* physPreset = m_loading_manager->LoadDependency(ASSET_TYPE_PHYSPRESET, value); + auto* physPreset = m_loading_manager->LoadDependency(value); if (physPreset == nullptr) { @@ -152,7 +152,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons } m_dependencies.emplace(physPreset); - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = physPreset->m_ptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = physPreset->Asset(); return true; } @@ -164,11 +164,11 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons { if (value.empty()) { - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = nullptr; return true; } - auto* tracer = m_loading_manager->LoadDependency(ASSET_TYPE_TRACER, value); + auto* tracer = m_loading_manager->LoadDependency(value); if (tracer == nullptr) { @@ -177,7 +177,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons } m_dependencies.emplace(tracer); - *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = tracer->m_ptr; + *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = tracer->Asset(); return true; } diff --git a/src/ObjLoading/Game/T6/Material/JsonMaterialLoader.cpp b/src/ObjLoading/Game/T6/Material/JsonMaterialLoader.cpp index 2011b30d..c714a955 100644 --- a/src/ObjLoading/Game/T6/Material/JsonMaterialLoader.cpp +++ b/src/ObjLoading/Game/T6/Material/JsonMaterialLoader.cpp @@ -99,7 +99,7 @@ namespace textureDef.semantic = jTexture.semantic; textureDef.isMatureContent = jTexture.isMatureContent; - auto* image = static_cast*>(m_manager.LoadDependency(ASSET_TYPE_IMAGE, jTexture.image)); + auto* image = m_manager.LoadDependency(jTexture.image); if (!image) { PrintError(material, std::format("Could not find textureDef image: {}", jTexture.image)); @@ -275,7 +275,7 @@ namespace material.cameraRegion = jMaterial.cameraRegion; material.probeMipBits = jMaterial.probeMipBits; - auto* techniqueSet = static_cast*>(m_manager.LoadDependency(ASSET_TYPE_TECHNIQUE_SET, jMaterial.techniqueSet)); + auto* techniqueSet = m_manager.LoadDependency(jMaterial.techniqueSet); if (!techniqueSet) { PrintError(material, "Could not find technique set"); @@ -337,7 +337,7 @@ namespace if (jMaterial.thermalMaterial) { - auto* thermalMaterial = static_cast*>(m_manager.LoadDependency(ASSET_TYPE_MATERIAL, jMaterial.thermalMaterial.value())); + auto* thermalMaterial = m_manager.LoadDependency(jMaterial.thermalMaterial.value()); if (!thermalMaterial) { PrintError(material, "Could not find thermal material"); diff --git a/src/ObjLoading/Game/T6/WeaponCamo/JsonWeaponCamoLoader.cpp b/src/ObjLoading/Game/T6/WeaponCamo/JsonWeaponCamoLoader.cpp index bb437b86..fada1b6e 100644 --- a/src/ObjLoading/Game/T6/WeaponCamo/JsonWeaponCamoLoader.cpp +++ b/src/ObjLoading/Game/T6/WeaponCamo/JsonWeaponCamoLoader.cpp @@ -53,7 +53,7 @@ namespace { if (jWeaponCamoSet.solidCamoImage) { - auto* image = static_cast*>(m_manager.LoadDependency(ASSET_TYPE_IMAGE, jWeaponCamoSet.solidCamoImage.value())); + auto* image = m_manager.LoadDependency(jWeaponCamoSet.solidCamoImage.value()); if (!image) { PrintError(weaponCamo, "Could not find solidCamoImage"); @@ -65,7 +65,7 @@ namespace if (jWeaponCamoSet.patternCamoImage) { - auto* image = static_cast*>(m_manager.LoadDependency(ASSET_TYPE_IMAGE, jWeaponCamoSet.patternCamoImage.value())); + auto* image = m_manager.LoadDependency(jWeaponCamoSet.patternCamoImage.value()); if (!image) { PrintError(weaponCamo, "Could not find patternCamoImage"); @@ -102,8 +102,8 @@ namespace for (auto i = 0u; i < weaponCamoMaterial.numBaseMaterials; i++) { const auto& materialOverride = jWeaponCamoMaterial.materialOverrides[i]; - auto* baseMaterial = static_cast*>(m_manager.LoadDependency(ASSET_TYPE_MATERIAL, materialOverride.baseMaterial)); - auto* camoMaterial = static_cast*>(m_manager.LoadDependency(ASSET_TYPE_MATERIAL, materialOverride.camoMaterial)); + auto* baseMaterial = m_manager.LoadDependency(materialOverride.baseMaterial); + auto* camoMaterial = m_manager.LoadDependency(materialOverride.camoMaterial); if (!baseMaterial) { @@ -164,7 +164,7 @@ namespace { if (jWeaponCamo.solidBaseImage) { - auto* image = static_cast*>(m_manager.LoadDependency(ASSET_TYPE_IMAGE, jWeaponCamo.solidBaseImage.value())); + auto* image = m_manager.LoadDependency(jWeaponCamo.solidBaseImage.value()); if (!image) { PrintError(weaponCamo, "Could not find solidBaseImage"); @@ -176,7 +176,7 @@ namespace if (jWeaponCamo.patternBaseImage) { - auto* image = static_cast*>(m_manager.LoadDependency(ASSET_TYPE_IMAGE, jWeaponCamo.patternBaseImage.value())); + auto* image = m_manager.LoadDependency(jWeaponCamo.patternBaseImage.value()); if (!image) { PrintError(weaponCamo, "Could not find patternBaseImage"); From d0c7311dcee6e143376bb7dba8763b47152b4a63 Mon Sep 17 00:00:00 2001 From: Jan Date: Tue, 23 Apr 2024 00:05:56 +0200 Subject: [PATCH 2/4] fix: iw4 and iw5 structured data def asset using wrong struct --- src/Common/Game/IW4/IW4.h | 2 +- src/Common/Game/IW5/IW5.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Common/Game/IW4/IW4.h b/src/Common/Game/IW4/IW4.h index 53f972e2..aaed950f 100644 --- a/src/Common/Game/IW4/IW4.h +++ b/src/Common/Game/IW4/IW4.h @@ -164,7 +164,7 @@ namespace IW4 using AssetRawFile = Asset; using AssetStringTable = Asset; using AssetLeaderBoard = Asset; - using AssetStructuredDataDef = Asset; + using AssetStructuredDataDef = Asset; using AssetTracer = Asset; using AssetVehicle = Asset; using AssetAddonMapEnts = Asset; diff --git a/src/Common/Game/IW5/IW5.h b/src/Common/Game/IW5/IW5.h index 18513576..c7e93b93 100644 --- a/src/Common/Game/IW5/IW5.h +++ b/src/Common/Game/IW5/IW5.h @@ -175,7 +175,7 @@ namespace IW5 using AssetScript = Asset; using AssetStringTable = Asset; using AssetLeaderBoard = Asset; - using AssetStructuredDataDef = Asset; + using AssetStructuredDataDef = Asset; using AssetTracer = Asset; using AssetVehicle = Asset; using AssetAddonMapEnts = Asset; From 931fe695e1c61ee6bb56971975c01d0a92cd42dc Mon Sep 17 00:00:00 2001 From: Jan Date: Tue, 23 Apr 2024 00:06:28 +0200 Subject: [PATCH 3/4] refactor: use template asset structs for AddAsset api --- .../AssetLoading/IAssetLoadingManager.h | 58 ++++++++++++------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/src/ObjLoading/AssetLoading/IAssetLoadingManager.h b/src/ObjLoading/AssetLoading/IAssetLoadingManager.h index 398a6515..a8c2f64f 100644 --- a/src/ObjLoading/AssetLoading/IAssetLoadingManager.h +++ b/src/ObjLoading/AssetLoading/IAssetLoadingManager.h @@ -19,36 +19,53 @@ public: _NODISCARD virtual AssetLoadingContext* GetAssetLoadingContext() const = 0; - virtual XAssetInfoGeneric* AddAsset(std::unique_ptr xAssetInfo) = 0; - - XAssetInfoGeneric* AddAsset(const asset_type_t assetType, const std::string& assetName, void* asset) + template XAssetInfo* AddAsset(const std::string& assetName, typename AssetType::Type* asset) { - return AddAsset(assetType, assetName, asset, std::vector(), std::vector()); + static_assert(std::is_base_of_v); + + return static_cast*>(AddAsset(std::make_unique( + AssetType::EnumEntry, assetName, asset, std::vector(), std::vector(), std::vector()))); } - XAssetInfoGeneric* AddAsset(const asset_type_t assetType, const std::string& assetName, void* asset, std::vector dependencies) + template + XAssetInfo* AddAsset(const std::string& assetName, typename AssetType::Type* asset, std::vector dependencies) { - return AddAsset(assetType, assetName, asset, std::move(dependencies), std::vector()); + static_assert(std::is_base_of_v); + + return static_cast*>(AddAsset(std::make_unique( + AssetType::EnumEntry, assetName, asset, std::move(dependencies), std::vector(), std::vector()))); } - XAssetInfoGeneric* AddAsset(const asset_type_t assetType, - const std::string& assetName, - void* asset, - std::vector dependencies, - std::vector usedScriptStrings) + template + XAssetInfo* AddAsset(const std::string& assetName, + typename AssetType::Type* asset, + std::vector dependencies, + std::vector usedScriptStrings) { - return AddAsset(assetType, assetName, asset, std::move(dependencies), std::move(usedScriptStrings), std::vector()); + static_assert(std::is_base_of_v); + + return static_cast*>(AddAsset(std::make_unique( + AssetType::EnumEntry, assetName, asset, std::move(dependencies), std::move(usedScriptStrings), std::vector()))); } - XAssetInfoGeneric* AddAsset(const asset_type_t assetType, - const std::string& assetName, - void* asset, - std::vector dependencies, - std::vector usedScriptStrings, - std::vector indirectAssetReferences) + template + XAssetInfo* AddAsset(const std::string& assetName, + typename AssetType::Type* asset, + std::vector dependencies, + std::vector usedScriptStrings, + std::vector indirectAssetReferences) { - return AddAsset(std::make_unique( - assetType, assetName, asset, std::move(dependencies), std::move(usedScriptStrings), std::move(indirectAssetReferences))); + static_assert(std::is_base_of_v); + + return static_cast*>(AddAsset(std::make_unique( + AssetType::EnumEntry, assetName, asset, std::move(dependencies), std::move(usedScriptStrings), std::move(indirectAssetReferences)))); + } + + template XAssetInfo* AddAsset(std::unique_ptr> xAssetInfo) + { + static_assert(std::is_base_of_v); + + return static_cast*>(AddAsset(std::unique_ptr(xAssetInfo.release()))); } template XAssetInfo* LoadDependency(const std::string& assetName) @@ -66,6 +83,7 @@ public: } protected: + virtual XAssetInfoGeneric* AddAsset(std::unique_ptr xAssetInfo) = 0; virtual XAssetInfoGeneric* LoadDependency(asset_type_t assetType, const std::string& assetName) = 0; virtual IndirectAssetReference LoadIndirectAssetReference(asset_type_t assetType, const std::string& assetName) = 0; }; From ae43a994b96fc49f4c41c9df1b0358ec5b5da4d9 Mon Sep 17 00:00:00 2001 From: Jan Date: Tue, 23 Apr 2024 00:06:48 +0200 Subject: [PATCH 4/4] chore: update usages of AddAsset for template asset struct api --- src/ObjLoading/AssetLoading/AssetLoadingManager.cpp | 3 +-- .../Game/IW3/AssetLoaders/AssetLoaderGfxImage.cpp | 2 +- .../Game/IW3/AssetLoaders/AssetLoaderLocalizeEntry.cpp | 2 +- .../Game/IW3/AssetLoaders/AssetLoaderRawFile.cpp | 2 +- .../Game/IW3/AssetLoaders/AssetLoaderStringTable.cpp | 2 +- .../Game/IW4/AssetLoaders/AssetLoaderGfxLightDef.cpp | 2 +- .../Game/IW4/AssetLoaders/AssetLoaderLocalizeEntry.cpp | 2 +- .../Game/IW4/AssetLoaders/AssetLoaderMaterial.cpp | 4 +++- .../Game/IW4/AssetLoaders/AssetLoaderMenuList.cpp | 7 +++---- .../Game/IW4/AssetLoaders/AssetLoaderPhysPreset.cpp | 2 +- .../Game/IW4/AssetLoaders/AssetLoaderPixelShader.cpp | 2 +- .../Game/IW4/AssetLoaders/AssetLoaderRawFile.cpp | 2 +- .../Game/IW4/AssetLoaders/AssetLoaderSndCurve.cpp | 2 +- .../Game/IW4/AssetLoaders/AssetLoaderStringTable.cpp | 2 +- .../AssetLoaders/AssetLoaderStructuredDataDefSet.cpp | 2 +- .../Game/IW4/AssetLoaders/AssetLoaderTechniqueSet.cpp | 2 +- .../Game/IW4/AssetLoaders/AssetLoaderVertexDecl.cpp | 2 +- .../Game/IW4/AssetLoaders/AssetLoaderVertexShader.cpp | 2 +- .../Game/IW4/AssetLoaders/AssetLoaderWeapon.cpp | 8 ++------ .../Game/IW5/AssetLoaders/AssetLoaderLocalizeEntry.cpp | 2 +- .../Game/IW5/AssetLoaders/AssetLoaderMenuList.cpp | 7 +++---- .../Game/IW5/AssetLoaders/AssetLoaderRawFile.cpp | 2 +- .../Game/IW5/AssetLoaders/AssetLoaderScriptFile.cpp | 2 +- .../Game/IW5/AssetLoaders/AssetLoaderStringTable.cpp | 2 +- .../Game/IW5/AssetLoaders/AssetLoaderWeapon.cpp | 8 ++------ .../IW5/AssetLoaders/AssetLoaderWeaponAttachment.cpp | 3 +-- .../Game/IW5/Weapon/JsonWeaponAttachmentLoader.cpp | 10 +++++----- .../Game/T5/AssetLoaders/AssetLoaderLocalizeEntry.cpp | 2 +- .../Game/T5/AssetLoaders/AssetLoaderRawFile.cpp | 4 ++-- .../Game/T5/AssetLoaders/AssetLoaderStringTable.cpp | 2 +- .../Game/T6/AssetLoaders/AssetLoaderFontIcon.cpp | 2 +- .../Game/T6/AssetLoaders/AssetLoaderGfxImage.cpp | 2 +- .../Game/T6/AssetLoaders/AssetLoaderLocalizeEntry.cpp | 2 +- .../Game/T6/AssetLoaders/AssetLoaderMaterial.cpp | 2 +- .../T6/AssetLoaders/AssetLoaderPhysConstraints.cpp | 2 +- .../Game/T6/AssetLoaders/AssetLoaderPhysPreset.cpp | 2 +- src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderQdb.cpp | 2 +- .../Game/T6/AssetLoaders/AssetLoaderRawFile.cpp | 4 ++-- .../T6/AssetLoaders/AssetLoaderScriptParseTree.cpp | 2 +- .../Game/T6/AssetLoaders/AssetLoaderSlug.cpp | 2 +- .../Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp | 2 +- .../Game/T6/AssetLoaders/AssetLoaderStringTable.cpp | 2 +- .../Game/T6/AssetLoaders/AssetLoaderTracer.cpp | 2 +- .../Game/T6/AssetLoaders/AssetLoaderVehicle.cpp | 2 +- .../Game/T6/AssetLoaders/AssetLoaderWeapon.cpp | 8 ++------ .../T6/AssetLoaders/AssetLoaderWeaponAttachment.cpp | 4 ++-- .../AssetLoaders/AssetLoaderWeaponAttachmentUnique.cpp | 8 ++------ .../Game/T6/AssetLoaders/AssetLoaderWeaponCamo.cpp | 2 +- .../Game/T6/AssetLoaders/AssetLoaderZBarrier.cpp | 2 +- 49 files changed, 66 insertions(+), 84 deletions(-) diff --git a/src/ObjLoading/AssetLoading/AssetLoadingManager.cpp b/src/ObjLoading/AssetLoading/AssetLoadingManager.cpp index eb3cb03b..e262e08a 100644 --- a/src/ObjLoading/AssetLoading/AssetLoadingManager.cpp +++ b/src/ObjLoading/AssetLoading/AssetLoadingManager.cpp @@ -50,8 +50,7 @@ XAssetInfoGeneric* AssetLoadingManager::LoadIgnoredDependency(const asset_type_t auto* linkAsset = loader->CreateEmptyAsset(assetName, m_context.m_zone->GetMemory()); if (linkAsset) { - IAssetLoadingManager::AddAsset( - assetType, assetName, linkAsset, std::vector(), std::vector(), std::vector()); + AddAsset(std::make_unique(assetType, assetName, linkAsset)); auto* lastDependency = m_last_dependency_loaded; m_last_dependency_loaded = nullptr; return lastDependency; diff --git a/src/ObjLoading/Game/IW3/AssetLoaders/AssetLoaderGfxImage.cpp b/src/ObjLoading/Game/IW3/AssetLoaders/AssetLoaderGfxImage.cpp index 0beea100..0351f788 100644 --- a/src/ObjLoading/Game/IW3/AssetLoaders/AssetLoaderGfxImage.cpp +++ b/src/ObjLoading/Game/IW3/AssetLoaders/AssetLoaderGfxImage.cpp @@ -127,7 +127,7 @@ bool AssetLoaderGfxImage::LoadFromRaw( } } - manager->AddAsset(ASSET_TYPE_IMAGE, assetName, image); + manager->AddAsset(assetName, image); return true; } diff --git a/src/ObjLoading/Game/IW3/AssetLoaders/AssetLoaderLocalizeEntry.cpp b/src/ObjLoading/Game/IW3/AssetLoaders/AssetLoaderLocalizeEntry.cpp index a6ab6caa..b71c5cf5 100644 --- a/src/ObjLoading/Game/IW3/AssetLoaders/AssetLoaderLocalizeEntry.cpp +++ b/src/ObjLoading/Game/IW3/AssetLoaders/AssetLoaderLocalizeEntry.cpp @@ -29,7 +29,7 @@ bool AssetLoaderLocalizeEntry::LoadFromRaw( localizeEntry->name = memory->Dup(entry.m_key.c_str()); localizeEntry->value = memory->Dup(entry.m_value.c_str()); - manager->AddAsset(ASSET_TYPE_LOCALIZE_ENTRY, entry.m_key, localizeEntry); + manager->AddAsset(entry.m_key, localizeEntry); }); return commonLoader.LoadLocalizeAsset(assetName, searchPath, manager, zone); diff --git a/src/ObjLoading/Game/IW3/AssetLoaders/AssetLoaderRawFile.cpp b/src/ObjLoading/Game/IW3/AssetLoaders/AssetLoaderRawFile.cpp index b14f245e..c865c06e 100644 --- a/src/ObjLoading/Game/IW3/AssetLoaders/AssetLoaderRawFile.cpp +++ b/src/ObjLoading/Game/IW3/AssetLoaders/AssetLoaderRawFile.cpp @@ -38,7 +38,7 @@ bool AssetLoaderRawFile::LoadFromRaw( fileBuffer[rawFile->len] = '\0'; rawFile->buffer = fileBuffer; - manager->AddAsset(ASSET_TYPE_RAWFILE, assetName, rawFile); + manager->AddAsset(assetName, rawFile); return true; } diff --git a/src/ObjLoading/Game/IW3/AssetLoaders/AssetLoaderStringTable.cpp b/src/ObjLoading/Game/IW3/AssetLoaders/AssetLoaderStringTable.cpp index 895f2b24..972e647f 100644 --- a/src/ObjLoading/Game/IW3/AssetLoaders/AssetLoaderStringTable.cpp +++ b/src/ObjLoading/Game/IW3/AssetLoaders/AssetLoaderStringTable.cpp @@ -33,7 +33,7 @@ bool AssetLoaderStringTable::LoadFromRaw( string_table::StringTableLoaderV1 loader; auto* stringTable = loader.LoadFromStream(assetName, *memory, *file.m_stream); - manager->AddAsset(ASSET_TYPE_STRINGTABLE, assetName, stringTable); + manager->AddAsset(assetName, stringTable); return true; } diff --git a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderGfxLightDef.cpp b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderGfxLightDef.cpp index de01df08..775eb766 100644 --- a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderGfxLightDef.cpp +++ b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderGfxLightDef.cpp @@ -66,7 +66,7 @@ bool AssetLoaderGfxLightDef::LoadFromRaw( lightDef->attenuation.image = imageDependency->Asset(); lightDef->lmapLookupStart = static_cast(static_cast(lmapLookupStart)); - manager->AddAsset(ASSET_TYPE_LIGHT_DEF, assetName, lightDef); + manager->AddAsset(assetName, lightDef); return true; } diff --git a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderLocalizeEntry.cpp b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderLocalizeEntry.cpp index ea83282c..6d4f596e 100644 --- a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderLocalizeEntry.cpp +++ b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderLocalizeEntry.cpp @@ -29,7 +29,7 @@ bool AssetLoaderLocalizeEntry::LoadFromRaw( localizeEntry->name = memory->Dup(entry.m_key.c_str()); localizeEntry->value = memory->Dup(entry.m_value.c_str()); - manager->AddAsset(ASSET_TYPE_LOCALIZE_ENTRY, entry.m_key, localizeEntry); + manager->AddAsset(entry.m_key, localizeEntry); }); return commonLoader.LoadLocalizeAsset(assetName, searchPath, manager, zone); diff --git a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderMaterial.cpp b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderMaterial.cpp index 1d9d472f..57efc24f 100644 --- a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderMaterial.cpp +++ b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderMaterial.cpp @@ -1381,7 +1381,9 @@ bool AssetLoaderMaterial::LoadFromGdt( try { if (loader.Load()) - manager->AddAsset(ASSET_TYPE_MATERIAL, assetName, loader.GetMaterial(), loader.GetDependencies(), std::vector()); + { + manager->AddAsset(assetName, loader.GetMaterial(), loader.GetDependencies()); + } } catch (const SkipMaterialException&) { diff --git a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderMenuList.cpp b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderMenuList.cpp index dde2b090..1907a41b 100644 --- a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderMenuList.cpp +++ b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderMenuList.cpp @@ -57,12 +57,11 @@ namespace IW4 } menus.push_back(menuAsset); - auto* menuAssetInfo = - manager->AddAsset(ASSET_TYPE_MENU, menu->m_name, menuAsset, std::move(converter.GetDependencies()), std::vector()); + auto* menuAssetInfo = manager->AddAsset(menu->m_name, menuAsset, std::move(converter.GetDependencies())); if (menuAssetInfo) { - allMenusOfFile.push_back(reinterpret_cast*>(menuAssetInfo)); + allMenusOfFile.push_back(menuAssetInfo); menuListDependencies.push_back(menuAssetInfo); } @@ -223,7 +222,7 @@ bool AssetLoaderMenuList::LoadFromRaw( auto* menuListAsset = MenuLoader::CreateMenuListAsset(assetName, memory, menus); if (menuListAsset) - manager->AddAsset(ASSET_TYPE_MENULIST, assetName, menuListAsset, menuListDependencies, std::vector()); + manager->AddAsset(assetName, menuListAsset, menuListDependencies); return true; } diff --git a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderPhysPreset.cpp b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderPhysPreset.cpp index ac0c581e..30701f60 100644 --- a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderPhysPreset.cpp +++ b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderPhysPreset.cpp @@ -75,7 +75,7 @@ bool AssetLoaderPhysPreset::LoadFromInfoString( CopyFromPhysPresetInfo(presetInfo.get(), physPreset); physPreset->name = memory->Dup(assetName.c_str()); - manager->AddAsset(ASSET_TYPE_PHYSPRESET, assetName, physPreset, converter.GetDependencies(), converter.GetUsedScriptStrings()); + manager->AddAsset(assetName, physPreset, converter.GetDependencies(), converter.GetUsedScriptStrings()); return true; } diff --git a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderPixelShader.cpp b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderPixelShader.cpp index dbedfef6..e034f6da 100644 --- a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderPixelShader.cpp +++ b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderPixelShader.cpp @@ -57,7 +57,7 @@ bool AssetLoaderPixelShader::LoadFromRaw( return false; pixelShader->prog.loadDef.program = fileBuffer; - manager->AddAsset(ASSET_TYPE_PIXELSHADER, assetName, pixelShader); + manager->AddAsset(assetName, pixelShader); return true; } diff --git a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderRawFile.cpp b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderRawFile.cpp index ff79965f..20db51ad 100644 --- a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderRawFile.cpp +++ b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderRawFile.cpp @@ -74,7 +74,7 @@ bool AssetLoaderRawFile::LoadFromRaw( deflateEnd(&zs); - manager->AddAsset(ASSET_TYPE_RAWFILE, assetName, rawFile); + manager->AddAsset(assetName, rawFile); return true; } diff --git a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderSndCurve.cpp b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderSndCurve.cpp index c657d8c7..53822d4a 100644 --- a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderSndCurve.cpp +++ b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderSndCurve.cpp @@ -73,7 +73,7 @@ bool AssetLoaderSndCurve::LoadFromRaw( } } - manager->AddAsset(ASSET_TYPE_SOUND_CURVE, assetName, sndCurve); + manager->AddAsset(assetName, sndCurve); return true; } diff --git a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderStringTable.cpp b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderStringTable.cpp index e7335004..08121661 100644 --- a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderStringTable.cpp +++ b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderStringTable.cpp @@ -34,7 +34,7 @@ bool AssetLoaderStringTable::LoadFromRaw( string_table::StringTableLoaderV2 loader; auto* stringTable = loader.LoadFromStream(assetName, *memory, *file.m_stream); - manager->AddAsset(ASSET_TYPE_STRINGTABLE, assetName, stringTable); + manager->AddAsset(assetName, stringTable); return true; } diff --git a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderStructuredDataDefSet.cpp b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderStructuredDataDefSet.cpp index 36068ca8..ee5c8183 100644 --- a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderStructuredDataDefSet.cpp +++ b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderStructuredDataDefSet.cpp @@ -214,7 +214,7 @@ bool AssetLoaderStructuredDataDefSet::LoadFromRaw( const auto defs = reader.ReadStructureDataDefs(readingDefsSuccessful); if (readingDefsSuccessful) - manager->AddAsset(ASSET_TYPE_STRUCTURED_DATA_DEF, assetName, ConvertSet(assetName, defs, memory)); + manager->AddAsset(assetName, ConvertSet(assetName, defs, memory)); return true; } diff --git a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderTechniqueSet.cpp b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderTechniqueSet.cpp index e51a7a3b..c7b330ec 100644 --- a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderTechniqueSet.cpp +++ b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderTechniqueSet.cpp @@ -1329,7 +1329,7 @@ bool AssetLoaderTechniqueSet::CreateTechsetFromDefinition( } } - manager->AddAsset(ASSET_TYPE_TECHNIQUE_SET, assetName, techset, std::vector(dependencies.begin(), dependencies.end()), std::vector()); + manager->AddAsset(assetName, techset, std::vector(dependencies.begin(), dependencies.end())); return true; } diff --git a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderVertexDecl.cpp b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderVertexDecl.cpp index 65fff5cb..8f616e49 100644 --- a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderVertexDecl.cpp +++ b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderVertexDecl.cpp @@ -96,6 +96,6 @@ bool AssetLoaderVertexDecl::LoadFromRaw( auto* allocatedDecl = memory->Create(decl); - manager->AddAsset(ASSET_TYPE_VERTEXDECL, assetName, allocatedDecl); + manager->AddAsset(assetName, allocatedDecl); return true; } diff --git a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderVertexShader.cpp b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderVertexShader.cpp index 94f22f90..07df2b0a 100644 --- a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderVertexShader.cpp +++ b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderVertexShader.cpp @@ -57,7 +57,7 @@ bool AssetLoaderVertexShader::LoadFromRaw( return false; vertexShader->prog.loadDef.program = fileBuffer; - manager->AddAsset(ASSET_TYPE_VERTEXSHADER, assetName, vertexShader); + manager->AddAsset(assetName, vertexShader); return true; } diff --git a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderWeapon.cpp b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderWeapon.cpp index c7221d1d..eb74d699 100644 --- a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderWeapon.cpp +++ b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderWeapon.cpp @@ -387,12 +387,8 @@ namespace CalculateWeaponFields(weaponFullDef, memory); - manager->AddAsset(ASSET_TYPE_WEAPON, - assetName, - &weaponFullDef->weapCompleteDef, - converter.GetDependencies(), - converter.GetUsedScriptStrings(), - converter.GetIndirectAssetReferences()); + manager->AddAsset( + assetName, &weaponFullDef->weapCompleteDef, converter.GetDependencies(), converter.GetUsedScriptStrings(), converter.GetIndirectAssetReferences()); return true; } diff --git a/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderLocalizeEntry.cpp b/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderLocalizeEntry.cpp index ac6d39e1..94f9a42e 100644 --- a/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderLocalizeEntry.cpp +++ b/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderLocalizeEntry.cpp @@ -29,7 +29,7 @@ bool AssetLoaderLocalizeEntry::LoadFromRaw( localizeEntry->name = memory->Dup(entry.m_key.c_str()); localizeEntry->value = memory->Dup(entry.m_value.c_str()); - manager->AddAsset(ASSET_TYPE_LOCALIZE_ENTRY, entry.m_key, localizeEntry); + manager->AddAsset(entry.m_key, localizeEntry); }); return commonLoader.LoadLocalizeAsset(assetName, searchPath, manager, zone); diff --git a/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderMenuList.cpp b/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderMenuList.cpp index 62071db0..8a0ba21e 100644 --- a/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderMenuList.cpp +++ b/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderMenuList.cpp @@ -57,12 +57,11 @@ namespace IW5 } menus.push_back(menuAsset); - auto* menuAssetInfo = - manager->AddAsset(ASSET_TYPE_MENU, menu->m_name, menuAsset, std::move(converter.GetDependencies()), std::vector()); + auto* menuAssetInfo = manager->AddAsset(menu->m_name, menuAsset, std::move(converter.GetDependencies())); if (menuAssetInfo) { - allMenusOfFile.push_back(reinterpret_cast*>(menuAssetInfo)); + allMenusOfFile.push_back(menuAssetInfo); menuListDependencies.push_back(menuAssetInfo); } @@ -223,7 +222,7 @@ bool AssetLoaderMenuList::LoadFromRaw( auto* menuListAsset = MenuLoader::CreateMenuListAsset(assetName, memory, menus); if (menuListAsset) - manager->AddAsset(ASSET_TYPE_MENULIST, assetName, menuListAsset, menuListDependencies, std::vector()); + manager->AddAsset(assetName, menuListAsset, menuListDependencies); return true; } diff --git a/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderRawFile.cpp b/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderRawFile.cpp index d29eb61c..b1a9a0a7 100644 --- a/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderRawFile.cpp +++ b/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderRawFile.cpp @@ -74,7 +74,7 @@ bool AssetLoaderRawFile::LoadFromRaw( deflateEnd(&zs); - manager->AddAsset(ASSET_TYPE_RAWFILE, assetName, rawFile); + manager->AddAsset(assetName, rawFile); return true; } diff --git a/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderScriptFile.cpp b/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderScriptFile.cpp index c1e84af7..84d4a8bb 100644 --- a/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderScriptFile.cpp +++ b/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderScriptFile.cpp @@ -72,7 +72,7 @@ bool AssetLoaderScriptFile::LoadFromRaw( scriptFile->bytecode = memory->Alloc(scriptFile->bytecodeLen); memcpy(scriptFile->bytecode, fileBuffer.get() + offset, scriptFile->bytecodeLen); - manager->AddAsset(ASSET_TYPE_SCRIPTFILE, assetName, scriptFile); + manager->AddAsset(assetName, scriptFile); return true; } diff --git a/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderStringTable.cpp b/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderStringTable.cpp index ece65461..c91eceb9 100644 --- a/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderStringTable.cpp +++ b/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderStringTable.cpp @@ -34,7 +34,7 @@ bool AssetLoaderStringTable::LoadFromRaw( string_table::StringTableLoaderV2 loader; auto* stringTable = loader.LoadFromStream(assetName, *memory, *file.m_stream); - manager->AddAsset(ASSET_TYPE_STRINGTABLE, assetName, stringTable); + manager->AddAsset(assetName, stringTable); return true; } diff --git a/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderWeapon.cpp b/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderWeapon.cpp index c81441a0..06e73bf3 100644 --- a/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderWeapon.cpp +++ b/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderWeapon.cpp @@ -817,12 +817,8 @@ namespace CalculateWeaponFields(weaponFullDef, memory); - manager->AddAsset(ASSET_TYPE_WEAPON, - assetName, - &weaponFullDef->weapCompleteDef, - converter.GetDependencies(), - converter.GetUsedScriptStrings(), - converter.GetIndirectAssetReferences()); + manager->AddAsset( + assetName, &weaponFullDef->weapCompleteDef, converter.GetDependencies(), converter.GetUsedScriptStrings(), converter.GetIndirectAssetReferences()); return true; } diff --git a/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderWeaponAttachment.cpp b/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderWeaponAttachment.cpp index 8545be21..0d04b56d 100644 --- a/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderWeaponAttachment.cpp +++ b/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderWeaponAttachment.cpp @@ -37,8 +37,7 @@ bool AssetLoaderWeaponAttachment::LoadFromRaw( std::vector dependencies; std::vector indirectAssetReferences; if (LoadWeaponAttachmentAsJson(*file.m_stream, *attachment, memory, manager, dependencies, indirectAssetReferences)) - manager->AddAsset( - ASSET_TYPE_ATTACHMENT, assetName, attachment, std::move(dependencies), std::vector(), std::move(indirectAssetReferences)); + manager->AddAsset(assetName, attachment, std::move(dependencies), std::vector(), std::move(indirectAssetReferences)); else std::cerr << "Failed to load attachment \"" << assetName << "\"\n"; diff --git a/src/ObjLoading/Game/IW5/Weapon/JsonWeaponAttachmentLoader.cpp b/src/ObjLoading/Game/IW5/Weapon/JsonWeaponAttachmentLoader.cpp index ab35dff4..5957ba83 100644 --- a/src/ObjLoading/Game/IW5/Weapon/JsonWeaponAttachmentLoader.cpp +++ b/src/ObjLoading/Game/IW5/Weapon/JsonWeaponAttachmentLoader.cpp @@ -120,7 +120,7 @@ namespace bool CreateTracerFromJson(const std::string& assetName, TracerDef*& tracerPtr, const WeaponAttachment& attachment) const { - auto* tracer = static_cast*>(m_manager.LoadDependency(ASSET_TYPE_TRACER, assetName)); + auto* tracer = m_manager.LoadDependency(assetName); if (!tracer) { PrintError(attachment, std::format("Could not find tracer {}", assetName)); @@ -134,7 +134,7 @@ namespace bool CreateMaterialFromJson(const std::string& assetName, Material*& materialPtr, const WeaponAttachment& attachment) const { - auto* material = static_cast*>(m_manager.LoadDependency(ASSET_TYPE_MATERIAL, assetName)); + auto* material = m_manager.LoadDependency(assetName); if (!material) { PrintError(attachment, std::format("Could not find material {}", assetName)); @@ -148,7 +148,7 @@ namespace bool CreateFxFromJson(const std::string& assetName, FxEffectDef*& fxPtr, const WeaponAttachment& attachment) const { - auto* fx = static_cast*>(m_manager.LoadDependency(ASSET_TYPE_FX, assetName)); + auto* fx = m_manager.LoadDependency(assetName); if (!fx) { PrintError(attachment, std::format("Could not find fx {}", assetName)); @@ -162,7 +162,7 @@ namespace bool CreateSoundFromJson(const std::string& assetName, SndAliasCustom& sndAliasCustom, const WeaponAttachment& attachment) const { - auto sound = m_manager.LoadIndirectAssetReference(ASSET_TYPE_SOUND, assetName); + auto sound = m_manager.LoadIndirectAssetReference(assetName); m_indirect_asset_references.push_back(std::move(sound)); sndAliasCustom.name = m_memory.Alloc(); sndAliasCustom.name->soundName = m_memory.Dup(assetName.c_str()); @@ -172,7 +172,7 @@ namespace bool CreateXModelFromJson(const std::string& assetName, XModel*& xmodelPtr, const WeaponAttachment& attachment) const { - auto* xmodel = static_cast*>(m_manager.LoadDependency(ASSET_TYPE_XMODEL, assetName)); + auto* xmodel = m_manager.LoadDependency(assetName); if (!xmodel) { PrintError(attachment, std::format("Could not find xmodel {}", assetName)); diff --git a/src/ObjLoading/Game/T5/AssetLoaders/AssetLoaderLocalizeEntry.cpp b/src/ObjLoading/Game/T5/AssetLoaders/AssetLoaderLocalizeEntry.cpp index 091d217f..720af58a 100644 --- a/src/ObjLoading/Game/T5/AssetLoaders/AssetLoaderLocalizeEntry.cpp +++ b/src/ObjLoading/Game/T5/AssetLoaders/AssetLoaderLocalizeEntry.cpp @@ -29,7 +29,7 @@ bool AssetLoaderLocalizeEntry::LoadFromRaw( localizeEntry->name = memory->Dup(entry.m_key.c_str()); localizeEntry->value = memory->Dup(entry.m_value.c_str()); - manager->AddAsset(ASSET_TYPE_LOCALIZE_ENTRY, entry.m_key, localizeEntry); + manager->AddAsset(entry.m_key, localizeEntry); }); return commonLoader.LoadLocalizeAsset(assetName, searchPath, manager, zone); diff --git a/src/ObjLoading/Game/T5/AssetLoaders/AssetLoaderRawFile.cpp b/src/ObjLoading/Game/T5/AssetLoaders/AssetLoaderRawFile.cpp index 682aca7e..53a5ae1a 100644 --- a/src/ObjLoading/Game/T5/AssetLoaders/AssetLoaderRawFile.cpp +++ b/src/ObjLoading/Game/T5/AssetLoaders/AssetLoaderRawFile.cpp @@ -75,7 +75,7 @@ bool AssetLoaderRawFile::LoadGsc( deflateEnd(&zs); - manager->AddAsset(ASSET_TYPE_RAWFILE, assetName, rawFile); + manager->AddAsset(assetName, rawFile); return true; } @@ -94,7 +94,7 @@ bool AssetLoaderRawFile::LoadDefault( fileBuffer[rawFile->len] = '\0'; rawFile->buffer = fileBuffer; - manager->AddAsset(ASSET_TYPE_RAWFILE, assetName, rawFile); + manager->AddAsset(assetName, rawFile); return true; } diff --git a/src/ObjLoading/Game/T5/AssetLoaders/AssetLoaderStringTable.cpp b/src/ObjLoading/Game/T5/AssetLoaders/AssetLoaderStringTable.cpp index d8785dc7..3d06701e 100644 --- a/src/ObjLoading/Game/T5/AssetLoaders/AssetLoaderStringTable.cpp +++ b/src/ObjLoading/Game/T5/AssetLoaders/AssetLoaderStringTable.cpp @@ -33,7 +33,7 @@ bool AssetLoaderStringTable::LoadFromRaw( string_table::StringTableLoaderV3 loader; auto* stringTable = loader.LoadFromStream(assetName, *memory, *file.m_stream); - manager->AddAsset(ASSET_TYPE_STRINGTABLE, assetName, stringTable); + manager->AddAsset(assetName, stringTable); return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderFontIcon.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderFontIcon.cpp index b89b4f8c..b355051f 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderFontIcon.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderFontIcon.cpp @@ -265,7 +265,7 @@ bool AssetLoaderFontIcon::LoadFromRaw( else fontIcon->fontIconAlias = nullptr; - manager->AddAsset(ASSET_TYPE_FONTICON, assetName, fontIcon); + manager->AddAsset(assetName, fontIcon); return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderGfxImage.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderGfxImage.cpp index 832a10a9..746da931 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderGfxImage.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderGfxImage.cpp @@ -66,7 +66,7 @@ bool AssetLoaderGfxImage::LoadFromRaw( image->streamedParts[0].hash = dataHash & 0x1FFFFFFF; image->streamedPartCount = 1; - manager->AddAsset(ASSET_TYPE_IMAGE, assetName, image); + manager->AddAsset(assetName, image); return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderLocalizeEntry.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderLocalizeEntry.cpp index 6dbb3bab..b90d5eb7 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderLocalizeEntry.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderLocalizeEntry.cpp @@ -29,7 +29,7 @@ bool AssetLoaderLocalizeEntry::LoadFromRaw( localizeEntry->name = memory->Dup(entry.m_key.c_str()); localizeEntry->value = memory->Dup(entry.m_value.c_str()); - manager->AddAsset(ASSET_TYPE_LOCALIZE_ENTRY, entry.m_key, localizeEntry); + manager->AddAsset(entry.m_key, localizeEntry); }); return commonLoader.LoadLocalizeAsset(assetName, searchPath, manager, zone); diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderMaterial.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderMaterial.cpp index 1297825f..85e44d9f 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderMaterial.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderMaterial.cpp @@ -51,7 +51,7 @@ bool AssetLoaderMaterial::LoadFromRaw( std::vector dependencies; if (LoadMaterialAsJson(*file.m_stream, *material, memory, manager, dependencies)) - manager->AddAsset(ASSET_TYPE_MATERIAL, assetName, material, std::move(dependencies)); + manager->AddAsset(assetName, material, std::move(dependencies)); else std::cerr << "Failed to load material \"" << assetName << "\"\n"; diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderPhysConstraints.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderPhysConstraints.cpp index ea413091..6dc86ede 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderPhysConstraints.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderPhysConstraints.cpp @@ -95,7 +95,7 @@ bool AssetLoaderPhysConstraints::LoadFromInfoString( auto scrStrings = converter.GetUsedScriptStrings(); scrStrings.push_back(zone->m_script_strings.AddOrGetScriptString("")); - manager->AddAsset(ASSET_TYPE_PHYSCONSTRAINTS, assetName, physConstraints, converter.GetDependencies(), scrStrings); + manager->AddAsset(assetName, physConstraints, converter.GetDependencies(), scrStrings); return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderPhysPreset.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderPhysPreset.cpp index bcf315a1..4542953b 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderPhysPreset.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderPhysPreset.cpp @@ -78,7 +78,7 @@ bool AssetLoaderPhysPreset::LoadFromInfoString( CopyFromPhysPresetInfo(presetInfo.get(), physPreset); physPreset->name = memory->Dup(assetName.c_str()); - manager->AddAsset(ASSET_TYPE_PHYSPRESET, assetName, physPreset, converter.GetDependencies(), converter.GetUsedScriptStrings()); + manager->AddAsset(assetName, physPreset, converter.GetDependencies(), converter.GetUsedScriptStrings()); return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderQdb.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderQdb.cpp index ca06111c..4366f1d5 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderQdb.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderQdb.cpp @@ -37,7 +37,7 @@ bool AssetLoaderQdb::LoadFromRaw(const std::string& assetName, ISearchPath* sear fileBuffer[qdb->len] = '\0'; qdb->buffer = static_cast(fileBuffer); - manager->AddAsset(ASSET_TYPE_QDB, assetName, qdb); + manager->AddAsset(assetName, qdb); return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderRawFile.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderRawFile.cpp index 7e71a2d5..6e652691 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderRawFile.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderRawFile.cpp @@ -74,7 +74,7 @@ bool AssetLoaderRawFile::LoadAnimtree( deflateEnd(&zs); - manager->AddAsset(ASSET_TYPE_RAWFILE, assetName, rawFile); + manager->AddAsset(assetName, rawFile); return true; } @@ -93,7 +93,7 @@ bool AssetLoaderRawFile::LoadDefault( fileBuffer[rawFile->len] = '\0'; rawFile->buffer = static_cast(fileBuffer); - manager->AddAsset(ASSET_TYPE_RAWFILE, assetName, rawFile); + manager->AddAsset(assetName, rawFile); return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderScriptParseTree.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderScriptParseTree.cpp index f82218b4..822567c6 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderScriptParseTree.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderScriptParseTree.cpp @@ -38,7 +38,7 @@ bool AssetLoaderScriptParseTree::LoadFromRaw( fileBuffer[scriptParseTree->len] = '\0'; scriptParseTree->buffer = static_cast(fileBuffer); - manager->AddAsset(ASSET_TYPE_SCRIPTPARSETREE, assetName, scriptParseTree); + manager->AddAsset(assetName, scriptParseTree); return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSlug.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSlug.cpp index 263ab4b0..5a6dac42 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSlug.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSlug.cpp @@ -37,7 +37,7 @@ bool AssetLoaderSlug::LoadFromRaw(const std::string& assetName, ISearchPath* sea fileBuffer[slug->len] = '\0'; slug->buffer = static_cast(fileBuffer); - manager->AddAsset(ASSET_TYPE_SLUG, assetName, slug); + manager->AddAsset(assetName, slug); return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp index dd7c3074..ad5c4cc8 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp @@ -569,6 +569,6 @@ bool AssetLoaderSoundBank::LoadFromRaw( } } - manager->AddAsset(ASSET_TYPE_SOUND, assetName, sndBank); + manager->AddAsset(assetName, sndBank); return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderStringTable.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderStringTable.cpp index e77cc4bb..5c4283f8 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderStringTable.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderStringTable.cpp @@ -33,7 +33,7 @@ bool AssetLoaderStringTable::LoadFromRaw( string_table::StringTableLoaderV3 loader; auto* stringTable = loader.LoadFromStream(assetName, *memory, *file.m_stream); - manager->AddAsset(ASSET_TYPE_STRINGTABLE, assetName, stringTable); + manager->AddAsset(assetName, stringTable); return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderTracer.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderTracer.cpp index 96784923..90d21cf2 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderTracer.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderTracer.cpp @@ -61,7 +61,7 @@ bool AssetLoaderTracer::LoadFromInfoString( tracer->name = memory->Dup(assetName.c_str()); - manager->AddAsset(ASSET_TYPE_TRACER, assetName, tracer, converter.GetDependencies(), converter.GetUsedScriptStrings()); + manager->AddAsset(assetName, tracer, converter.GetDependencies(), converter.GetUsedScriptStrings()); return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderVehicle.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderVehicle.cpp index 9717b9da..3b935a5c 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderVehicle.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderVehicle.cpp @@ -124,7 +124,7 @@ bool AssetLoaderVehicle::LoadFromInfoString( vehicleDef->name = memory->Dup(assetName.c_str()); - manager->AddAsset(ASSET_TYPE_VEHICLEDEF, assetName, vehicleDef, converter.GetDependencies(), converter.GetUsedScriptStrings()); + manager->AddAsset(assetName, vehicleDef, converter.GetDependencies(), converter.GetUsedScriptStrings()); return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeapon.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeapon.cpp index 96f21e6f..6228858a 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeapon.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeapon.cpp @@ -567,12 +567,8 @@ bool AssetLoaderWeapon::LoadFromInfoString( CalculateWeaponFields(weaponFullDef); CalculateAttachmentFields(weaponFullDef); - manager->AddAsset(ASSET_TYPE_WEAPON, - assetName, - &weaponFullDef->weapVariantDef, - converter.GetDependencies(), - converter.GetUsedScriptStrings(), - converter.GetIndirectAssetReferences()); + manager->AddAsset( + assetName, &weaponFullDef->weapVariantDef, converter.GetDependencies(), converter.GetUsedScriptStrings(), converter.GetIndirectAssetReferences()); return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponAttachment.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponAttachment.cpp index 5ed03211..8f748a0f 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponAttachment.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponAttachment.cpp @@ -112,8 +112,8 @@ bool AssetLoaderWeaponAttachment::LoadFromInfoString( CalculateAttachmentFields(attachment); attachment->szInternalName = memory->Dup(assetName.c_str()); - manager->AddAsset( - ASSET_TYPE_ATTACHMENT, assetName, attachment, converter.GetDependencies(), converter.GetUsedScriptStrings(), converter.GetIndirectAssetReferences()); + manager->AddAsset( + assetName, attachment, converter.GetDependencies(), converter.GetUsedScriptStrings(), converter.GetIndirectAssetReferences()); return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponAttachmentUnique.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponAttachmentUnique.cpp index 1e3cd64a..86ff51fa 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponAttachmentUnique.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponAttachmentUnique.cpp @@ -231,12 +231,8 @@ bool AssetLoaderWeaponAttachmentUnique::LoadFromInfoString( attachmentUniqueFull->attachment.szInternalName = memory->Dup(assetName.c_str()); - manager->AddAsset(ASSET_TYPE_ATTACHMENT_UNIQUE, - assetName, - &attachmentUniqueFull->attachment, - converter.GetDependencies(), - converter.GetUsedScriptStrings(), - converter.GetIndirectAssetReferences()); + manager->AddAsset( + assetName, &attachmentUniqueFull->attachment, converter.GetDependencies(), converter.GetUsedScriptStrings(), converter.GetIndirectAssetReferences()); return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponCamo.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponCamo.cpp index bec480f8..ac964eb0 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponCamo.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponCamo.cpp @@ -37,7 +37,7 @@ bool AssetLoaderWeaponCamo::LoadFromRaw( std::vector dependencies; if (LoadWeaponCamoAsJson(*file.m_stream, *weaponCamo, memory, manager, dependencies)) - manager->AddAsset(ASSET_TYPE_WEAPON_CAMO, assetName, weaponCamo, std::move(dependencies)); + manager->AddAsset(assetName, weaponCamo, std::move(dependencies)); else std::cerr << "Failed to load weapon camo \"" << assetName << "\"\n"; diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderZBarrier.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderZBarrier.cpp index 5da0f3b3..b8421ae5 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderZBarrier.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderZBarrier.cpp @@ -74,7 +74,7 @@ bool AssetLoaderZBarrier::LoadFromInfoString( CalculateZBarrierFields(zbarrier); zbarrier->name = memory->Dup(assetName.c_str()); - manager->AddAsset(ASSET_TYPE_ZBARRIER, assetName, zbarrier, converter.GetDependencies(), converter.GetUsedScriptStrings()); + manager->AddAsset(assetName, zbarrier, converter.GetDependencies(), converter.GetUsedScriptStrings()); return true; }