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( !server )
{ {
if (getSound() != StringTable->EmptyString()) if (getSound() != StringTable->EmptyString() && !isSoundValid())
{ {
_setSound(getSound()); Con::errorf(ConsoleLogEntry::General, "ExplosionData::preload: Invalid Sound asset.");
return false;
if (!getSoundProfile())
{
Con::errorf(ConsoleLogEntry::General, "SplashData::preload: Cant get an sfxProfile for splash.");
return false;
}
} }
if (!particleEmitter && particleEmitterId != 0) if (!particleEmitter && particleEmitterId != 0)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -318,17 +318,19 @@ bool RigidShapeData::preload(bool server, String &errorStr)
if (!server) { if (!server) {
for (S32 i = 0; i < Body::MaxSounds; i++) 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++) 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)) if (!Sim::findObject(SimObjectId((uintptr_t)state[i].emitter), state[i].emitter))
Con::errorf(ConsoleLogEntry::General, "Error, unable to load emitter for image datablock"); 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); Con::errorf(ConsoleLogEntry::General, "ShapeBaseImageData::preload: Invalid stateSound asset %s on state %d", getstateSound(i), i);
if (!getstateSoundProfile(i)) return false;
Con::errorf("ShapeBaseImageData::preload() - Could not find profile for asset %s on state %d", getstateSound(i), i);
} }
} }
} }

View file

@ -141,9 +141,10 @@ bool FlyingVehicleData::preload(bool server, String &errorStr)
if (!server) { if (!server) {
for (S32 i = 0; i < MaxSounds; i++) 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++) for (S32 j = 0; j < MaxJetEmitters; j++)

View file

@ -314,11 +314,13 @@ bool HoverVehicleData::preload(bool server, String &errorStr)
if (!server) { if (!server) {
for (S32 i = 0; i < MaxSounds; i++) 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++) for (S32 j = 0; j < MaxJetEmitters; j++)
if (jetEmitter[j]) if (jetEmitter[j])
Sim::findObject(SimObjectId((uintptr_t)jetEmitter[j]),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) { if (!server) {
for (S32 i = 0; i < MaxSounds; i++) 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); Con::errorf(ConsoleLogEntry::General, "ProjectileData::preload: Invalid packet, bad datablockId(decal): %d", decalId);
*/ */
_setProjectileSound(getProjectileSound()); if (getProjectileSound() != StringTable->EmptyString() && !isProjectileSoundValid())
if (getProjectileSound() != StringTable->EmptyString())
{ {
if (!getProjectileSoundProfile()) Con::errorf(ConsoleLogEntry::General, "afxMagicMissileData::preload: Invalid ProjectileSound asset.");
Con::errorf(ConsoleLogEntry::General, "afxMagicMissileData::preload: Cant get an sfxProfile for afxMagicMissileData."); return false;
} }
if (!lightDesc && lightDescId != 0) if (!lightDesc && lightDescId != 0)

View file

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