Skip to content

Commit

Permalink
PEGASUS: Fix timers starting when paused
Browse files Browse the repository at this point in the history
TimeBase now has its own pause time adjustment instead of using getTotalPlayTime()
  • Loading branch information
Matthew Hoops committed Dec 19, 2011
1 parent f72884c commit fa92148
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions engines/pegasus/timers.cpp
Expand Up @@ -67,6 +67,7 @@ TimeBase::TimeBase(const TimeScale preferredScale) {
_stopScale = 1;
_master = 0;
_pausedRate = 0;
_pauseStart = 0;

((PegasusEngine *)g_engine)->addTimeBase(this);
}
Expand Down Expand Up @@ -118,13 +119,17 @@ void TimeBase::pause() {
_pausedRate = getRate();
stop();
_paused = true;
_pauseStart = g_system->getMillis();
}
}

void TimeBase::resume() {
if (_paused) {
setRate(_pausedRate);
_paused = false;

if (isRunning())
_lastMillis += g_system->getMillis() - _pauseStart;
}
}

Expand Down Expand Up @@ -200,9 +205,9 @@ void TimeBase::setMasterTimeBase(TimeBase *tb) {

void TimeBase::updateTime() {
if (_lastMillis == 0) {
_lastMillis = g_engine->getTotalPlayTime();
_lastMillis = g_system->getMillis();
} else {
uint32 curTime = g_engine->getTotalPlayTime();
uint32 curTime = g_system->getMillis();
if (_lastMillis == curTime) // No change
return;

Expand Down
2 changes: 1 addition & 1 deletion engines/pegasus/timers.h
Expand Up @@ -120,7 +120,7 @@ friend class TimeBaseCallBack;
uint32 _flags;

Common::Rational _time;
uint32 _lastMillis;
uint32 _lastMillis, _pauseStart;

private:
Common::Rational getEffectiveRate() const;
Expand Down

0 comments on commit fa92148

Please sign in to comment.