From 7cf8f14f49a48fc0f5207010d64eb76c22197695 Mon Sep 17 00:00:00 2001 From: Louve <33836535+Rackover@users.noreply.github.com> Date: Wed, 22 Feb 2023 10:03:35 +0100 Subject: [PATCH] Fix snd/sndcurve not using original assets as fallback, bump IW4Of (#791) --- deps/iw4-open-formats | 2 +- src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp | 2 ++ .../Modules/AssetInterfaces/IMaterialTechniqueSet.cpp | 5 ++++- src/Components/Modules/AssetInterfaces/ISndCurve.cpp | 5 +++++ src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.cpp | 5 +++++ src/Components/Modules/ZoneBuilder.cpp | 4 +++- 6 files changed, 20 insertions(+), 3 deletions(-) diff --git a/deps/iw4-open-formats b/deps/iw4-open-formats index f25d31a8..c517856c 160000 --- a/deps/iw4-open-formats +++ b/deps/iw4-open-formats @@ -1 +1 @@ -Subproject commit f25d31a8946a259d96cbed2e0e432e649f3d24cf +Subproject commit c517856ce3db12557cf77bf53e27d7a411f03e12 diff --git a/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp b/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp index 978934b6..0d366ce2 100644 --- a/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp +++ b/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp @@ -8,6 +8,8 @@ namespace Assets if (!header->data) this->loadEfx(header, name, builder); // Check if we have an editor fx if (!header->data) this->loadFromIW4OF(header, name, builder); // Check if we need to import a new one into the game if (!header->data /*&& !builder->isPrimaryAsset()*/) this->loadNative(header, name, builder); // Check if there is a native one + + assert(header->data); } void IFxEffectDef::loadFxElemVisuals(Game::FxElemVisuals* visuals, char elemType, Components::ZoneBuilder::Zone* builder, Utils::Stream::Reader* reader) diff --git a/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.cpp b/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.cpp index cb2fe8b0..c0e81d06 100644 --- a/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.cpp +++ b/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.cpp @@ -12,7 +12,10 @@ namespace Assets if (!header->data) this->loadFromDisk(header, name, builder); // Check if we need to import a new one into the game if (!header->data) this->loadNative(header, name, builder); // Check if there is a native one - assert(header->data); + if (!header->data) + { + AssertUnreachable; + } } void IMaterialTechniqueSet::loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/) diff --git a/src/Components/Modules/AssetInterfaces/ISndCurve.cpp b/src/Components/Modules/AssetInterfaces/ISndCurve.cpp index a4228e67..a3a7a496 100644 --- a/src/Components/Modules/AssetInterfaces/ISndCurve.cpp +++ b/src/Components/Modules/AssetInterfaces/ISndCurve.cpp @@ -26,5 +26,10 @@ namespace Assets void ISndCurve::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) { header->sndCurve = builder->getIW4OfApi()->read(Game::XAssetType::ASSET_TYPE_SOUND_CURVE, name); + + if (!header->sndCurve) + { + header->sndCurve = Components::AssetHandler::FindOriginalAsset(Game::XAssetType::ASSET_TYPE_SOUND_CURVE, name.data()).sndCurve; + } } } diff --git a/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.cpp b/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.cpp index 9d321160..76b21b2b 100644 --- a/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.cpp +++ b/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.cpp @@ -8,6 +8,11 @@ namespace Assets void Isnd_alias_list_t::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) { header->sound = builder->getIW4OfApi()->read(Game::XAssetType::ASSET_TYPE_SOUND, name); + + if (!header->sound) + { + header->sound = Components::AssetHandler::FindOriginalAsset(Game::XAssetType::ASSET_TYPE_SOUND_CURVE, name.data()).sound; + } } void Isnd_alias_list_t::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) diff --git a/src/Components/Modules/ZoneBuilder.cpp b/src/Components/Modules/ZoneBuilder.cpp index 6d07155f..5e4f7386 100644 --- a/src/Components/Modules/ZoneBuilder.cpp +++ b/src/Components/Modules/ZoneBuilder.cpp @@ -761,7 +761,9 @@ namespace Components iw4of::params_t ZoneBuilder::Zone::getIW4OfApiParams() { - iw4of::params_t params; + iw4of::params_t params{}; + + params.write_only_once = true; params.find_other_asset = [this](int type, const std::string& name) -> void* {