From 15f7f04beec72ee21ed0b3da4c177cca7febae7d Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sun, 19 Feb 2023 05:19:51 -0600 Subject: [PATCH] standardize soundasset preloading for datablocks --- Engine/source/T3D/fx/explosion.cpp | 11 +++-------- Engine/source/T3D/fx/lightning.cpp | 14 ++++++-------- Engine/source/T3D/fx/precipitation.cpp | 8 +++----- Engine/source/T3D/fx/splash.cpp | 9 +++------ Engine/source/T3D/player.cpp | 7 +++---- Engine/source/T3D/projectile.cpp | 7 +++---- Engine/source/T3D/rigidShape.cpp | 10 ++++++---- Engine/source/T3D/shapeImage.cpp | 8 +++----- Engine/source/T3D/vehicles/flyingVehicle.cpp | 5 +++-- Engine/source/T3D/vehicles/hoverVehicle.cpp | 8 +++++--- Engine/source/T3D/vehicles/wheeledVehicle.cpp | 5 +++-- Engine/source/afx/afxMagicMissile.cpp | 7 +++---- Engine/source/sfx/sfxAmbience.cpp | 5 ++--- 13 files changed, 46 insertions(+), 58 deletions(-) diff --git a/Engine/source/T3D/fx/explosion.cpp b/Engine/source/T3D/fx/explosion.cpp index 61d27dae7..3ac493a3d 100644 --- a/Engine/source/T3D/fx/explosion.cpp +++ b/Engine/source/T3D/fx/explosion.cpp @@ -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) diff --git a/Engine/source/T3D/fx/lightning.cpp b/Engine/source/T3D/fx/lightning.cpp index 0ffef45bf..fb3f795b6 100644 --- a/Engine/source/T3D/fx/lightning.cpp +++ b/Engine/source/T3D/fx/lightning.cpp @@ -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; diff --git a/Engine/source/T3D/fx/precipitation.cpp b/Engine/source/T3D/fx/precipitation.cpp index fda28f597..13959405c 100644 --- a/Engine/source/T3D/fx/precipitation.cpp +++ b/Engine/source/T3D/fx/precipitation.cpp @@ -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; } } diff --git a/Engine/source/T3D/fx/splash.cpp b/Engine/source/T3D/fx/splash.cpp index 46f1a22db..53c5a5105 100644 --- a/Engine/source/T3D/fx/splash.cpp +++ b/Engine/source/T3D/fx/splash.cpp @@ -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; diff --git a/Engine/source/T3D/player.cpp b/Engine/source/T3D/player.cpp index 7d5c4be99..ce729cb06 100644 --- a/Engine/source/T3D/player.cpp +++ b/Engine/source/T3D/player.cpp @@ -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; } } } diff --git a/Engine/source/T3D/projectile.cpp b/Engine/source/T3D/projectile.cpp index d99188ac3..0de89fc9e 100644 --- a/Engine/source/T3D/projectile.cpp +++ b/Engine/source/T3D/projectile.cpp @@ -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) diff --git a/Engine/source/T3D/rigidShape.cpp b/Engine/source/T3D/rigidShape.cpp index cbece3f20..10dbe7e5a 100644 --- a/Engine/source/T3D/rigidShape.cpp +++ b/Engine/source/T3D/rigidShape.cpp @@ -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; } } diff --git a/Engine/source/T3D/shapeImage.cpp b/Engine/source/T3D/shapeImage.cpp index 97ee3cea5..8615f7741 100644 --- a/Engine/source/T3D/shapeImage.cpp +++ b/Engine/source/T3D/shapeImage.cpp @@ -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; } - } } diff --git a/Engine/source/T3D/vehicles/flyingVehicle.cpp b/Engine/source/T3D/vehicles/flyingVehicle.cpp index 13e42df15..92b409826 100644 --- a/Engine/source/T3D/vehicles/flyingVehicle.cpp +++ b/Engine/source/T3D/vehicles/flyingVehicle.cpp @@ -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++) diff --git a/Engine/source/T3D/vehicles/hoverVehicle.cpp b/Engine/source/T3D/vehicles/hoverVehicle.cpp index 0172c573f..e9596f5a6 100644 --- a/Engine/source/T3D/vehicles/hoverVehicle.cpp +++ b/Engine/source/T3D/vehicles/hoverVehicle.cpp @@ -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]); diff --git a/Engine/source/T3D/vehicles/wheeledVehicle.cpp b/Engine/source/T3D/vehicles/wheeledVehicle.cpp index b11c040f9..2c36b71a9 100644 --- a/Engine/source/T3D/vehicles/wheeledVehicle.cpp +++ b/Engine/source/T3D/vehicles/wheeledVehicle.cpp @@ -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; } } diff --git a/Engine/source/afx/afxMagicMissile.cpp b/Engine/source/afx/afxMagicMissile.cpp index 09a4e7053..6defe43d1 100644 --- a/Engine/source/afx/afxMagicMissile.cpp +++ b/Engine/source/afx/afxMagicMissile.cpp @@ -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) diff --git a/Engine/source/sfx/sfxAmbience.cpp b/Engine/source/sfx/sfxAmbience.cpp index ade60dd92..b5d0502bb 100644 --- a/Engine/source/sfx/sfxAmbience.cpp +++ b/Engine/source/sfx/sfxAmbience.cpp @@ -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; }