Remove the Play_Single flag. It's not correct.

This commit is contained in:
Chris Robinson 2012-03-31 07:41:26 -07:00
parent ae308b9b5f
commit 977e7ac9a3
3 changed files with 4 additions and 42 deletions

View file

@ -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);
}
};

View file

@ -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();

View file

@ -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<SoundPtr,PtrIDPair> SoundMap;
SoundMap mActiveSounds;
typedef std::map<std::string,SoundPtr> IDSoundMap;
IDSoundMap mSingleSounds;
std::string lookup(const std::string &soundId,
float &volume, float &min, float &max);
void streamMusicFull(const std::string& filename);