From 8e6cd813337ca4ec7ba5124b361583219c151b90 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Fri, 26 Jan 2007 19:00:41 +0000 Subject: - Just warn, don't die, when a CD-Track isn't found - Before using _vm->_adlib, first check whether it's actually there svn-id: r25205 --- engines/gob/cdrom.cpp | 2 +- engines/gob/game.cpp | 2 +- engines/gob/game_v1.cpp | 7 ++++--- engines/gob/game_v2.cpp | 7 ++++--- engines/gob/inter_v1.cpp | 24 ++++++++++++++---------- engines/gob/inter_v2.cpp | 10 ++++++---- engines/gob/music.cpp | 2 +- 7 files changed, 31 insertions(+), 23 deletions(-) (limited to 'engines') diff --git a/engines/gob/cdrom.cpp b/engines/gob/cdrom.cpp index 75e9d7bd66..5e2de01643 100644 --- a/engines/gob/cdrom.cpp +++ b/engines/gob/cdrom.cpp @@ -172,7 +172,7 @@ void CDROM::startTrack(const char *trackname) { } if (!matchPtr) { - error("Track %s not found", trackname); + warning("Track %s not found", trackname); return; } diff --git a/engines/gob/game.cpp b/engines/gob/game.cpp index f96c2e8a45..e569daed53 100644 --- a/engines/gob/game.cpp +++ b/engines/gob/game.cpp @@ -352,7 +352,7 @@ void Game::freeSoundSlot(int16 slot) { return; if (_soundADL[slot]) { - if (_vm->_adlib->getIndex() == slot) + if (_vm->_adlib && (_vm->_adlib->getIndex() == slot)) _vm->_adlib->stopPlay(); if (_soundFromExt[slot] == 1) { delete[] ((char *) _soundSamples[slot]); diff --git a/engines/gob/game_v1.cpp b/engines/gob/game_v1.cpp index 80d6709da9..7c807aef70 100644 --- a/engines/gob/game_v1.cpp +++ b/engines/gob/game_v1.cpp @@ -81,9 +81,10 @@ void Game_v1::playTot(int16 skipPlay) { _vm->_draw->_fontToSprite[i].height = -1; } - if (_vm->_features & GF_MAC) - _vm->_adlib->stopPlay(); - else + if (_vm->_features & GF_MAC) { + if (_vm->_adlib) + _vm->_adlib->stopPlay(); + } else _vm->_cdrom->stopPlaying(); _vm->_draw->animateCursor(4); _vm->_inter->initControlVars(1); diff --git a/engines/gob/game_v2.cpp b/engines/gob/game_v2.cpp index 2ecddfdb70..410ca10cfa 100644 --- a/engines/gob/game_v2.cpp +++ b/engines/gob/game_v2.cpp @@ -73,9 +73,10 @@ void Game_v2::playTot(int16 skipPlay) { while (!_vm->_quitRequested) { if (_vm->_global->_inter_variables != 0) _vm->_draw->animateCursor(4); - if (_vm->_features & GF_MAC) - _vm->_adlib->stopPlay(); - else + if (_vm->_features & GF_MAC) { + if (_vm->_adlib) + _vm->_adlib->stopPlay(); + } else _vm->_cdrom->stopPlaying(); if (skipPlay != -1) { diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp index 5a9862157f..408dcd481c 100644 --- a/engines/gob/inter_v1.cpp +++ b/engines/gob/inter_v1.cpp @@ -1210,7 +1210,8 @@ bool Inter_v1::o1_playComposition(char &cmdCount, int16 &counter, int16 &retFlag } bool Inter_v1::o1_stopSound(char &cmdCount, int16 &counter, int16 &retFlag) { - _vm->_adlib->stopPlay(); + if (_vm->_adlib) + _vm->_adlib->stopPlay(); _vm->_snd->stopSound(_vm->_parse->parseValExpr()); _soundEndTimeKey = 0; return false; @@ -1640,9 +1641,10 @@ void Inter_v1::o1_loadCurLayer(void) { void Inter_v1::o1_playCDTrack(void) { evalExpr(0); - if (_vm->_features & GF_MAC) - _vm->_adlib->playTrack(_vm->_global->_inter_resStr); - else + if (_vm->_features & GF_MAC) { + if (_vm->_adlib) + _vm->_adlib->playTrack(_vm->_global->_inter_resStr); + } else // Used in gob1 CD _vm->_cdrom->startTrack(_vm->_global->_inter_resStr); } @@ -1663,9 +1665,10 @@ void Inter_v1::o1_getCDTrackPos(void) { } void Inter_v1::o1_stopCD(void) { - if (_vm->_features & GF_MAC) - _vm->_adlib->stopPlay(); - else + if (_vm->_features & GF_MAC) { + if (_vm->_adlib) + _vm->_adlib->stopPlay(); + } else // Used in gob1 CD _vm->_cdrom->stopPlaying(); } @@ -2587,9 +2590,10 @@ void Inter_v1::o1_animateObjects(int16 &extraData, int32 *retVarPtr, Goblin::Gob void Inter_v1::o1_drawObjects(int16 &extraData, int32 *retVarPtr, Goblin::Gob_Object *objDesc) { _vm->_goblin->drawObjects(); - if (_vm->_features & GF_MAC) - _vm->_adlib->playBgMusic(); - else if (_vm->_cdrom->getTrackPos() == -1) + if (_vm->_features & GF_MAC) { + if (_vm->_adlib) + _vm->_adlib->playBgMusic(); + } else if (_vm->_cdrom->getTrackPos() == -1) _vm->_cdrom->playBgMusic(); } diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp index f134d91fa6..fd21e6e12f 100644 --- a/engines/gob/inter_v2.cpp +++ b/engines/gob/inter_v2.cpp @@ -1601,10 +1601,12 @@ bool Inter_v2::o2_playSound(char &cmdCount, int16 &counter, int16 &retFlag) { _vm->_game->_soundSamples[index]->size / 2) * 1000) / freq2; } // loc_E2F3 - if (_vm->_game->_soundTypes[index] & 8) { - _vm->_adlib->load((byte *) _vm->_game->_soundSamples[index], index); - _vm->_adlib->setRepeating(repCount - 1); - _vm->_adlib->startPlay(); + if ((_vm->_game->_soundTypes[index] & 8)) { + if (_vm->_adlib) { + _vm->_adlib->load((byte *) _vm->_game->_soundSamples[index], index); + _vm->_adlib->setRepeating(repCount - 1); + _vm->_adlib->startPlay(); + } } else { _vm->_snd->stopSound(0); _vm->_snd->playSample(_vm->_game->_soundSamples[index], repCount, frequency); diff --git a/engines/gob/music.cpp b/engines/gob/music.cpp index c56cac3764..b074a15602 100644 --- a/engines/gob/music.cpp +++ b/engines/gob/music.cpp @@ -307,7 +307,7 @@ void Adlib::setKey(byte voice, byte note, bool on, bool spec) { _notes[voice] = note; note += _notCol[voice]; - note = MIN(0x5F, (int)note); + note = MIN((byte) 0x5F, note); octa = note / 12; freq = _freqs[_notLin[voice]][note - octa * 12]; -- cgit v1.2.3