diff options
Diffstat (limited to 'engines/kyra/timer.cpp')
-rw-r--r-- | engines/kyra/timer.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/engines/kyra/timer.cpp b/engines/kyra/timer.cpp index da7e22f684..88b86393c8 100644 --- a/engines/kyra/timer.cpp +++ b/engines/kyra/timer.cpp @@ -108,6 +108,7 @@ void TimerManager::addTimer(uint8 id, TimerFunc *func, int countdown, bool enabl newTimer.enabled = enabled ? 1 : 0; newTimer.lastUpdate = newTimer.nextRun = 0; newTimer.func = func; + newTimer.pauseStartTime = 0; _timers.push_back(newTimer); } @@ -217,6 +218,28 @@ uint32 TimerManager::getNextRun(uint8 id) const { return 0xFFFFFFFF; } +void TimerManager::pauseSingleTimer(uint8 id, bool p) { + debugC(9, kDebugLevelTimer, "TimerManager::pauseSingleTimer(%d, %d)", id, (int) p); + Iterator timer = Common::find_if(_timers.begin(), _timers.end(), TimerEqual(id)); + + if (timer == _timers.end()) { + warning("TimerManager::pauseSingleTimer: No timer %d", id); + return; + } + + if (p) { + timer->pauseStartTime = _system->getMillis(); + timer->enabled = 0; + } else if (timer->pauseStartTime) { + int32 elapsedTime = _system->getMillis() - timer->pauseStartTime; + timer->enabled = 1; + timer->lastUpdate += elapsedTime; + timer->nextRun += elapsedTime; + resync(); + timer->pauseStartTime = 0; + } +} + bool TimerManager::isEnabled(uint8 id) const { debugC(9, kDebugLevelTimer, "TimerManager::isEnabled(%d)", id); |