Merge pull request #967 from Azaezel/alpha41/audiopreloadFixes

standardize soundasset preloading for datablocks
This commit is contained in:
Brian Roberts 2023-02-20 22:15:50 -06:00 committed by GitHub
commit ae72247be2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 46 additions and 58 deletions

View file

@ -877,15 +877,10 @@ bool ExplosionData::preload(bool server, String &errorStr)
if( !server )
{
if (getSound() != StringTable->EmptyString())
if (getSound() != StringTable->EmptyString() && !isSoundValid())
{
_setSound(getSound());
if (!getSoundProfile())
{
Con::errorf(ConsoleLogEntry::General, "SplashData::preload: Cant get an sfxProfile for splash.");
return false;
}
Con::errorf(ConsoleLogEntry::General, "ExplosionData::preload: Invalid Sound asset.");
return false;
}
if (!particleEmitter && particleEmitterId != 0)

View file

@ -297,19 +297,17 @@ bool LightningData::preload(bool server, String &errorStr)
{
for (S32 i = 0; i < MaxThunders; i++)
{
_setThunderSound(getThunderSound(i), i);
if (isThunderSoundValid(i) && !getThunderSoundProfile(i))
if (getThunderSound(i) != StringTable->EmptyString() && !isThunderSoundValid(i))
{
Con::errorf(ConsoleLogEntry::General, "LightningData::preload: Cant get an sfxProfile for thunder.");
Con::errorf(ConsoleLogEntry::General, "LightningData::preload: Invalid ThunderSound asset.");
return false;
}
}
_setStrikeSound(getStrikeSound());
if (isStrikeSoundValid() && !getStrikeSoundProfile())
if (getStrikeSound() != StringTable->EmptyString() && !isStrikeSoundValid())
{
Con::errorf(ConsoleLogEntry::General, "LightningData::preload: can't get sfxProfile from strike sound.");
Con::errorf(ConsoleLogEntry::General, "LightningData::preload: Invalid StrikeSound asset.");
return false;
}
mNumStrikeTextures = 0;

View file

@ -191,12 +191,10 @@ bool PrecipitationData::preload( bool server, String &errorStr )
return false;
if (!server)
{
if (getSound() != StringTable->EmptyString())
if (getSound() != StringTable->EmptyString() && !isSoundValid())
{
_setSound(getSound());
if (!getSoundProfile())
Con::errorf(ConsoleLogEntry::General, "SplashData::preload: Cant get an sfxProfile for splash.");
Con::errorf(ConsoleLogEntry::General, "PrecipitationData::preload: Invalid Sound asset.");
return false;
}
}

View file

@ -279,13 +279,10 @@ bool SplashData::preload(bool server, String &errorStr)
if (!server)
{
if (getSound() != StringTable->EmptyString())
if (getSound() != StringTable->EmptyString() && !isSoundValid())
{
_setSound(getSound());
if(!getSoundProfile())
Con::errorf(ConsoleLogEntry::General, "SplashData::preload: Cant get an sfxProfile for splash.");
Con::errorf(ConsoleLogEntry::General, "SplashData::preload: Invalid Sound asset.");
return false;
}
S32 i;

View file

@ -471,11 +471,10 @@ bool PlayerData::preload(bool server, String &errorStr)
if (!server) {
for (U32 i = 0; i < MaxSounds; ++i)
{
_setPlayerSound(getPlayerSound(i), i);
if (getPlayerSound(i) != StringTable->EmptyString())
if (getPlayerSound(i) != StringTable->EmptyString() && !isPlayerSoundValid(i))
{
if (!getPlayerSoundProfile(i))
Con::errorf("PlayerData::Preload() - unable to find sfxProfile for asset %d %s", i, mPlayerSoundAssetId[i]);
Con::errorf(ConsoleLogEntry::General, "ExplosionData::preload: Invalid PlayerSound asset.");
return false;
}
}
}

View file

@ -368,11 +368,10 @@ bool ProjectileData::preload(bool server, String &errorStr)
if (Sim::findObject(decalId, decal) == false)
Con::errorf(ConsoleLogEntry::General, "ProjectileData::preload: Invalid packet, bad datablockId(decal): %d", decalId);
_setProjectileSound(getProjectileSound());
if (getProjectileSound() != StringTable->EmptyString())
if (getProjectileSound() != StringTable->EmptyString() && !isProjectileSoundValid())
{
if (!getProjectileSoundProfile())
Con::errorf(ConsoleLogEntry::General, "SplashData::preload: Cant get an sfxProfile for splash.");
Con::errorf(ConsoleLogEntry::General, "ProjectileData::preload: Invalid ProjectileSound asset.");
return false;
}
if (!lightDesc && lightDescId != 0)

View file

@ -318,17 +318,19 @@ bool RigidShapeData::preload(bool server, String &errorStr)
if (!server) {
for (S32 i = 0; i < Body::MaxSounds; i++)
{
if (getBodySounds(i) != StringTable->EmptyString())
if (getBodySounds(i) != StringTable->EmptyString() && !isBodySoundsValid(i))
{
_setBodySounds(getBodySounds(i), i);
Con::errorf(ConsoleLogEntry::General, "RigidShapeData::preload: Invalid BodySound asset.");
return false;
}
}
for (S32 j = 0; j < Sounds::MaxSounds; j++)
{
if (getWaterSounds(j) != StringTable->EmptyString())
if (getWaterSounds(j) != StringTable->EmptyString() && !isWaterSoundsValid(j))
{
_setWaterSounds(getWaterSounds(j), j);
Con::errorf(ConsoleLogEntry::General, "RigidShapeData::preload: Invalid WaterSound asset.");
return false;
}
}

View file

@ -422,13 +422,11 @@ bool ShapeBaseImageData::preload(bool server, String &errorStr)
if (!Sim::findObject(SimObjectId((uintptr_t)state[i].emitter), state[i].emitter))
Con::errorf(ConsoleLogEntry::General, "Error, unable to load emitter for image datablock");
if (getstateSound(i) != StringTable->EmptyString())
if (getstateSound(i) != StringTable->EmptyString() && !isstateSoundValid(i))
{
_setstateSound(getstateSound(i), i);
if (!getstateSoundProfile(i))
Con::errorf("ShapeBaseImageData::preload() - Could not find profile for asset %s on state %d", getstateSound(i), i);
Con::errorf(ConsoleLogEntry::General, "ShapeBaseImageData::preload: Invalid stateSound asset %s on state %d", getstateSound(i), i);
return false;
}
}
}

View file

@ -141,9 +141,10 @@ bool FlyingVehicleData::preload(bool server, String &errorStr)
if (!server) {
for (S32 i = 0; i < MaxSounds; i++)
{
if (mFlyingSounds[i])
if (getFlyingSounds(i) != StringTable->EmptyString() && !isFlyingSoundsValid(i))
{
_setFlyingSounds(getFlyingSounds(i), i);
Con::errorf(ConsoleLogEntry::General, "FlyingVehicleData::preload: Invalid FlyingSounds asset.");
return false;
}
}
for (S32 j = 0; j < MaxJetEmitters; j++)

View file

@ -314,11 +314,13 @@ bool HoverVehicleData::preload(bool server, String &errorStr)
if (!server) {
for (S32 i = 0; i < MaxSounds; i++)
if (getHoverSounds(i) != StringTable->EmptyString())
{
if (getHoverSounds(i) != StringTable->EmptyString() && !isHoverSoundsValid(i))
{
_setHoverSounds(getHoverSounds(i), i);
Con::errorf(ConsoleLogEntry::General, "HoverVehicleData::preload: Invalid HoverSounds asset.");
return false;
}
}
for (S32 j = 0; j < MaxJetEmitters; j++)
if (jetEmitter[j])
Sim::findObject(SimObjectId((uintptr_t)jetEmitter[j]),jetEmitter[j]);

View file

@ -348,9 +348,10 @@ bool WheeledVehicleData::preload(bool server, String &errorStr)
if (!server) {
for (S32 i = 0; i < MaxSounds; i++)
{
if (getWheeledVehicleSounds(i) != StringTable->EmptyString())
if (getWheeledVehicleSounds(i) != StringTable->EmptyString() && !isWheeledVehicleSoundsValid(i))
{
_setWheeledVehicleSounds(getWheeledVehicleSounds(i), i);
Con::errorf(ConsoleLogEntry::General, "HoverVehicleData::preload: Invalid WheeledVehicleSounds asset.");
return false;
}
}

View file

@ -517,11 +517,10 @@ bool afxMagicMissileData::preload(bool server, String &errorStr)
Con::errorf(ConsoleLogEntry::General, "ProjectileData::preload: Invalid packet, bad datablockId(decal): %d", decalId);
*/
_setProjectileSound(getProjectileSound());
if (getProjectileSound() != StringTable->EmptyString())
if (getProjectileSound() != StringTable->EmptyString() && !isProjectileSoundValid())
{
if (!getProjectileSoundProfile())
Con::errorf(ConsoleLogEntry::General, "afxMagicMissileData::preload: Cant get an sfxProfile for afxMagicMissileData.");
Con::errorf(ConsoleLogEntry::General, "afxMagicMissileData::preload: Invalid ProjectileSound asset.");
return false;
}
if (!lightDesc && lightDescId != 0)

View file

@ -153,10 +153,9 @@ bool SFXAmbience::preload( bool server, String& errorStr )
if( !sfxResolve( &mEnvironment, errorStr ) )
return false;
_setSoundTrack(getSoundTrack());
if (!getSoundTrackProfile())
if (getSoundTrack() != StringTable->EmptyString() && !isSoundTrackValid())
{
Con::errorf("SFXAmbience::Preload() - unable to find sfxProfile for asset %s", mSoundTrackAssetId);
Con::errorf(ConsoleLogEntry::General, "SFXAmbience::preload: Invalid SoundTrack asset.");
return false;
}