[ZoneBuilder] Load native XModels when not explicitly specified in the csv

aka 'primary asset'
This commit is contained in:
momo5502 2017-06-05 21:03:04 +02:00
parent 001939166b
commit e1c85f81d6
5 changed files with 37 additions and 6 deletions

View File

@ -332,6 +332,8 @@ namespace Components
Game::XAssetHeader AssetHandler::FindAssetForZone(Game::XAssetType type, std::string filename, ZoneBuilder::Zone* builder, bool isSubAsset) Game::XAssetHeader AssetHandler::FindAssetForZone(Game::XAssetType type, std::string filename, ZoneBuilder::Zone* builder, bool isSubAsset)
{ {
ZoneBuilder::Zone::AssetRecursionMarker _(builder);
Game::XAssetHeader header = { nullptr }; Game::XAssetHeader header = { nullptr };
if (type >= Game::XAssetType::ASSET_TYPE_COUNT) return header; if (type >= Game::XAssetType::ASSET_TYPE_COUNT) return header;

View File

@ -7,7 +7,7 @@ namespace Assets
void IFxEffectDef::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) 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->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 /*&& !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 if (!header->data) this->loadBinary(header, name, builder); // Check if we need to import a new one into the game
} }

View File

@ -74,6 +74,12 @@ namespace Assets
void IXModel::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) 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())); Components::FileSystem::File modelFile(Utils::String::VA("xmodel/%s.iw4xModel", name.data()));
if (modelFile.exists()) if (modelFile.exists())

View File

@ -18,11 +18,11 @@ namespace Components
// Side note: if you need a fastfile larger than 100MB, you're doing it wrong- // 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. // Well, decompressed maps can get way larger than 100MB, so let's increase that.
buffer(0xC800000), 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), ZoneBuilder::Zone::Zone() : indexStart(0), externalSize(0), buffer(0xC800000), zoneName("null_zone"),
zoneName("null_zone"), dataMap(), branding{ nullptr } dataMap(), branding{ nullptr }, assetDepth(0)
{} {}
ZoneBuilder::Zone::~Zone() ZoneBuilder::Zone::~Zone()

View File

@ -14,6 +14,23 @@ namespace Components
class Zone class Zone
{ {
public: public:
class AssetRecursionMarker
{
public:
AssetRecursionMarker(Zone* _builder) : builder(_builder)
{
this->builder->increaseAssetDepth();
}
~AssetRecursionMarker()
{
this->builder->decreaseAssetDepth();
}
private:
Zone* builder;
};
Zone(std::string zoneName); Zone(std::string zoneName);
Zone(); Zone();
~Zone(); ~Zone();
@ -52,6 +69,10 @@ namespace Components
void incrementExternalSize(unsigned int size); void incrementExternalSize(unsigned int size);
void increaseAssetDepth() { ++this->assetDepth; }
void decreaseAssetDepth() { --this->assetDepth; }
bool isPrimaryAsset() { return this->assetDepth <= 1; }
private: private:
void loadFastFiles(); void loadFastFiles();
@ -89,6 +110,8 @@ namespace Components
std::vector<std::pair<Game::XAsset, uint32_t>> aliasList; std::vector<std::pair<Game::XAsset, uint32_t>> aliasList;
Game::RawFile branding; Game::RawFile branding;
size_t assetDepth;
}; };
ZoneBuilder(); ZoneBuilder();