forked from teamnwah/openmw-tes3coop
Split stopSound3D into separate functions to deal with stopping all sounds on an object
This commit is contained in:
parent
033faba9c4
commit
f0db2ab82f
2 changed files with 21 additions and 24 deletions
|
@ -231,36 +231,31 @@ namespace MWSound
|
||||||
|
|
||||||
void SoundManager::stopSound3D(MWWorld::Ptr ptr, const std::string& soundId)
|
void SoundManager::stopSound3D(MWWorld::Ptr ptr, const std::string& soundId)
|
||||||
{
|
{
|
||||||
// Stop a sound and remove it from the list. If soundId="" then
|
SoundMap::iterator snditer = mActiveSounds.find(std::make_pair(ptr, soundId));
|
||||||
// stop all its sounds.
|
if(snditer == mActiveSounds.end())
|
||||||
if(!soundId.empty())
|
return;
|
||||||
{
|
|
||||||
SoundMap::iterator snditer = mActiveSounds.find(std::make_pair(ptr, soundId));
|
|
||||||
if(snditer == mActiveSounds.end())
|
|
||||||
return;
|
|
||||||
|
|
||||||
snditer->second->stop();
|
snditer->second->stop();
|
||||||
mActiveSounds.erase(snditer);
|
mActiveSounds.erase(snditer);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
void SoundManager::stopSound3D(MWWorld::Ptr ptr)
|
||||||
|
{
|
||||||
|
SoundMap::iterator snditer = mActiveSounds.begin();
|
||||||
|
while(snditer != mActiveSounds.end())
|
||||||
{
|
{
|
||||||
SoundMap::iterator snditer = mActiveSounds.begin();
|
if(snditer->first.first == ptr)
|
||||||
while(snditer != mActiveSounds.end())
|
|
||||||
{
|
{
|
||||||
if(snditer->first.first == ptr)
|
snditer->second->stop();
|
||||||
{
|
mActiveSounds.erase(snditer++);
|
||||||
snditer->second->stop();
|
|
||||||
mActiveSounds.erase(snditer++);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
snditer++;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
snditer++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundManager::stopSound(const MWWorld::Ptr::CellStore *cell)
|
void SoundManager::stopSound(const MWWorld::Ptr::CellStore *cell)
|
||||||
{
|
{
|
||||||
// Remove all references to objects belonging to a given cell
|
|
||||||
SoundMap::iterator snditer = mActiveSounds.begin();
|
SoundMap::iterator snditer = mActiveSounds.begin();
|
||||||
while(snditer != mActiveSounds.end())
|
while(snditer != mActiveSounds.end())
|
||||||
{
|
{
|
||||||
|
|
|
@ -95,9 +95,11 @@ namespace MWSound
|
||||||
bool untracked=false);
|
bool untracked=false);
|
||||||
///< Play a sound from an object
|
///< Play a sound from an object
|
||||||
|
|
||||||
void stopSound3D(MWWorld::Ptr reference, const std::string& soundId="");
|
void stopSound3D(MWWorld::Ptr reference, const std::string& soundId);
|
||||||
///< Stop the given object from playing the given sound, If no soundId is given,
|
///< Stop the given object from playing the given sound,
|
||||||
/// all sounds for this reference will stop.
|
|
||||||
|
void stopSound3D(MWWorld::Ptr reference);
|
||||||
|
///< Stop the given object from playing all sounds.
|
||||||
|
|
||||||
void stopSound(const MWWorld::Ptr::CellStore *cell);
|
void stopSound(const MWWorld::Ptr::CellStore *cell);
|
||||||
///< Stop all sounds for the given cell.
|
///< Stop all sounds for the given cell.
|
||||||
|
|
Loading…
Reference in a new issue