diff options
author | Willem Jan Palenstijn | 2013-04-18 23:55:01 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-05-08 20:47:44 +0200 |
commit | 102299630901d08a44ef3aec367fcbcae065b9fe (patch) | |
tree | 98db4bbe0c54176c0a43e2f5076f8b3d63b8065c /engines/pegasus/timers.cpp | |
parent | 583f9abaf98f64895546b75573e9442ca47426e3 (diff) | |
parent | 78ba3210a57094086d44b25d5a8507c33ce9bef3 (diff) | |
download | scummvm-rg350-102299630901d08a44ef3aec367fcbcae065b9fe.tar.gz scummvm-rg350-102299630901d08a44ef3aec367fcbcae065b9fe.tar.bz2 scummvm-rg350-102299630901d08a44ef3aec367fcbcae065b9fe.zip |
Merge branch 'master'
Diffstat (limited to 'engines/pegasus/timers.cpp')
-rw-r--r-- | engines/pegasus/timers.cpp | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/engines/pegasus/timers.cpp b/engines/pegasus/timers.cpp index 3b875038cc..50cc9bc6d8 100644 --- a/engines/pegasus/timers.cpp +++ b/engines/pegasus/timers.cpp @@ -73,13 +73,8 @@ TimeBase::TimeBase(const TimeScale preferredScale) { } TimeBase::~TimeBase() { - if (_master) - _master->_slaves.remove(this); - ((PegasusEngine *)g_engine)->removeTimeBase(this); disposeAllCallBacks(); - - // TODO: Remove slaves? Make them remove themselves? } void TimeBase::setTime(const TimeValue time, const TimeScale scale) { @@ -88,20 +83,23 @@ void TimeBase::setTime(const TimeValue time, const TimeScale scale) { } TimeValue TimeBase::getTime(const TimeScale scale) { + // HACK: Emulate the master TimeBase code here for the one case that needs it in the + // game. Note that none of the master TimeBase code in this file should actually be + // used as a reference for anything ever. + if (_master) + return _master->getTime(scale); + return _time.getNumerator() * ((scale == 0) ? _preferredScale : scale) / _time.getDenominator(); } void TimeBase::setRate(const Common::Rational rate) { _rate = rate; + _lastMillis = 0; if (_rate == 0) _paused = false; } -Common::Rational TimeBase::getEffectiveRate() const { - return _rate * ((_master == 0) ? 1 : _master->getEffectiveRate()); -} - void TimeBase::start() { if (_paused) _pausedRate = 1; @@ -192,18 +190,15 @@ TimeValue TimeBase::getDuration(const TimeScale scale) const { } void TimeBase::setMasterTimeBase(TimeBase *tb) { - // TODO: We're just ignoring the master (except for effective rate) - // for now to simplify things - if (_master) - _master->_slaves.remove(this); - _master = tb; - - if (_master) - _master->_slaves.push_back(this); } void TimeBase::updateTime() { + if (_master) { + _master->updateTime(); + return; + } + if (_lastMillis == 0) { _lastMillis = g_system->getMillis(); } else { @@ -211,7 +206,7 @@ void TimeBase::updateTime() { if (_lastMillis == curTime) // No change return; - _time += Common::Rational(curTime - _lastMillis, 1000) * getEffectiveRate(); + _time += Common::Rational(curTime - _lastMillis, 1000) * getRate(); _lastMillis = curTime; } } @@ -233,8 +228,6 @@ void TimeBase::checkCallBacks() { else if (_time <= startTime) _time = startTime; - // TODO: Update the slaves? - Common::Rational time = Common::Rational(getTime(), getScale()); // Check if we've triggered any callbacks |