From 977e7ac9a3c49a4771c2f8ede2193429399a5ee0 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 31 Mar 2012 07:41:26 -0700 Subject: [PATCH] Remove the Play_Single flag. It's not correct. --- apps/openmw/mwscript/soundextensions.cpp | 4 +-- apps/openmw/mwsound/soundmanager.cpp | 36 ++---------------------- apps/openmw/mwsound/soundmanager.hpp | 6 ---- 3 files changed, 4 insertions(+), 42 deletions(-) diff --git a/apps/openmw/mwscript/soundextensions.cpp b/apps/openmw/mwscript/soundextensions.cpp index 7ae109075..b4386a8a0 100644 --- a/apps/openmw/mwscript/soundextensions.cpp +++ b/apps/openmw/mwscript/soundextensions.cpp @@ -130,7 +130,7 @@ namespace MWScript std::string sound = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - context.getSoundManager().playSound3D (ptr, sound, 1.0, 1.0, MWSound::Play_Single | (mLoop ? MWSound::Play_Loop : 0)); + context.getSoundManager().playSound3D (ptr, sound, 1.0, 1.0, mLoop ? MWSound::Play_Loop : 0); } }; @@ -159,7 +159,7 @@ namespace MWScript Interpreter::Type_Float pitch = runtime[0].mFloat; runtime.pop(); - context.getSoundManager().playSound3D (ptr, sound, volume, pitch, MWSound::Play_Single | (mLoop ? MWSound::Play_Loop : 0)); + context.getSoundManager().playSound3D (ptr, sound, volume, pitch, mLoop ? MWSound::Play_Loop : 0); } }; diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index 2d743d9cb..6249c4e4d 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -67,7 +67,6 @@ namespace MWSound SoundManager::~SoundManager() { - mSingleSounds.clear(); mActiveSounds.clear(); mMusic.reset(); mOutput.reset(); @@ -231,29 +230,15 @@ namespace MWSound SoundPtr SoundManager::playSound3D(MWWorld::Ptr ptr, const std::string& soundId, float volume, float pitch, int mode) { - const ESM::Position &pos = ptr.getCellRef().pos; - const Ogre::Vector3 objpos(pos.pos[0], pos.pos[1], pos.pos[2]); SoundPtr sound; - - if((mode&Play_Single)) - { - IDSoundMap::iterator inviter = mSingleSounds.find(soundId); - if(inviter != mSingleSounds.end()) - { - if(inviter->second->mPos.squaredDistance(mOutput->mPos) < - objpos.squaredDistance(mOutput->mPos)) - return sound; - inviter->second->stop(); - mSingleSounds.erase(inviter); - } - } - try { // Look up the sound in the ESM data float basevol = 1.0f; /* TODO: volume settings */ float min, max; std::string file = lookup(soundId, basevol, min, max); + const ESM::Position &pos = ptr.getCellRef().pos; + const Ogre::Vector3 objpos(pos.pos[0], pos.pos[1], pos.pos[2]); sound = mOutput->playSound3D(file, objpos, volume*basevol, pitch, min, max, mode&Play_Loop); sound->mPos = objpos; @@ -265,10 +250,7 @@ namespace MWSound if((mode&Play_NoTrack)) mActiveSounds[sound] = std::make_pair(MWWorld::Ptr(), soundId); else - { mActiveSounds[sound] = std::make_pair(ptr, soundId); - mSingleSounds[soundId] = sound; - } } catch(std::exception &e) { @@ -284,9 +266,6 @@ namespace MWSound { if(snditer->second.first == ptr && snditer->second.second == soundId) { - IDSoundMap::iterator inviter = mSingleSounds.find(snditer->second.second); - if(inviter != mSingleSounds.end() && inviter->second == snditer->first) - mSingleSounds.erase(inviter); snditer->first->stop(); mActiveSounds.erase(snditer++); } @@ -302,9 +281,6 @@ namespace MWSound { if(snditer->second.first == ptr) { - IDSoundMap::iterator inviter = mSingleSounds.find(snditer->second.second); - if(inviter != mSingleSounds.end() && inviter->second == snditer->first) - mSingleSounds.erase(inviter); snditer->first->stop(); mActiveSounds.erase(snditer++); } @@ -321,9 +297,6 @@ namespace MWSound if(snditer->second.first != MWWorld::Ptr() && snditer->second.first.getCell() == cell) { - IDSoundMap::iterator inviter = mSingleSounds.find(snditer->second.second); - if(inviter != mSingleSounds.end() && inviter->second == snditer->first) - mSingleSounds.erase(inviter); snditer->first->stop(); mActiveSounds.erase(snditer++); } @@ -452,12 +425,7 @@ namespace MWSound while(snditer != mActiveSounds.end()) { if(!snditer->first->isPlaying()) - { - IDSoundMap::iterator inviter = mSingleSounds.find(snditer->second.second); - if(inviter != mSingleSounds.end() && inviter->second == snditer->first) - mSingleSounds.erase(inviter); mActiveSounds.erase(snditer++); - } else { snditer->first->update(); diff --git a/apps/openmw/mwsound/soundmanager.hpp b/apps/openmw/mwsound/soundmanager.hpp index 03cacca23..de5cca839 100644 --- a/apps/openmw/mwsound/soundmanager.hpp +++ b/apps/openmw/mwsound/soundmanager.hpp @@ -37,9 +37,6 @@ namespace MWSound Play_NoTrack = 1<<2, /* (3D only) Play the sound at the given object's position * but do not keep it updated (the sound will not move with * the object and will not stop when the object is deleted. */ - Play_Single = 1<<3, /* (3D only) Play only a single instance of the given sound id. - * Sounds not marked as Single will not count, and all but the - * closest to the listener's position will be stopped. */ }; static inline int operator|(const PlayMode &a, const PlayMode &b) { return (int)a | (int)b; } @@ -61,9 +58,6 @@ namespace MWSound typedef std::map SoundMap; SoundMap mActiveSounds; - typedef std::map IDSoundMap; - IDSoundMap mSingleSounds; - std::string lookup(const std::string &soundId, float &volume, float &min, float &max); void streamMusicFull(const std::string& filename);