[IMaterial] Correct loading order
This commit is contained in:
parent
e909329910
commit
cb4f4a8321
@ -6,15 +6,17 @@ namespace Assets
|
|||||||
{
|
{
|
||||||
void IMaterial::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
|
void IMaterial::load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
|
||||||
{
|
{
|
||||||
Components::FileSystem::File materialFile(fmt::sprintf("materials/%s.iw4xMaterial", name.data()));
|
if (!header->data) this->loadJson(header, name, builder); // Check if we want to override materials
|
||||||
if(!materialFile.exists())
|
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
|
||||||
this->loadJson(header, name, builder);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::Material* material = builder->getAllocator()->allocate<Game::Material>();
|
void IMaterial::loadBinary(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
|
||||||
|
{
|
||||||
|
Components::FileSystem::File materialFile(fmt::sprintf("materials/%s.iw4xMaterial", name.data()));
|
||||||
|
if (!materialFile.exists()) return;
|
||||||
|
|
||||||
|
Game::Material* material = builder->getAllocator()->allocate<Game::Material>();
|
||||||
if (!material)
|
if (!material)
|
||||||
{
|
{
|
||||||
Components::Logger::Print("Error allocating memory for material structure!\n");
|
Components::Logger::Print("Error allocating memory for material structure!\n");
|
||||||
@ -130,6 +132,11 @@ namespace Assets
|
|||||||
}, material, false);
|
}, material, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IMaterial::loadNative(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
|
||||||
|
{
|
||||||
|
header->material = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).material;
|
||||||
|
}
|
||||||
|
|
||||||
void IMaterial::loadJson(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
|
void IMaterial::loadJson(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
|
||||||
{
|
{
|
||||||
Components::FileSystem::File materialInfo(fmt::sprintf("materials/%s.json", name.data()));
|
Components::FileSystem::File materialInfo(fmt::sprintf("materials/%s.json", name.data()));
|
||||||
|
@ -9,5 +9,7 @@ namespace Assets
|
|||||||
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
|
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
|
||||||
virtual void load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) override;
|
virtual void load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) override;
|
||||||
void loadJson(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder);
|
void loadJson(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder);
|
||||||
|
void loadNative(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder);
|
||||||
|
void loadBinary(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user