From 27e9a22e43f3482dc360dad0819e661fa3b42ec0 Mon Sep 17 00:00:00 2001 From: Louvenarde Date: Mon, 6 Sep 2021 00:20:16 +0200 Subject: [PATCH] Allow loading assets from disk even if they're already in memory --- src/Components/Modules/AssetInterfaces/IXModel.cpp | 5 +++-- src/Components/Modules/ZoneBuilder.cpp | 3 +++ src/Components/Modules/ZoneBuilder.hpp | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Components/Modules/AssetInterfaces/IXModel.cpp b/src/Components/Modules/AssetInterfaces/IXModel.cpp index cdcee206..39b49b6a 100644 --- a/src/Components/Modules/AssetInterfaces/IXModel.cpp +++ b/src/Components/Modules/AssetInterfaces/IXModel.cpp @@ -84,13 +84,14 @@ namespace Assets void IXModel::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) { - if (!builder->isPrimaryAsset()) + Components::FileSystem::File modelFile(Utils::String::VA("xmodel/%s.iw4xModel", name.data())); + + if (!builder->isPrimaryAsset() && (Components::ZoneBuilder::MatchTechsetsDvar.get() || !modelFile.exists())) { header->model = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).model; if (header->model) return; } - Components::FileSystem::File modelFile(Utils::String::VA("xmodel/%s.iw4xModel", name.data())); if (modelFile.exists()) { diff --git a/src/Components/Modules/ZoneBuilder.cpp b/src/Components/Modules/ZoneBuilder.cpp index be9004f5..58c70572 100644 --- a/src/Components/Modules/ZoneBuilder.cpp +++ b/src/Components/Modules/ZoneBuilder.cpp @@ -10,6 +10,9 @@ namespace Components bool ZoneBuilder::Terminate; std::thread ZoneBuilder::CommandThread; + Dvar::Var ZoneBuilder::MatchTechsetsDvar; + Dvar::Var ZoneBuilder::PreferDiskAssetsDvar; + ZoneBuilder::Zone::Zone(const std::string& name) : indexStart(0), externalSize(0), // Reserve 100MB by default. diff --git a/src/Components/Modules/ZoneBuilder.hpp b/src/Components/Modules/ZoneBuilder.hpp index 8b0c12f0..5c647816 100644 --- a/src/Components/Modules/ZoneBuilder.hpp +++ b/src/Components/Modules/ZoneBuilder.hpp @@ -130,6 +130,7 @@ namespace Components static std::vector> EndAssetTrace(); static Game::XAssetHeader GetEmptyAssetIfCommon(Game::XAssetType type, const std::string& name, Zone* builder); + static Dvar::Var PreferDiskAssetsDvar; private: static int StoreTexture(Game::GfxImageLoadDef **loadDef, Game::GfxImage *image);