Split stopSound3D into separate functions to deal with stopping all sounds on an object

actorid
Chris Robinson 13 years ago
parent 033faba9c4
commit f0db2ab82f

@ -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())
{

@ -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.

Loading…
Cancel
Save