mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
Use an empty MWWorld::Ptr object for non-3D sounds
This commit is contained in:
parent
7b3ecc290e
commit
0d552c10bc
2 changed files with 12 additions and 18 deletions
|
@ -69,7 +69,6 @@ namespace MWSound
|
|||
|
||||
SoundManager::~SoundManager()
|
||||
{
|
||||
mLooseSounds.clear();
|
||||
mActiveSounds.clear();
|
||||
mMusic.reset();
|
||||
mOutput.reset();
|
||||
|
@ -207,7 +206,7 @@ namespace MWSound
|
|||
{
|
||||
std::string file = lookup(soundId, volume, min, max);
|
||||
Sound *sound = mOutput->playSound(file, volume, pitch, loop);
|
||||
mLooseSounds[soundId] = SoundPtr(sound);
|
||||
mActiveSounds[MWWorld::Ptr()][soundId] = SoundPtr(sound);
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
|
@ -226,8 +225,7 @@ namespace MWSound
|
|||
std::string file = lookup(soundId, volume, min, max);
|
||||
|
||||
SoundPtr sound(mOutput->playSound3D(file, pos.pos, volume, pitch, min, max, loop));
|
||||
if(untracked) mLooseSounds[soundId] = sound;
|
||||
else mActiveSounds[ptr][soundId] = sound;
|
||||
mActiveSounds[untracked?MWWorld::Ptr():ptr][soundId] = sound;
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
|
@ -272,7 +270,7 @@ namespace MWSound
|
|||
SoundMap::iterator snditer = mActiveSounds.begin();
|
||||
while(snditer != mActiveSounds.end())
|
||||
{
|
||||
if(snditer->first.getCell() == cell)
|
||||
if(snditer->first != MWWorld::Ptr() && snditer->first.getCell() == cell)
|
||||
{
|
||||
IDMap::iterator iditer = snditer->second.begin();
|
||||
while(iditer != snditer->second.end())
|
||||
|
@ -289,11 +287,17 @@ namespace MWSound
|
|||
|
||||
void SoundManager::stopSound(const std::string& soundId)
|
||||
{
|
||||
IDMap::iterator iditer = mLooseSounds.find(soundId);
|
||||
if(iditer != mLooseSounds.end())
|
||||
SoundMap::iterator snditer = mActiveSounds.find(MWWorld::Ptr());
|
||||
if(snditer == mActiveSounds.end())
|
||||
return;
|
||||
|
||||
IDMap::iterator iditer = snditer->second.find(soundId);
|
||||
if(iditer != snditer->second.end())
|
||||
{
|
||||
iditer->second->stop();
|
||||
mLooseSounds.erase(iditer);
|
||||
snditer->second.erase(iditer);
|
||||
if(snditer->second.empty())
|
||||
mActiveSounds.erase(snditer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -415,15 +419,6 @@ namespace MWSound
|
|||
else
|
||||
snditer++;
|
||||
}
|
||||
|
||||
IDMap::iterator iditer = mLooseSounds.begin();
|
||||
while(iditer != mLooseSounds.end())
|
||||
{
|
||||
if(!iditer->second->isPlaying())
|
||||
mLooseSounds.erase(iditer++);
|
||||
else
|
||||
iditer++;
|
||||
}
|
||||
}
|
||||
|
||||
void SoundManager::update(float duration)
|
||||
|
|
|
@ -44,7 +44,6 @@ namespace MWSound
|
|||
typedef std::map<std::string,SoundPtr> IDMap;
|
||||
typedef std::map<MWWorld::Ptr,IDMap> SoundMap;
|
||||
SoundMap mActiveSounds;
|
||||
IDMap mLooseSounds;
|
||||
|
||||
std::string lookup(const std::string &soundId,
|
||||
float &volume, float &min, float &max);
|
||||
|
|
Loading…
Reference in a new issue