fix sDefaultAmbience intialization.

we don't want to spool that up before the SFX subsystem has kicked in
This commit is contained in:
AzaezelX 2022-05-16 19:22:25 -05:00
parent 22db2d4291
commit ff0e418132
2 changed files with 15 additions and 11 deletions

View file

@ -73,7 +73,7 @@ extern F32 gDecalBias;
extern GFXTexHandle gLevelAccuMap; extern GFXTexHandle gLevelAccuMap;
/// Default SFXAmbience used to reset the global soundscape. /// Default SFXAmbience used to reset the global soundscape.
static SFXAmbience sDefaultAmbience; extern SFXAmbience* sDefaultAmbience;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -256,7 +256,7 @@ void LevelInfo::unpackUpdate(NetConnection *conn, BitStream *stream)
if( mSoundAmbience ) if( mSoundAmbience )
mSoundscape->setAmbience( mSoundAmbience ); mSoundscape->setAmbience( mSoundAmbience );
else else
mSoundscape->setAmbience( &sDefaultAmbience ); mSoundscape->setAmbience( sDefaultAmbience );
} }
SFX->setDistanceModel( mSoundDistanceModel ); SFX->setDistanceModel( mSoundDistanceModel );
@ -302,7 +302,7 @@ bool LevelInfo::onAdd()
void LevelInfo::onRemove() void LevelInfo::onRemove()
{ {
if( mSoundscape ) if( mSoundscape )
mSoundscape->setAmbience( &sDefaultAmbience ); mSoundscape->setAmbience( sDefaultAmbience );
Parent::onRemove(); Parent::onRemove();
} }

View file

@ -69,6 +69,8 @@ MODULE_END;
SFXSystem* SFXSystem::smSingleton = NULL; SFXSystem* SFXSystem::smSingleton = NULL;
/// Default SFXAmbience used to reset the global soundscape.
SFXAmbience *sDefaultAmbience;
// Excludes Null and Blocked as these are not passed out to the control layer. // Excludes Null and Blocked as these are not passed out to the control layer.
ImplementEnumType( SFXStatus, ImplementEnumType( SFXStatus,
@ -365,6 +367,7 @@ void SFXSystem::init()
// Create the system. // Create the system.
smSingleton = new SFXSystem(); smSingleton = new SFXSystem();
sDefaultAmbience = new SFXAmbience();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -384,6 +387,7 @@ void SFXSystem::destroy()
// Destroy the stream thread pool // Destroy the stream thread pool
SFXInternal::SFXThreadPool::deleteSingleton(); SFXInternal::SFXThreadPool::deleteSingleton();
delete(sDefaultAmbience);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -1617,10 +1621,10 @@ DefineEngineFunction( sfxPlayOnce, S32, (StringTableEntry assetId, const char* a
{ {
SFXDescription* description = NULL; SFXDescription* description = NULL;
if (assetId == StringTable->EmptyString()) if (assetId == StringTable->EmptyString())
{ {
Con::errorf( "sfxPlayOnce - Must Define a sound asset"); Con::errorf( "sfxPlayOnce - Must Define a sound asset");
return 0; return 0;
} }
SFXSource* source = NULL; SFXSource* source = NULL;
@ -1639,10 +1643,10 @@ DefineEngineFunction( sfxPlayOnce, S32, (StringTableEntry assetId, const char* a
MatrixF transform; MatrixF transform;
transform.set(EulerF(0, 0, 0), Point3F(dAtof(arg0), dAtof(arg1), dAtof(arg2))); transform.set(EulerF(0, 0, 0), Point3F(dAtof(arg0), dAtof(arg1), dAtof(arg2)));
source = SFX->playOnce(tempSoundAsset->getSfxProfile(), &transform, NULL, dAtof(arg3)); source = SFX->playOnce(tempSoundAsset->getSfxProfile(), &transform, NULL, dAtof(arg3));
}
} }
else }
{ else
{
Con::errorf("sfxPlayOnce - Could not locate assetId '%s'", assetId); Con::errorf("sfxPlayOnce - Could not locate assetId '%s'", assetId);
return 0; return 0;
} }