From c4ae6258cc4110e6a341060a6de77204bf7f723b Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sun, 26 Feb 2023 17:26:43 -0600 Subject: [PATCH] sound safeties and future notes --- Engine/source/T3D/assets/SoundAsset.h | 4 ++-- Engine/source/T3D/fx/explosion.cpp | 5 ++--- Engine/source/T3D/fx/lightning.cpp | 10 ++++------ Engine/source/T3D/fx/precipitation.cpp | 5 ++--- Engine/source/T3D/fx/splash.cpp | 4 ++-- Engine/source/T3D/player.cpp | 5 ++--- Engine/source/T3D/projectile.cpp | 5 ++--- Engine/source/T3D/proximityMine.cpp | 12 ++++++++---- Engine/source/T3D/rigidShape.cpp | 10 ++++------ Engine/source/T3D/shapeImage.cpp | 5 ++--- Engine/source/T3D/vehicles/flyingVehicle.cpp | 2 +- Engine/source/T3D/vehicles/hoverVehicle.cpp | 5 ++--- Engine/source/T3D/vehicles/wheeledVehicle.cpp | 5 ++--- Engine/source/afx/afxMagicMissile.cpp | 5 ++--- Engine/source/sfx/sfxAmbience.cpp | 5 ++--- 15 files changed, 39 insertions(+), 48 deletions(-) diff --git a/Engine/source/T3D/assets/SoundAsset.h b/Engine/source/T3D/assets/SoundAsset.h index 573063351..e7c3ee460 100644 --- a/Engine/source/T3D/assets/SoundAsset.h +++ b/Engine/source/T3D/assets/SoundAsset.h @@ -264,7 +264,7 @@ public: \ return m##name##Desc;}\ return NULL;\ }\ - bool is##name##Valid() { return (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok); } + bool is##name##Valid() { return (get##name() != StringTable->EmptyString() && m##name##Asset && m##name##Asset->getStatus() == AssetBase::Ok); } #ifdef TORQUE_SHOW_LEGACY_FILE_FIELDS @@ -449,7 +449,7 @@ public: \ return m##name##Asset[id]->getSfxProfile();\ return NULL;\ }\ - bool is##name##Valid(const U32& id) {return (get##name(id) != StringTable->EmptyString() && m##name##Asset[id]->getStatus() == AssetBase::Ok); } + bool is##name##Valid(const U32& id) {return (get##name(id) != StringTable->EmptyString() && m##name##Asset[id] && m##name##Asset[id]->getStatus() == AssetBase::Ok); } #ifdef TORQUE_SHOW_LEGACY_FILE_FIELDS diff --git a/Engine/source/T3D/fx/explosion.cpp b/Engine/source/T3D/fx/explosion.cpp index 3ac493a3d..d9cfc1367 100644 --- a/Engine/source/T3D/fx/explosion.cpp +++ b/Engine/source/T3D/fx/explosion.cpp @@ -877,10 +877,9 @@ bool ExplosionData::preload(bool server, String &errorStr) if( !server ) { - if (getSound() != StringTable->EmptyString() && !isSoundValid()) + if (!isSoundValid()) { - Con::errorf(ConsoleLogEntry::General, "ExplosionData::preload: Invalid Sound asset."); - return false; + //return false; -TODO: trigger asset download } if (!particleEmitter && particleEmitterId != 0) diff --git a/Engine/source/T3D/fx/lightning.cpp b/Engine/source/T3D/fx/lightning.cpp index fb3f795b6..58a5ca4bd 100644 --- a/Engine/source/T3D/fx/lightning.cpp +++ b/Engine/source/T3D/fx/lightning.cpp @@ -297,17 +297,15 @@ bool LightningData::preload(bool server, String &errorStr) { for (S32 i = 0; i < MaxThunders; i++) { - if (getThunderSound(i) != StringTable->EmptyString() && !isThunderSoundValid(i)) + if (!isThunderSoundValid(i)) { - Con::errorf(ConsoleLogEntry::General, "LightningData::preload: Invalid ThunderSound asset."); - return false; + //return false; -TODO: trigger asset download } } - if (getStrikeSound() != StringTable->EmptyString() && !isStrikeSoundValid()) + if (!isStrikeSoundValid()) { - Con::errorf(ConsoleLogEntry::General, "LightningData::preload: Invalid StrikeSound asset."); - return false; + //return false; -TODO: trigger asset download } mNumStrikeTextures = 0; diff --git a/Engine/source/T3D/fx/precipitation.cpp b/Engine/source/T3D/fx/precipitation.cpp index 13959405c..d57ef3bd6 100644 --- a/Engine/source/T3D/fx/precipitation.cpp +++ b/Engine/source/T3D/fx/precipitation.cpp @@ -191,10 +191,9 @@ bool PrecipitationData::preload( bool server, String &errorStr ) return false; if (!server) { - if (getSound() != StringTable->EmptyString() && !isSoundValid()) + if (!isSoundValid()) { - Con::errorf(ConsoleLogEntry::General, "PrecipitationData::preload: Invalid Sound asset."); - return false; + //return false; -TODO: trigger asset download } } diff --git a/Engine/source/T3D/fx/splash.cpp b/Engine/source/T3D/fx/splash.cpp index 53c5a5105..3b8c6da24 100644 --- a/Engine/source/T3D/fx/splash.cpp +++ b/Engine/source/T3D/fx/splash.cpp @@ -279,10 +279,10 @@ bool SplashData::preload(bool server, String &errorStr) if (!server) { - if (getSound() != StringTable->EmptyString() && !isSoundValid()) + if (!isSoundValid()) { Con::errorf(ConsoleLogEntry::General, "SplashData::preload: Invalid Sound asset."); - return false; + //return false; } S32 i; diff --git a/Engine/source/T3D/player.cpp b/Engine/source/T3D/player.cpp index ce729cb06..1aced35ff 100644 --- a/Engine/source/T3D/player.cpp +++ b/Engine/source/T3D/player.cpp @@ -471,10 +471,9 @@ bool PlayerData::preload(bool server, String &errorStr) if (!server) { for (U32 i = 0; i < MaxSounds; ++i) { - if (getPlayerSound(i) != StringTable->EmptyString() && !isPlayerSoundValid(i)) + if (!isPlayerSoundValid(i)) { - Con::errorf(ConsoleLogEntry::General, "ExplosionData::preload: Invalid PlayerSound asset."); - return false; + //return false; -TODO: trigger asset download } } } diff --git a/Engine/source/T3D/projectile.cpp b/Engine/source/T3D/projectile.cpp index 0de89fc9e..96bebca24 100644 --- a/Engine/source/T3D/projectile.cpp +++ b/Engine/source/T3D/projectile.cpp @@ -368,10 +368,9 @@ 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); - if (getProjectileSound() != StringTable->EmptyString() && !isProjectileSoundValid()) + if (!isProjectileSoundValid()) { - Con::errorf(ConsoleLogEntry::General, "ProjectileData::preload: Invalid ProjectileSound asset."); - return false; + //return false; -TODO: trigger asset download } if (!lightDesc && lightDescId != 0) diff --git a/Engine/source/T3D/proximityMine.cpp b/Engine/source/T3D/proximityMine.cpp index 2cc49a8ef..1a8465166 100644 --- a/Engine/source/T3D/proximityMine.cpp +++ b/Engine/source/T3D/proximityMine.cpp @@ -134,10 +134,14 @@ bool ProximityMineData::preload( bool server, String& errorStr ) if ( !server ) { - if( !getArmSound() ) - Con::errorf( ConsoleLogEntry::General, "ProximityMineData::preload: Invalid arming sound." ); - if( !getTriggerSound() ) - Con::errorf( ConsoleLogEntry::General, "ProximityMineData::preload: Invalid trigger sound." ); + if(!isArmSoundValid() ) + { + //return false; -TODO: trigger asset download + } + if(!isTriggerSoundValid() ) + { + //return false; -TODO: trigger asset download + } } if ( mShape ) diff --git a/Engine/source/T3D/rigidShape.cpp b/Engine/source/T3D/rigidShape.cpp index 10dbe7e5a..2cec66d9d 100644 --- a/Engine/source/T3D/rigidShape.cpp +++ b/Engine/source/T3D/rigidShape.cpp @@ -318,19 +318,17 @@ bool RigidShapeData::preload(bool server, String &errorStr) if (!server) { for (S32 i = 0; i < Body::MaxSounds; i++) { - if (getBodySounds(i) != StringTable->EmptyString() && !isBodySoundsValid(i)) + if (!isBodySoundsValid(i)) { - Con::errorf(ConsoleLogEntry::General, "RigidShapeData::preload: Invalid BodySound asset."); - return false; + //return false; -TODO: trigger asset download } } for (S32 j = 0; j < Sounds::MaxSounds; j++) { - if (getWaterSounds(j) != StringTable->EmptyString() && !isWaterSoundsValid(j)) + if (!isWaterSoundsValid(j)) { - Con::errorf(ConsoleLogEntry::General, "RigidShapeData::preload: Invalid WaterSound asset."); - return false; + //return false; -TODO: trigger asset download } } diff --git a/Engine/source/T3D/shapeImage.cpp b/Engine/source/T3D/shapeImage.cpp index 8615f7741..f921aa680 100644 --- a/Engine/source/T3D/shapeImage.cpp +++ b/Engine/source/T3D/shapeImage.cpp @@ -422,10 +422,9 @@ 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() && !isstateSoundValid(i)) + if (!isstateSoundValid(i)) { - Con::errorf(ConsoleLogEntry::General, "ShapeBaseImageData::preload: Invalid stateSound asset %s on state %d", getstateSound(i), i); - return false; + //return false; -TODO: trigger asset download } } } diff --git a/Engine/source/T3D/vehicles/flyingVehicle.cpp b/Engine/source/T3D/vehicles/flyingVehicle.cpp index 92b409826..063e23afe 100644 --- a/Engine/source/T3D/vehicles/flyingVehicle.cpp +++ b/Engine/source/T3D/vehicles/flyingVehicle.cpp @@ -141,7 +141,7 @@ bool FlyingVehicleData::preload(bool server, String &errorStr) if (!server) { for (S32 i = 0; i < MaxSounds; i++) { - if (getFlyingSounds(i) != StringTable->EmptyString() && !isFlyingSoundsValid(i)) + if (!isFlyingSoundsValid(i)) { Con::errorf(ConsoleLogEntry::General, "FlyingVehicleData::preload: Invalid FlyingSounds asset."); return false; diff --git a/Engine/source/T3D/vehicles/hoverVehicle.cpp b/Engine/source/T3D/vehicles/hoverVehicle.cpp index e9596f5a6..2c54e41c5 100644 --- a/Engine/source/T3D/vehicles/hoverVehicle.cpp +++ b/Engine/source/T3D/vehicles/hoverVehicle.cpp @@ -315,10 +315,9 @@ bool HoverVehicleData::preload(bool server, String &errorStr) for (S32 i = 0; i < MaxSounds; i++) { - if (getHoverSounds(i) != StringTable->EmptyString() && !isHoverSoundsValid(i)) + if (!isHoverSoundsValid(i)) { - Con::errorf(ConsoleLogEntry::General, "HoverVehicleData::preload: Invalid HoverSounds asset."); - return false; + //return false; -TODO: trigger asset download } } for (S32 j = 0; j < MaxJetEmitters; j++) diff --git a/Engine/source/T3D/vehicles/wheeledVehicle.cpp b/Engine/source/T3D/vehicles/wheeledVehicle.cpp index 2c36b71a9..b7553a8e8 100644 --- a/Engine/source/T3D/vehicles/wheeledVehicle.cpp +++ b/Engine/source/T3D/vehicles/wheeledVehicle.cpp @@ -348,10 +348,9 @@ bool WheeledVehicleData::preload(bool server, String &errorStr) if (!server) { for (S32 i = 0; i < MaxSounds; i++) { - if (getWheeledVehicleSounds(i) != StringTable->EmptyString() && !isWheeledVehicleSoundsValid(i)) + if (!isWheeledVehicleSoundsValid(i)) { - Con::errorf(ConsoleLogEntry::General, "HoverVehicleData::preload: Invalid WheeledVehicleSounds asset."); - return false; + //return false; -TODO: trigger asset download } } diff --git a/Engine/source/afx/afxMagicMissile.cpp b/Engine/source/afx/afxMagicMissile.cpp index 6defe43d1..a61f8e86d 100644 --- a/Engine/source/afx/afxMagicMissile.cpp +++ b/Engine/source/afx/afxMagicMissile.cpp @@ -517,10 +517,9 @@ bool afxMagicMissileData::preload(bool server, String &errorStr) Con::errorf(ConsoleLogEntry::General, "ProjectileData::preload: Invalid packet, bad datablockId(decal): %d", decalId); */ - if (getProjectileSound() != StringTable->EmptyString() && !isProjectileSoundValid()) + if (!isProjectileSoundValid()) { - Con::errorf(ConsoleLogEntry::General, "afxMagicMissileData::preload: Invalid ProjectileSound asset."); - return false; + //return false; -TODO: trigger asset download } if (!lightDesc && lightDescId != 0) diff --git a/Engine/source/sfx/sfxAmbience.cpp b/Engine/source/sfx/sfxAmbience.cpp index b5d0502bb..0ef3ed0ad 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; - if (getSoundTrack() != StringTable->EmptyString() && !isSoundTrackValid()) + if (!isSoundTrackValid()) { - Con::errorf(ConsoleLogEntry::General, "SFXAmbience::preload: Invalid SoundTrack asset."); - return false; + //return false; -TODO: trigger asset download } for( U32 i = 0; i < MaxStates; ++ i )