forked from mirror/openmw-tes3mp
Remove the Play_Single flag. It's not correct.
This commit is contained in:
parent
ae308b9b5f
commit
977e7ac9a3
3 changed files with 4 additions and 42 deletions
|
@ -130,7 +130,7 @@ namespace MWScript
|
||||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
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;
|
Interpreter::Type_Float pitch = runtime[0].mFloat;
|
||||||
runtime.pop();
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -67,7 +67,6 @@ namespace MWSound
|
||||||
|
|
||||||
SoundManager::~SoundManager()
|
SoundManager::~SoundManager()
|
||||||
{
|
{
|
||||||
mSingleSounds.clear();
|
|
||||||
mActiveSounds.clear();
|
mActiveSounds.clear();
|
||||||
mMusic.reset();
|
mMusic.reset();
|
||||||
mOutput.reset();
|
mOutput.reset();
|
||||||
|
@ -231,29 +230,15 @@ namespace MWSound
|
||||||
SoundPtr SoundManager::playSound3D(MWWorld::Ptr ptr, const std::string& soundId,
|
SoundPtr SoundManager::playSound3D(MWWorld::Ptr ptr, const std::string& soundId,
|
||||||
float volume, float pitch, int mode)
|
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;
|
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
|
try
|
||||||
{
|
{
|
||||||
// Look up the sound in the ESM data
|
// Look up the sound in the ESM data
|
||||||
float basevol = 1.0f; /* TODO: volume settings */
|
float basevol = 1.0f; /* TODO: volume settings */
|
||||||
float min, max;
|
float min, max;
|
||||||
std::string file = lookup(soundId, basevol, 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 = mOutput->playSound3D(file, objpos, volume*basevol, pitch, min, max, mode&Play_Loop);
|
||||||
sound->mPos = objpos;
|
sound->mPos = objpos;
|
||||||
|
@ -265,10 +250,7 @@ namespace MWSound
|
||||||
if((mode&Play_NoTrack))
|
if((mode&Play_NoTrack))
|
||||||
mActiveSounds[sound] = std::make_pair(MWWorld::Ptr(), soundId);
|
mActiveSounds[sound] = std::make_pair(MWWorld::Ptr(), soundId);
|
||||||
else
|
else
|
||||||
{
|
|
||||||
mActiveSounds[sound] = std::make_pair(ptr, soundId);
|
mActiveSounds[sound] = std::make_pair(ptr, soundId);
|
||||||
mSingleSounds[soundId] = sound;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
|
@ -284,9 +266,6 @@ namespace MWSound
|
||||||
{
|
{
|
||||||
if(snditer->second.first == ptr && snditer->second.second == soundId)
|
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();
|
snditer->first->stop();
|
||||||
mActiveSounds.erase(snditer++);
|
mActiveSounds.erase(snditer++);
|
||||||
}
|
}
|
||||||
|
@ -302,9 +281,6 @@ namespace MWSound
|
||||||
{
|
{
|
||||||
if(snditer->second.first == ptr)
|
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();
|
snditer->first->stop();
|
||||||
mActiveSounds.erase(snditer++);
|
mActiveSounds.erase(snditer++);
|
||||||
}
|
}
|
||||||
|
@ -321,9 +297,6 @@ namespace MWSound
|
||||||
if(snditer->second.first != MWWorld::Ptr() &&
|
if(snditer->second.first != MWWorld::Ptr() &&
|
||||||
snditer->second.first.getCell() == cell)
|
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();
|
snditer->first->stop();
|
||||||
mActiveSounds.erase(snditer++);
|
mActiveSounds.erase(snditer++);
|
||||||
}
|
}
|
||||||
|
@ -452,12 +425,7 @@ namespace MWSound
|
||||||
while(snditer != mActiveSounds.end())
|
while(snditer != mActiveSounds.end())
|
||||||
{
|
{
|
||||||
if(!snditer->first->isPlaying())
|
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++);
|
mActiveSounds.erase(snditer++);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
snditer->first->update();
|
snditer->first->update();
|
||||||
|
|
|
@ -37,9 +37,6 @@ namespace MWSound
|
||||||
Play_NoTrack = 1<<2, /* (3D only) Play the sound at the given object's position
|
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
|
* but do not keep it updated (the sound will not move with
|
||||||
* the object and will not stop when the object is deleted. */
|
* 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)
|
static inline int operator|(const PlayMode &a, const PlayMode &b)
|
||||||
{ return (int)a | (int)b; }
|
{ return (int)a | (int)b; }
|
||||||
|
@ -61,9 +58,6 @@ namespace MWSound
|
||||||
typedef std::map<SoundPtr,PtrIDPair> SoundMap;
|
typedef std::map<SoundPtr,PtrIDPair> SoundMap;
|
||||||
SoundMap mActiveSounds;
|
SoundMap mActiveSounds;
|
||||||
|
|
||||||
typedef std::map<std::string,SoundPtr> IDSoundMap;
|
|
||||||
IDSoundMap mSingleSounds;
|
|
||||||
|
|
||||||
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);
|
||||||
void streamMusicFull(const std::string& filename);
|
void streamMusicFull(const std::string& filename);
|
||||||
|
|
Loading…
Reference in a new issue