Cleanup & handle flag conversion in iw3xport

This commit is contained in:
rackover 2021-04-12 00:40:10 +02:00
parent eebc48ab7c
commit eebd0ae1da
2 changed files with 11 additions and 15 deletions

View File

@ -7,12 +7,13 @@ namespace Assets
void IFxEffectDef::load(Game::XAssetHeader* header, const 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 /*&& !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 /*&& !builder->isPrimaryAsset()*/) this->loadNative(header, name, builder); // Check if there is a native one
}
void IFxEffectDef::loadFxElemVisuals(Game::FxElemVisuals* visuals, char elemType, Components::ZoneBuilder::Zone* builder, Utils::Stream::Reader* reader)
{
switch (elemType)
{
case Game::FX_ELEM_TYPE_MODEL:
@ -34,10 +35,7 @@ namespace Assets
if (visuals->soundName)
{
visuals->soundName = reader->readCString();
visuals->soundName = "null";
Components::Logger::Print("Unable to load sounds yet!\n");
}
break;
}

View File

@ -298,22 +298,15 @@ namespace Assets
alias->volumeFalloffCurve = curve;
}
// Clear the flags from type
alias->flags &= ~(0b111 << 7);
if (type.number_value() == Game::snd_alias_type_t::SAT_LOADED) // Loaded
if (static_cast<Game::snd_alias_type_t>(type.number_value()) == Game::snd_alias_type_t::SAT_LOADED) // Loaded
{
alias->soundFile->type = Game::SAT_LOADED;
alias->soundFile->u.loadSnd = Components::AssetHandler::FindAssetForZone(Game::XAssetType::ASSET_TYPE_LOADED_SOUND, soundFile.string_value().c_str(), builder).loadSnd;
// Set the type
alias->flags |= (Game::SAT_LOADED & 0b111) << 7;
}
else if (type.number_value() == Game::snd_alias_type_t::SAT_STREAMED) // Streamed
else if (static_cast<Game::snd_alias_type_t>(type.number_value()) == Game::snd_alias_type_t::SAT_STREAMED) // Streamed
{
alias->soundFile->type = Game::SAT_STREAMED;
alias->flags |= (Game::SAT_STREAMED & 0b111) << 7;
std::string streamedFile = soundFile.string_value();
std::string directory = ""s;
int split = streamedFile.find_last_of('/');
@ -363,7 +356,12 @@ namespace Assets
if (alias->volumeFalloffCurve)
{
builder->loadAsset(Game::XAssetType::ASSET_TYPE_SOUND_CURVE, alias->volumeFalloffCurve);
if (!builder->loadAsset(Game::XAssetType::ASSET_TYPE_SOUND_CURVE, alias->volumeFalloffCurve))
{
// (Should never happen, but just in case)
alias->volumeFalloffCurve->filename = "$default";
builder->loadAsset(Game::XAssetType::ASSET_TYPE_SOUND_CURVE, alias->volumeFalloffCurve);
}
}
}
}