diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index 5450c113a..449b5100b 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -231,36 +231,31 @@ namespace MWSound void SoundManager::stopSound3D(MWWorld::Ptr ptr, const std::string& soundId) { - // Stop a sound and remove it from the list. If soundId="" then - // stop all its sounds. - if(!soundId.empty()) - { - SoundMap::iterator snditer = mActiveSounds.find(std::make_pair(ptr, soundId)); - if(snditer == mActiveSounds.end()) - return; + SoundMap::iterator snditer = mActiveSounds.find(std::make_pair(ptr, soundId)); + if(snditer == mActiveSounds.end()) + return; - snditer->second->stop(); - mActiveSounds.erase(snditer); - } - else + snditer->second->stop(); + mActiveSounds.erase(snditer); + } + + void SoundManager::stopSound3D(MWWorld::Ptr ptr) + { + SoundMap::iterator snditer = mActiveSounds.begin(); + while(snditer != mActiveSounds.end()) { - SoundMap::iterator snditer = mActiveSounds.begin(); - while(snditer != mActiveSounds.end()) + if(snditer->first.first == ptr) { - if(snditer->first.first == ptr) - { - snditer->second->stop(); - mActiveSounds.erase(snditer++); - } - else - snditer++; + snditer->second->stop(); + mActiveSounds.erase(snditer++); } + else + snditer++; } } void SoundManager::stopSound(const MWWorld::Ptr::CellStore *cell) { - // Remove all references to objects belonging to a given cell SoundMap::iterator snditer = mActiveSounds.begin(); while(snditer != mActiveSounds.end()) { diff --git a/apps/openmw/mwsound/soundmanager.hpp b/apps/openmw/mwsound/soundmanager.hpp index 7f20425af..d79aface6 100644 --- a/apps/openmw/mwsound/soundmanager.hpp +++ b/apps/openmw/mwsound/soundmanager.hpp @@ -95,9 +95,11 @@ namespace MWSound bool untracked=false); ///< Play a sound from an object - void stopSound3D(MWWorld::Ptr reference, const std::string& soundId=""); - ///< Stop the given object from playing the given sound, If no soundId is given, - /// all sounds for this reference will stop. + void stopSound3D(MWWorld::Ptr reference, const std::string& soundId); + ///< Stop the given object from playing the given sound, + + void stopSound3D(MWWorld::Ptr reference); + ///< Stop the given object from playing all sounds. void stopSound(const MWWorld::Ptr::CellStore *cell); ///< Stop all sounds for the given cell.