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/timer.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'engines/avalanche/timer.cpp') 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