From 27d302cdb16c9c94b1613752316a5fa09f811d63 Mon Sep 17 00:00:00 2001 From: urukgit Date: Tue, 19 Nov 2013 18:25:44 +0100 Subject: AVALANCHE: Fix timer. --- engines/avalanche/avalanche.cpp | 3 +-- engines/avalanche/avalanche.h | 3 --- engines/avalanche/avalot.cpp | 1 - engines/avalanche/timer.cpp | 28 +++++++++++++--------------- 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/engines/avalanche/avalanche.cpp b/engines/avalanche/avalanche.cpp index beb6333daa..8b3efe4081 100644 --- a/engines/avalanche/avalanche.cpp +++ b/engines/avalanche/avalanche.cpp @@ -163,7 +163,6 @@ void AvalancheEngine::initVariables() { _takenMushroom = false; _givenPenToAyles = false; _askedDogfoodAboutNim = false; - _ableToAddTimer = false; _spludwickAtHome = false; _passedCwytalotInHerts = false; _lastRoom = _lastRoomNotMap = kRoomDummy; @@ -448,7 +447,7 @@ bool AvalancheEngine::loadGame(const int16 slot) { delete f; _isLoaded = true; - _ableToAddTimer = false; + _seeScroll = true; // This prevents display of the new sprites before the new picture is loaded. if (_holdTheDawn) { diff --git a/engines/avalanche/avalanche.h b/engines/avalanche/avalanche.h index 2734155b7d..fdbc4c7a15 100644 --- a/engines/avalanche/avalanche.h +++ b/engines/avalanche/avalanche.h @@ -264,10 +264,7 @@ public: bool _doingSpriteRun; // Only set to True if we're doing a sprite_run at this moment. This stops the trippancy system from moving any of the sprites. bool _soundFx; - // These two have very similar purpose, but it's crucial not to modify _isLoaded later than the actual loading - // or at the begginning of the game, and _ablteToAddTimer must be modified in addTimer(). bool _isLoaded; // Is it a loaded gamestate? - bool _ableToAddTimer; void callVerb(VerbCode id); void loadRoom(byte num); diff --git a/engines/avalanche/avalot.cpp b/engines/avalanche/avalot.cpp index 87b2b7aef0..7c9699d8e3 100644 --- a/engines/avalanche/avalot.cpp +++ b/engines/avalanche/avalot.cpp @@ -1531,7 +1531,6 @@ void AvalancheEngine::newGame() { _doingSpriteRun = false; _avvyInBed = true; - _ableToAddTimer = true; // Set to false in _vm->loadGame(). _isLoaded = false; enterRoom(kRoomYours, 1); diff --git a/engines/avalanche/timer.cpp b/engines/avalanche/timer.cpp index 93889b76b7..8a4aa1c055 100644 --- a/engines/avalanche/timer.cpp +++ b/engines/avalanche/timer.cpp @@ -43,22 +43,20 @@ Timer::Timer(AvalancheEngine *vm) { * @remarks Originally called 'set_up_timer' */ void Timer::addTimer(int32 duration, byte action, byte reason) { - if (_vm->_ableToAddTimer) { - byte i = 0; - while ((i < 7) && (_times[i]._timeLeft != 0)) - i++; - - if (i == 7) - return; // Oh dear... No timer left - - // Everything's OK here! - _times[i]._timeLeft = duration; - _times[i]._action = action; - _times[i]._reason = reason; - } else { - _vm->_ableToAddTimer = true; - return; + byte i = 0; + while ((i < 7) && (_times[i]._timeLeft != 0)) { + if (_times[i]._reason == reason) // We only add a timer if it's not already in the array. + return; + i++; } + + if (i == 7) + return; // Oh dear... No timer left + + // Everything's OK here! + _times[i]._timeLeft = duration; + _times[i]._action = action; + _times[i]._reason = reason; } /** -- cgit v1.2.3