1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 19:19:56 +00:00

Catch exceptions inside the loadVoice() (bug #4685)

This commit is contained in:
Andrei Kortunov 2018-10-18 14:59:39 +04:00
parent e406c5ff81
commit 8fa0ffcfe4
3 changed files with 27 additions and 12 deletions

View file

@ -142,6 +142,7 @@
Bug #4674: Journal can be opened when settings window is open
Bug #4677: Crash in ESM reader when NPC record has DNAM record without DODT one
Bug #4678: Crash in ESP parser when SCVR has no variable names
Bug #4685: Missing sound causes an exception inside Say command
Feature #912: Editor: Add missing icons to UniversalId tables
Feature #1221: Editor: Creature/NPC rendering
Feature #1617: Editor: Enchantment effect record verifier

View file

@ -244,8 +244,11 @@ namespace MWSound
}
DecoderPtr SoundManager::loadVoice(const std::string &voicefile)
{
try
{
DecoderPtr decoder = getDecoder();
// Workaround: Bethesda at some point converted some of the files to mp3, but the references were kept as .wav.
if(mVFS->exists(voicefile))
decoder->open(voicefile);
@ -260,6 +263,13 @@ namespace MWSound
return decoder;
}
catch(std::exception &e)
{
Log(Debug::Error) << "Failed to load audio from " << voicefile << ": " << e.what();
}
return nullptr;
}
Sound *SoundManager::getSoundRef()
{
@ -471,6 +481,8 @@ namespace MWSound
mVFS->normalizeFilename(voicefile);
DecoderPtr decoder = loadVoice(voicefile);
if (!decoder)
return;
MWBase::World *world = MWBase::Environment::get().getWorld();
const osg::Vec3f pos = world->getActorHeadTransform(ptr).getTrans();
@ -503,6 +515,8 @@ namespace MWSound
mVFS->normalizeFilename(voicefile);
DecoderPtr decoder = loadVoice(voicefile);
if (!decoder)
return;
stopSay(MWWorld::ConstPtr());
Stream *sound = playVoice(decoder, osg::Vec3f(), true);

View file

@ -117,7 +117,7 @@ namespace MWSound
Sound_Buffer *lookupSound(const std::string &soundId) const;
Sound_Buffer *loadSound(const std::string &soundId);
// returns a decoder to start streaming
// returns a decoder to start streaming, or nullptr if the sound was not found
DecoderPtr loadVoice(const std::string &voicefile);
Sound *getSoundRef();