1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 09:53:50 +00:00

Store the underwater sound to easily stop it

This commit is contained in:
Chris Robinson 2013-08-27 13:48:20 -07:00
parent 16331bf1ed
commit 02df8ab841
2 changed files with 8 additions and 5 deletions

View file

@ -103,6 +103,7 @@ namespace MWSound
SoundManager::~SoundManager() SoundManager::~SoundManager()
{ {
mUnderwaterSound.reset();
mActiveSounds.clear(); mActiveSounds.clear();
mMusic.reset(); mMusic.reset();
mOutput.reset(); mOutput.reset();
@ -550,13 +551,13 @@ namespace MWSound
{ {
env = Env_Underwater; env = Env_Underwater;
//play underwater sound //play underwater sound
if(!getSoundPlaying(MWWorld::Ptr(), "Underwater")) if(!(mUnderwaterSound && mUnderwaterSound->isPlaying()))
playSound("Underwater", 1.0f, 1.0f, Play_TypeSfx, Play_LoopNoEnv); mUnderwaterSound = playSound("Underwater", 1.0f, 1.0f, Play_TypeSfx, Play_LoopNoEnv);
} }
else else if(mUnderwaterSound)
{ {
//no need to check if it's playing, stop sound does nothing in that case mUnderwaterSound->stop();
stopSound("Underwater"); mUnderwaterSound.reset();
} }
mOutput->updateListener( mOutput->updateListener(

View file

@ -44,6 +44,8 @@ namespace MWSound
typedef std::map<MWBase::SoundPtr,PtrIDPair> SoundMap; typedef std::map<MWBase::SoundPtr,PtrIDPair> SoundMap;
SoundMap mActiveSounds; SoundMap mActiveSounds;
MWBase::SoundPtr mUnderwaterSound;
Ogre::Vector3 mListenerPos; Ogre::Vector3 mListenerPos;
Ogre::Vector3 mListenerDir; Ogre::Vector3 mListenerDir;
Ogre::Vector3 mListenerUp; Ogre::Vector3 mListenerUp;