1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-27 05:10:26 +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 #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 #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 #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 #912: Editor: Add missing icons to UniversalId tables
Feature #1221: Editor: Creature/NPC rendering Feature #1221: Editor: Creature/NPC rendering
Feature #1617: Editor: Enchantment effect record verifier Feature #1617: Editor: Enchantment effect record verifier

View file

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