Browse Source

fix sDefaultAmbience intialization.
we don't want to spool that up before the SFX subsystem has kicked in

AzaezelX 3 years ago
parent
commit
ff0e418132
2 changed files with 15 additions and 11 deletions
  1. 3 3
      Engine/source/T3D/levelInfo.cpp
  2. 12 8
      Engine/source/sfx/sfxSystem.cpp

+ 3 - 3
Engine/source/T3D/levelInfo.cpp

@@ -73,7 +73,7 @@ extern F32 gDecalBias;
 extern GFXTexHandle gLevelAccuMap;
 
 /// 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 )
             mSoundscape->setAmbience( mSoundAmbience );
          else
-            mSoundscape->setAmbience( &sDefaultAmbience );
+            mSoundscape->setAmbience( sDefaultAmbience );
       }
 
       SFX->setDistanceModel( mSoundDistanceModel );
@@ -302,7 +302,7 @@ bool LevelInfo::onAdd()
 void LevelInfo::onRemove()
 {
    if( mSoundscape )
-      mSoundscape->setAmbience( &sDefaultAmbience );
+      mSoundscape->setAmbience( sDefaultAmbience );
 
    Parent::onRemove();
 }

+ 12 - 8
Engine/source/sfx/sfxSystem.cpp

@@ -69,6 +69,8 @@ MODULE_END;
 
 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.
 ImplementEnumType( SFXStatus,
@@ -364,7 +366,8 @@ void SFXSystem::init()
    // register them in the provider initialization.
 
    // Create the system.
-   smSingleton = new SFXSystem();   
+   smSingleton = new SFXSystem();
+   sDefaultAmbience = new SFXAmbience();
 }
 
 //-----------------------------------------------------------------------------
@@ -384,6 +387,7 @@ void SFXSystem::destroy()
    // Destroy the stream thread pool
 
    SFXInternal::SFXThreadPool::deleteSingleton();
+   delete(sDefaultAmbience);
 }
 
 //-----------------------------------------------------------------------------
@@ -1617,10 +1621,10 @@ DefineEngineFunction( sfxPlayOnce, S32, (StringTableEntry assetId, const char* a
 {
    SFXDescription* description = NULL;
    if (assetId == StringTable->EmptyString())
-      {
-         Con::errorf( "sfxPlayOnce - Must Define a sound asset");
-         return 0;
-      }
+   {
+      Con::errorf( "sfxPlayOnce - Must Define a sound asset");
+      return 0;
+   }
 
    SFXSource* source = NULL;
 
@@ -1639,10 +1643,10 @@ DefineEngineFunction( sfxPlayOnce, S32, (StringTableEntry assetId, const char* a
          MatrixF transform;
          transform.set(EulerF(0, 0, 0), Point3F(dAtof(arg0), dAtof(arg1), dAtof(arg2)));
          source = SFX->playOnce(tempSoundAsset->getSfxProfile(), &transform, NULL, dAtof(arg3));
-   }
       }
-      else
-      {
+   }
+   else
+   {
       Con::errorf("sfxPlayOnce - Could not locate assetId '%s'", assetId);
       return 0;
    }