From 2ad28b8cd53c363f12d920c746795e0d371dc9f9 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 27 Oct 2010 22:37:51 +0000 Subject: ENGINE: Generalize SCUMM play time counting and move it into Engine. This implements Max's idea on -devel ("Re: [Scummvm-devel] ATTN Engine authors: Advanced engine features") from 27.10.2010 on 11:12PM CEST. Unlike the SCUMM implementation it stores the play time as ms instead of s. The SCUMM engine was adapted to use this instead to reduce code duplication. svn-id: r53892 --- engines/scumm/saveload.cpp | 6 +++--- engines/scumm/scumm.cpp | 10 +--------- engines/scumm/scumm.h | 3 --- 3 files changed, 4 insertions(+), 15 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp index 28ec6c182f..b9cb0ae10f 100644 --- a/engines/scumm/saveload.cpp +++ b/engines/scumm/saveload.cpp @@ -378,10 +378,10 @@ bool ScummEngine::loadState(int slot, bool compat) { return false; } - _engineStartTime = _system->getMillis() / 1000 - infos.playtime; + resetTotalPlayTime(infos.playtime * 1000); } else { // start time counting - _engineStartTime = _system->getMillis() / 1000; + resetTotalPlayTime(); } // Due to a bug in scummvm up to and including 0.3.0, save games could be saved @@ -797,7 +797,7 @@ void ScummEngine::saveInfos(Common::WriteStream* file) { // still save old format for older versions section.timeTValue = 0; - section.playtime = _system->getMillis() / 1000 - _engineStartTime; + section.playtime = getTotalPlayTime() / 1000; TimeDate curTime; _system->getTimeAndDate(curTime); diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index d711888c2c..2c654402fa 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -1927,7 +1927,7 @@ int ScummEngine::getTalkSpeed() { #pragma mark - Common::Error ScummEngine::go() { - _engineStartTime = _system->getMillis() / 1000; + resetTotalPlayTime(); // If requested, load a save game instead of running the boot script if (_saveLoadFlag != 2 || !loadState(_saveLoadSlot, _saveTemporaryState)) { @@ -2505,10 +2505,6 @@ void ScummEngine::startManiac() { void ScummEngine::pauseEngineIntern(bool pause) { if (pause) { - // Record start of the pause, so that we can later - // adjust _engineStartTime accordingly. - _pauseStartTime = _system->getMillis(); - // Pause sound & video _oldSoundsPaused = _sound->_soundsPaused; _sound->pauseSounds(true); @@ -2526,10 +2522,6 @@ void ScummEngine::pauseEngineIntern(bool pause) { // Resume sound & video _sound->pauseSounds(_oldSoundsPaused); - - // Adjust engine start time - _engineStartTime += (_system->getMillis() - _pauseStartTime) / 1000; - _pauseStartTime = 0; } } diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index 346d8fb79a..0a513b6068 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -700,9 +700,6 @@ protected: void saveInfos(Common::WriteStream* file); static bool loadInfos(Common::SeekableReadStream *file, InfoStuff *stuff); - int32 _engineStartTime; - int32 _pauseStartTime; - protected: /* Script VM - should be in Script class */ uint32 _localScriptOffsets[1024]; -- cgit v1.2.3