Make SayDone return 1 on the frame speech is started (bug #4879)

pull/2398/head
Capostrophic 6 years ago
parent e0fb411fc8
commit 4c2b694b29

@ -58,6 +58,7 @@
Bug #4867: Arbitrary text after local variable declarations breaks script compilation Bug #4867: Arbitrary text after local variable declarations breaks script compilation
Bug #4876: AI ratings handling inconsistencies Bug #4876: AI ratings handling inconsistencies
Bug #4877: Startup script executes only on a new game start Bug #4877: Startup script executes only on a new game start
Bug #4879: SayDone returns 0 on the frame Say is called
Bug #4888: Global variable stray explicit reference calls break script compilation Bug #4888: Global variable stray explicit reference calls break script compilation
Bug #4896: Title screen music doesn't loop Bug #4896: Title screen music doesn't loop
Bug #4902: Using scrollbars in settings causes resolution to change Bug #4902: Using scrollbars in settings causes resolution to change

@ -520,7 +520,7 @@ namespace MWSound
Stream *sound = playVoice(decoder, pos, (ptr == MWMechanics::getPlayer())); Stream *sound = playVoice(decoder, pos, (ptr == MWMechanics::getPlayer()));
if(!sound) return; if(!sound) return;
mActiveSaySounds.insert(std::make_pair(ptr, sound)); mSaySoundsQueue.emplace(ptr, sound);
} }
float SoundManager::getSaySoundLoudness(const MWWorld::ConstPtr &ptr) const float SoundManager::getSaySoundLoudness(const MWWorld::ConstPtr &ptr) const
@ -568,7 +568,15 @@ namespace MWSound
void SoundManager::stopSay(const MWWorld::ConstPtr &ptr) void SoundManager::stopSay(const MWWorld::ConstPtr &ptr)
{ {
SaySoundMap::iterator snditer = mActiveSaySounds.find(ptr); SaySoundMap::iterator snditer = mSaySoundsQueue.find(ptr);
if(snditer != mSaySoundsQueue.end())
{
mOutput->finishStream(snditer->second);
mUnusedStreams.push_back(snditer->second);
mSaySoundsQueue.erase(snditer);
}
snditer = mActiveSaySounds.find(ptr);
if(snditer != mActiveSaySounds.end()) if(snditer != mActiveSaySounds.end())
{ {
mOutput->finishStream(snditer->second); mOutput->finishStream(snditer->second);
@ -1068,8 +1076,15 @@ namespace MWSound
++snditer; ++snditer;
} }
SaySoundMap::iterator sayiter = mActiveSaySounds.begin(); SaySoundMap::iterator sayiter = mSaySoundsQueue.begin();
while(sayiter != mActiveSaySounds.end()) while (sayiter != mSaySoundsQueue.end())
{
mActiveSaySounds[sayiter->first] = sayiter->second;
mSaySoundsQueue.erase(sayiter++);
}
sayiter = mActiveSaySounds.begin();
while (sayiter != mActiveSaySounds.end())
{ {
MWWorld::ConstPtr ptr = sayiter->first; MWWorld::ConstPtr ptr = sayiter->first;
Stream *sound = sayiter->second; Stream *sound = sayiter->second;
@ -1187,6 +1202,12 @@ namespace MWSound
sound->setBaseVolume(volumeFromType(sound->getPlayType())); sound->setBaseVolume(volumeFromType(sound->getPlayType()));
mOutput->updateStream(sound); mOutput->updateStream(sound);
} }
for(SaySoundMap::value_type &snd : mSaySoundsQueue)
{
Stream *sound = snd.second;
sound->setBaseVolume(volumeFromType(sound->getPlayType()));
mOutput->updateStream(sound);
}
for(Stream *sound : mActiveTracks) for(Stream *sound : mActiveTracks)
{ {
sound->setBaseVolume(volumeFromType(sound->getPlayType())); sound->setBaseVolume(volumeFromType(sound->getPlayType()));
@ -1218,7 +1239,16 @@ namespace MWSound
mActiveSounds.erase(snditer); mActiveSounds.erase(snditer);
mActiveSounds.emplace(updated, std::move(sndlist)); mActiveSounds.emplace(updated, std::move(sndlist));
} }
SaySoundMap::iterator sayiter = mActiveSaySounds.find(old);
SaySoundMap::iterator sayiter = mSaySoundsQueue.find(old);
if(sayiter != mSaySoundsQueue.end())
{
Stream *stream = sayiter->second;
mSaySoundsQueue.erase(sayiter);
mSaySoundsQueue.emplace(updated, stream);
}
sayiter = mActiveSaySounds.find(old);
if(sayiter != mActiveSaySounds.end()) if(sayiter != mActiveSaySounds.end())
{ {
Stream *stream = sayiter->second; Stream *stream = sayiter->second;
@ -1311,6 +1341,13 @@ namespace MWSound
mUnderwaterSound = nullptr; mUnderwaterSound = nullptr;
mNearWaterSound = nullptr; mNearWaterSound = nullptr;
for(SaySoundMap::value_type &snd : mSaySoundsQueue)
{
mOutput->finishStream(snd.second);
mUnusedStreams.push_back(snd.second);
}
mSaySoundsQueue.clear();
for(SaySoundMap::value_type &snd : mActiveSaySounds) for(SaySoundMap::value_type &snd : mActiveSaySounds)
{ {
mOutput->finishStream(snd.second); mOutput->finishStream(snd.second);

@ -93,6 +93,7 @@ namespace MWSound
SoundMap mActiveSounds; SoundMap mActiveSounds;
typedef std::map<MWWorld::ConstPtr,Stream*> SaySoundMap; typedef std::map<MWWorld::ConstPtr,Stream*> SaySoundMap;
SaySoundMap mSaySoundsQueue;
SaySoundMap mActiveSaySounds; SaySoundMap mActiveSaySounds;
typedef std::vector<Stream*> TrackList; typedef std::vector<Stream*> TrackList;

Loading…
Cancel
Save