diff --git a/Engine/source/T3D/proximityMine.cpp b/Engine/source/T3D/proximityMine.cpp
index 2102ef7e1..12eb60a1a 100644
--- a/Engine/source/T3D/proximityMine.cpp
+++ b/Engine/source/T3D/proximityMine.cpp
@@ -74,16 +74,16 @@ IMPLEMENT_CALLBACK( ProximityMineData, onExplode, void, ( ProximityMine* obj, Po
ProximityMineData::ProximityMineData()
: armingDelay( 0 ),
armingSequence( -1 ),
- armingSound( NULL ),
triggerRadius( 5.0f ),
triggerSpeed( 1.0f ),
autoTriggerDelay( 0 ),
triggerOnOwner( false ),
triggerDelay( 0 ),
triggerSequence( -1 ),
- triggerSound( NULL ),
explosionOffset( 0.05f )
{
+ INIT_SOUNDASSET(ArmSound);
+ INIT_SOUNDASSET(TriggerSound);
}
void ProximityMineData::initPersistFields()
@@ -91,9 +91,9 @@ void ProximityMineData::initPersistFields()
addGroup( "Arming" );
addField( "armingDelay", TypeF32, Offset(armingDelay, ProximityMineData),
"Delay (in seconds) from when the mine is placed to when it becomes active." );
- addField( "armingSound", TypeSFXTrackName, Offset(armingSound, ProximityMineData),
- "Sound to play when the mine is armed (starts at the same time as "
- "the armed sequence if defined)." );
+
+ INITPERSISTFIELD_SOUNDASSET(ArmSound, ProximityMineData, "Arming sound for this proximity mine.");
+
endGroup( "Arming" );
addGroup( "Triggering" );
@@ -111,9 +111,9 @@ void ProximityMineData::initPersistFields()
"Speed above which moving objects within the trigger radius will trigger the mine" );
addField( "triggerDelay", TypeF32, Offset(triggerDelay, ProximityMineData),
"Delay (in seconds) from when the mine is triggered until it explodes." );
- addField( "triggerSound", TypeSFXTrackName, Offset(triggerSound, ProximityMineData),
- "Sound to play when the mine is triggered (starts at the same time as "
- "the triggered sequence if defined)." );
+
+ INITPERSISTFIELD_SOUNDASSET(TriggerSound, ProximityMineData, "Arming sound for this proximity mine.");
+
endGroup( "Triggering" );
addGroup( "Explosion" );
@@ -135,12 +135,10 @@ bool ProximityMineData::preload( bool server, String& errorStr )
if ( !server )
{
- // Resolve sounds
- String sfxErrorStr;
- if( !sfxResolve( &armingSound, sfxErrorStr ) )
- Con::errorf( ConsoleLogEntry::General, "ProximityMineData::preload: Invalid packet: %s", sfxErrorStr.c_str() );
- if( !sfxResolve( &triggerSound, sfxErrorStr ) )
- Con::errorf( ConsoleLogEntry::General, "ProximityMineData::preload: Invalid packet: %s", sfxErrorStr.c_str() );
+ if( !getArmSound() )
+ Con::errorf( ConsoleLogEntry::General, "ProximityMineData::preload: Invalid arming sound." );
+ if( !getTriggerSound() )
+ Con::errorf( ConsoleLogEntry::General, "ProximityMineData::preload: Invalid trigger sound." );
}
if ( mShape )
@@ -158,14 +156,14 @@ void ProximityMineData::packData( BitStream* stream )
Parent::packData( stream );
stream->write( armingDelay );
- sfxWrite( stream, armingSound );
+ PACKDATA_SOUNDASSET(ArmSound);
stream->write( autoTriggerDelay );
stream->writeFlag( triggerOnOwner );
stream->write( triggerRadius );
stream->write( triggerSpeed );
stream->write( triggerDelay );
- sfxWrite( stream, triggerSound );
+ PACKDATA_SOUNDASSET(TriggerSound);
}
void ProximityMineData::unpackData( BitStream* stream )
@@ -173,14 +171,14 @@ void ProximityMineData::unpackData( BitStream* stream )
Parent::unpackData(stream);
stream->read( &armingDelay );
- sfxRead( stream, &armingSound );
+ UNPACKDATA_SOUNDASSET(ArmSound);
stream->read( &autoTriggerDelay );
triggerOnOwner = stream->readFlag();
stream->read( &triggerRadius );
stream->read( &triggerSpeed );
stream->read( &triggerDelay );
- sfxRead( stream, &triggerSound );
+ UNPACKDATA_SOUNDASSET(TriggerSound);
}
//----------------------------------------------------------------------------
@@ -428,8 +426,8 @@ void ProximityMine::processTick( const Move* move )
mAnimThread = mShapeInstance->addThread();
mShapeInstance->setSequence( mAnimThread, mDataBlock->armingSequence, 0.0f );
}
- if ( mDataBlock->armingSound )
- SFX->playOnce( mDataBlock->armingSound, &getRenderTransform() );
+ if ( mDataBlock->getArmSound() )
+ SFX->playOnce( mDataBlock->getArmSoundAsset()->getSfxProfile(), &getRenderTransform() );
}
break;
@@ -469,8 +467,8 @@ void ProximityMine::processTick( const Move* move )
mAnimThread = mShapeInstance->addThread();
mShapeInstance->setSequence( mAnimThread, mDataBlock->triggerSequence, 0.0f );
}
- if ( mDataBlock->triggerSound )
- SFX->playOnce( mDataBlock->triggerSound, &getRenderTransform() );
+ if ( mDataBlock->getTriggerSound() )
+ SFX->playOnce( mDataBlock->getTriggerSoundAsset()->getSfxProfile(), &getRenderTransform() );
if ( isServerObject() )
mDataBlock->onTriggered_callback( this, sql.mList[0] );
diff --git a/Engine/source/T3D/proximityMine.h b/Engine/source/T3D/proximityMine.h
index 7b448e628..4736c0e16 100644
--- a/Engine/source/T3D/proximityMine.h
+++ b/Engine/source/T3D/proximityMine.h
@@ -27,6 +27,8 @@
#include "T3D/item.h"
#endif
+#include "T3D/assets/SoundAsset.h"
+
class ExplosionData;
class SFXTrack;
class ProximityMine;
@@ -43,7 +45,8 @@ struct ProximityMineData: public ItemData
public:
F32 armingDelay;
S32 armingSequence;
- SFXTrack* armingSound;
+ DECLARE_SOUNDASSET(ProximityMineData, ArmSound);
+ DECLARE_SOUNDASSET_SETGET(ProximityMineData, ArmSound);
F32 autoTriggerDelay;
bool triggerOnOwner;
@@ -51,7 +54,8 @@ public:
F32 triggerSpeed;
F32 triggerDelay;
S32 triggerSequence;
- SFXTrack* triggerSound;
+ DECLARE_SOUNDASSET(ProximityMineData, TriggerSound);
+ DECLARE_SOUNDASSET_SETGET(ProximityMineData, TriggerSound);
F32 explosionOffset;
diff --git a/Engine/source/T3D/vehicles/flyingVehicle.cpp b/Engine/source/T3D/vehicles/flyingVehicle.cpp
index e092668d8..64ec41fd6 100644
--- a/Engine/source/T3D/vehicles/flyingVehicle.cpp
+++ b/Engine/source/T3D/vehicles/flyingVehicle.cpp
@@ -116,7 +116,7 @@ FlyingVehicleData::FlyingVehicleData()
jetEmitter[j] = 0;
for (S32 i = 0; i < MaxSounds; i++)
- sound[i] = 0;
+ INIT_SOUNDASSET_ARRAY(FlyingSounds, i);
vertThrustMultiple = 1.0;
}
@@ -131,8 +131,10 @@ bool FlyingVehicleData::preload(bool server, String &errorStr)
// Resolve objects transmitted from server
if (!server) {
for (S32 i = 0; i < MaxSounds; i++)
- if (sound[i])
- Sim::findObject(SimObjectId((uintptr_t)sound[i]),sound[i]);
+ if (mFlyingSounds[i])
+ {
+ _setFlyingSounds(getFlyingSounds(i), i);
+ }
for (S32 j = 0; j < MaxJetEmitters; j++)
if (jetEmitter[j])
@@ -163,10 +165,8 @@ bool FlyingVehicleData::preload(bool server, String &errorStr)
void FlyingVehicleData::initPersistFields()
{
- addField( "jetSound", TYPEID< SFXProfile >(), Offset(sound[JetSound], FlyingVehicleData),
- "Looping sound to play while the vehicle is jetting." );
- addField( "engineSound", TYPEID< SFXProfile >(), Offset(sound[EngineSound], FlyingVehicleData),
- "Looping engine sound." );
+
+ INITPERSISTFIELD_SOUNDASSET_ARRAY(FlyingSounds, Sounds::MaxSounds, FlyingVehicleData, "Sounds for flying vehicle");
addField( "maneuveringForce", TypeF32, Offset(maneuveringForce, FlyingVehicleData),
"@brief Maximum X and Y (horizontal plane) maneuvering force.\n\n"
@@ -240,11 +240,7 @@ void FlyingVehicleData::packData(BitStream* stream)
for (S32 i = 0; i < MaxSounds; i++)
{
- if (stream->writeFlag(sound[i]))
- {
- SimObjectId writtenId = mPacked ? SimObjectId((uintptr_t)sound[i]) : sound[i]->getId();
- stream->writeRangedU32(writtenId, DataBlockObjectIdFirst, DataBlockObjectIdLast);
- }
+ PACKDATA_SOUNDASSET_ARRAY(FlyingSounds, i);
}
for (S32 j = 0; j < MaxJetEmitters; j++)
@@ -277,11 +273,9 @@ void FlyingVehicleData::unpackData(BitStream* stream)
{
Parent::unpackData(stream);
- for (S32 i = 0; i < MaxSounds; i++) {
- sound[i] = NULL;
- if (stream->readFlag())
- sound[i] = (SFXProfile*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst,
- DataBlockObjectIdLast);
+ for (S32 i = 0; i < MaxSounds; i++)
+ {
+ UNPACKDATA_SOUNDASSET_ARRAY(FlyingSounds, i);
}
for (S32 j = 0; j < MaxJetEmitters; j++) {
@@ -374,11 +368,11 @@ bool FlyingVehicle::onNewDataBlock(GameBaseData* dptr, bool reload)
SFX_DELETE( mJetSound );
SFX_DELETE( mEngineSound );
- if ( mDataBlock->sound[FlyingVehicleData::EngineSound] )
- mEngineSound = SFX->createSource( mDataBlock->sound[FlyingVehicleData::EngineSound], &getTransform() );
+ if ( mDataBlock->getFlyingSounds(FlyingVehicleData::EngineSound) )
+ mEngineSound = SFX->createSource( mDataBlock->getFlyingSoundProfile(FlyingVehicleData::EngineSound), &getTransform() );
- if ( mDataBlock->sound[FlyingVehicleData::JetSound] )
- mJetSound = SFX->createSource( mDataBlock->sound[FlyingVehicleData::JetSound], &getTransform() );
+ if ( mDataBlock->getFlyingSounds(FlyingVehicleData::JetSound))
+ mJetSound = SFX->createSource( mDataBlock->getFlyingSoundProfile(FlyingVehicleData::JetSound), &getTransform() );
}
// Jet Sequences
diff --git a/Engine/source/T3D/vehicles/flyingVehicle.h b/Engine/source/T3D/vehicles/flyingVehicle.h
index 814b66250..18c3379e1 100644
--- a/Engine/source/T3D/vehicles/flyingVehicle.h
+++ b/Engine/source/T3D/vehicles/flyingVehicle.h
@@ -45,7 +45,15 @@ struct FlyingVehicleData: public VehicleData {
EngineSound,
MaxSounds,
};
- SFXProfile* sound[MaxSounds];
+ DECLARE_SOUNDASSET_ARRAY(FlyingVehicleData, FlyingSounds, Sounds::MaxSounds);
+ DECLARE_SOUNDASSET_ARRAY_SETGET(FlyingVehicleData, FlyingSounds);
+ SFXProfile* getFlyingSoundProfile(U32 id)
+ {
+ if (mFlyingSoundsAsset[id] != NULL)
+ return mFlyingSoundsAsset[id]->getSfxProfile();
+ else
+ return NULL;
+ }
enum Jets {
// These enums index into a static name list.