mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-03 16:45:34 +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()
|
SoundManager::~SoundManager()
|
||||||
{
|
{
|
||||||
mLooseSounds.clear();
|
|
||||||
mActiveSounds.clear();
|
mActiveSounds.clear();
|
||||||
mMusic.reset();
|
mMusic.reset();
|
||||||
mOutput.reset();
|
mOutput.reset();
|
||||||
|
@ -207,7 +206,7 @@ namespace MWSound
|
||||||
{
|
{
|
||||||
std::string file = lookup(soundId, volume, min, max);
|
std::string file = lookup(soundId, volume, min, max);
|
||||||
Sound *sound = mOutput->playSound(file, volume, pitch, loop);
|
Sound *sound = mOutput->playSound(file, volume, pitch, loop);
|
||||||
mLooseSounds[soundId] = SoundPtr(sound);
|
mActiveSounds[MWWorld::Ptr()][soundId] = SoundPtr(sound);
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
|
@ -226,8 +225,7 @@ namespace MWSound
|
||||||
std::string file = lookup(soundId, volume, min, max);
|
std::string file = lookup(soundId, volume, min, max);
|
||||||
|
|
||||||
SoundPtr sound(mOutput->playSound3D(file, pos.pos, volume, pitch, min, max, loop));
|
SoundPtr sound(mOutput->playSound3D(file, pos.pos, volume, pitch, min, max, loop));
|
||||||
if(untracked) mLooseSounds[soundId] = sound;
|
mActiveSounds[untracked?MWWorld::Ptr():ptr][soundId] = sound;
|
||||||
else mActiveSounds[ptr][soundId] = sound;
|
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
|
@ -272,7 +270,7 @@ namespace MWSound
|
||||||
SoundMap::iterator snditer = mActiveSounds.begin();
|
SoundMap::iterator snditer = mActiveSounds.begin();
|
||||||
while(snditer != mActiveSounds.end())
|
while(snditer != mActiveSounds.end())
|
||||||
{
|
{
|
||||||
if(snditer->first.getCell() == cell)
|
if(snditer->first != MWWorld::Ptr() && snditer->first.getCell() == cell)
|
||||||
{
|
{
|
||||||
IDMap::iterator iditer = snditer->second.begin();
|
IDMap::iterator iditer = snditer->second.begin();
|
||||||
while(iditer != snditer->second.end())
|
while(iditer != snditer->second.end())
|
||||||
|
@ -289,11 +287,17 @@ namespace MWSound
|
||||||
|
|
||||||
void SoundManager::stopSound(const std::string& soundId)
|
void SoundManager::stopSound(const std::string& soundId)
|
||||||
{
|
{
|
||||||
IDMap::iterator iditer = mLooseSounds.find(soundId);
|
SoundMap::iterator snditer = mActiveSounds.find(MWWorld::Ptr());
|
||||||
if(iditer != mLooseSounds.end())
|
if(snditer == mActiveSounds.end())
|
||||||
|
return;
|
||||||
|
|
||||||
|
IDMap::iterator iditer = snditer->second.find(soundId);
|
||||||
|
if(iditer != snditer->second.end())
|
||||||
{
|
{
|
||||||
iditer->second->stop();
|
iditer->second->stop();
|
||||||
mLooseSounds.erase(iditer);
|
snditer->second.erase(iditer);
|
||||||
|
if(snditer->second.empty())
|
||||||
|
mActiveSounds.erase(snditer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,15 +419,6 @@ namespace MWSound
|
||||||
else
|
else
|
||||||
snditer++;
|
snditer++;
|
||||||
}
|
}
|
||||||
|
|
||||||
IDMap::iterator iditer = mLooseSounds.begin();
|
|
||||||
while(iditer != mLooseSounds.end())
|
|
||||||
{
|
|
||||||
if(!iditer->second->isPlaying())
|
|
||||||
mLooseSounds.erase(iditer++);
|
|
||||||
else
|
|
||||||
iditer++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundManager::update(float duration)
|
void SoundManager::update(float duration)
|
||||||
|
|
|
@ -44,7 +44,6 @@ namespace MWSound
|
||||||
typedef std::map<std::string,SoundPtr> IDMap;
|
typedef std::map<std::string,SoundPtr> IDMap;
|
||||||
typedef std::map<MWWorld::Ptr,IDMap> SoundMap;
|
typedef std::map<MWWorld::Ptr,IDMap> SoundMap;
|
||||||
SoundMap mActiveSounds;
|
SoundMap mActiveSounds;
|
||||||
IDMap mLooseSounds;
|
|
||||||
|
|
||||||
std::string lookup(const std::string &soundId,
|
std::string lookup(const std::string &soundId,
|
||||||
float &volume, float &min, float &max);
|
float &volume, float &min, float &max);
|
||||||
|
|
Loading…
Reference in a new issue