Properly update the near water sound volume

This commit is contained in:
Chris Robinson 2017-09-12 17:00:39 -07:00
parent 0b720cd90c
commit 033303b911

View file

@ -931,25 +931,28 @@ namespace MWSound
mOutput->finishSound(mNearWaterSound); mOutput->finishSound(mNearWaterSound);
mNearWaterSound = nullptr; mNearWaterSound = nullptr;
} }
else if(LastCell != curcell) else
{ {
bool soundIdChanged = false; bool soundIdChanged = false;
Sound_Buffer* sfx = lookupSound(soundId); Sound_Buffer *sfx = lookupSound(soundId);
SoundMap::const_iterator snditer = mActiveSounds.find(MWWorld::Ptr()); if(LastCell != curcell)
if(snditer != mActiveSounds.end())
{ {
SoundBufferRefPairList::const_iterator pairiter = std::find_if( LastCell = curcell;
snditer->second.begin(), snditer->second.end(), SoundMap::const_iterator snditer = mActiveSounds.find(MWWorld::Ptr());
[this](const SoundBufferRefPairList::value_type &item) -> bool if(snditer != mActiveSounds.end())
{ return mNearWaterSound == item.first; } {
); SoundBufferRefPairList::const_iterator pairiter = std::find_if(
if (pairiter != snditer->second.end() && pairiter->second != sfx) snditer->second.begin(), snditer->second.end(),
soundIdChanged = true; [this](const SoundBufferRefPairList::value_type &item) -> bool
{ return mNearWaterSound == item.first; }
);
if (pairiter != snditer->second.end() && pairiter->second != sfx)
soundIdChanged = true;
}
} }
LastCell = curcell; if(soundIdChanged)
if (soundIdChanged)
{ {
mOutput->finishSound(mNearWaterSound); mOutput->finishSound(mNearWaterSound);
mNearWaterSound = playSound(soundId, volume, 1.0f, Play_TypeSfx, Play_Loop); mNearWaterSound = playSound(soundId, volume, 1.0f, Play_TypeSfx, Play_Loop);