diff --git a/src/Components/Modules/AssetHandler.cpp b/src/Components/Modules/AssetHandler.cpp index 3331f733..469eb0d1 100644 --- a/src/Components/Modules/AssetHandler.cpp +++ b/src/Components/Modules/AssetHandler.cpp @@ -332,6 +332,8 @@ namespace Components Game::XAssetHeader AssetHandler::FindAssetForZone(Game::XAssetType type, std::string filename, ZoneBuilder::Zone* builder, bool isSubAsset) { + ZoneBuilder::Zone::AssetRecursionMarker _(builder); + Game::XAssetHeader header = { nullptr }; if (type >= Game::XAssetType::ASSET_TYPE_COUNT) return header; diff --git a/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp b/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp index 5dc04ae0..a303a021 100644 --- a/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp +++ b/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp @@ -6,9 +6,9 @@ namespace Assets { void IFxEffectDef::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) { - if (!header->data) this->loadEfx(header, name, builder); // Check if we have an editor fx - if (!header->data) this->loadNative(header, name, builder); // Check if there is a native one - if (!header->data) this->loadBinary(header, name, builder); // Check if we need to import a new one into the game + if (!header->data) this->loadEfx(header, name, builder); // Check if we have an editor fx + if (!header->data /*&& !builder->isPrimaryAsset()*/) this->loadNative(header, name, builder); // Check if there is a native one + if (!header->data) this->loadBinary(header, name, builder); // Check if we need to import a new one into the game } void IFxEffectDef::loadFxElemVisuals(Game::FxElemVisuals* visuals, char elemType, Components::ZoneBuilder::Zone* builder, Utils::Stream::Reader* reader) diff --git a/src/Components/Modules/AssetInterfaces/IXModel.cpp b/src/Components/Modules/AssetInterfaces/IXModel.cpp index 5623df12..0cbf0635 100644 --- a/src/Components/Modules/AssetInterfaces/IXModel.cpp +++ b/src/Components/Modules/AssetInterfaces/IXModel.cpp @@ -74,6 +74,12 @@ namespace Assets void IXModel::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) { + if(!builder->isPrimaryAsset()) + { + 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 0f5b390a..ab583818 100644 --- a/src/Components/Modules/ZoneBuilder.cpp +++ b/src/Components/Modules/ZoneBuilder.cpp @@ -18,11 +18,11 @@ namespace Components // Side note: if you need a fastfile larger than 100MB, you're doing it wrong- // Well, decompressed maps can get way larger than 100MB, so let's increase that. buffer(0xC800000), - zoneName(name), dataMap("zone_source/" + name + ".csv"), branding{ nullptr } + zoneName(name), dataMap("zone_source/" + name + ".csv"), branding{ nullptr }, assetDepth(0) {} - ZoneBuilder::Zone::Zone() : indexStart(0), externalSize(0), buffer(0xC800000), - zoneName("null_zone"), dataMap(), branding{ nullptr } + ZoneBuilder::Zone::Zone() : indexStart(0), externalSize(0), buffer(0xC800000), zoneName("null_zone"), + dataMap(), branding{ nullptr }, assetDepth(0) {} ZoneBuilder::Zone::~Zone() diff --git a/src/Components/Modules/ZoneBuilder.hpp b/src/Components/Modules/ZoneBuilder.hpp index cfded145..da5022a8 100644 --- a/src/Components/Modules/ZoneBuilder.hpp +++ b/src/Components/Modules/ZoneBuilder.hpp @@ -14,6 +14,23 @@ namespace Components class Zone { public: + class AssetRecursionMarker + { + public: + AssetRecursionMarker(Zone* _builder) : builder(_builder) + { + this->builder->increaseAssetDepth(); + } + + ~AssetRecursionMarker() + { + this->builder->decreaseAssetDepth(); + } + + private: + Zone* builder; + }; + Zone(std::string zoneName); Zone(); ~Zone(); @@ -52,6 +69,10 @@ namespace Components void incrementExternalSize(unsigned int size); + void increaseAssetDepth() { ++this->assetDepth; } + void decreaseAssetDepth() { --this->assetDepth; } + bool isPrimaryAsset() { return this->assetDepth <= 1; } + private: void loadFastFiles(); @@ -89,6 +110,8 @@ namespace Components std::vector> aliasList; Game::RawFile branding; + + size_t assetDepth; }; ZoneBuilder();