From fe8ec2ef105a1bfa05742acd5491580d81bd7fdb Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Fri, 6 Jun 2008 06:58:37 +0000 Subject: Only try to play a sound file if the file could be found. (Otherwise, it looks like it will try to use the most recently opened file, which is probably not a sound at all.) svn-id: r32568 --- engines/drascula/drascula.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index f9ca3b4aa6..223877389f 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -1796,6 +1796,7 @@ void DrasculaEngine::centerText(const char *message, int textX, int textY) { void DrasculaEngine::playSound(int soundNum) { char file[20]; + printf("playSound(%d)\n", soundNum); sprintf(file, "s%i.als", soundNum); playFile(file); @@ -3346,16 +3347,17 @@ void DrasculaEngine::MusicFadeout() { } void DrasculaEngine::playFile(const char *fname) { - _arj.open(fname); - - int soundSize = _arj.size(); - byte *soundData = (byte *)malloc(soundSize); - _arj.seek(32); - _arj.read(soundData, soundSize); - _arj.close(); + if (_arj.open(fname)) { + int soundSize = _arj.size(); + byte *soundData = (byte *)malloc(soundSize); + _arj.seek(32); + _arj.read(soundData, soundSize); + _arj.close(); - _mixer->playRaw(Audio::Mixer::kSFXSoundType, &_soundHandle, soundData, soundSize - 64, - 11025, Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_UNSIGNED); + _mixer->playRaw(Audio::Mixer::kSFXSoundType, &_soundHandle, soundData, soundSize - 64, + 11025, Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_UNSIGNED); + } else + warning("playFile: Could not open %s", fname); } bool DrasculaEngine::soundIsActive() { -- cgit v1.2.3