diff options
author | Martin Kiewitz | 2016-01-31 20:53:36 +0100 |
---|---|---|
committer | Martin Kiewitz | 2016-01-31 20:53:36 +0100 |
commit | fd9c46831df3bcd09bc6f85d5e41c2beb3f7c024 (patch) | |
tree | 7e85bd08b17c976e78d628fe0da427726ba0ccf3 /engines/agi/saveload.cpp | |
parent | 9acbe6f3f42a35becf3dcff04d758b3286c05c7e (diff) | |
download | scummvm-rg350-fd9c46831df3bcd09bc6f85d5e41c2beb3f7c024.tar.gz scummvm-rg350-fd9c46831df3bcd09bc6f85d5e41c2beb3f7c024.tar.bz2 scummvm-rg350-fd9c46831df3bcd09bc6f85d5e41c2beb3f7c024.zip |
AGI: remove timer hack, implement in game timer
in game timer is now updated, when scripts read in game timer
VM variables and during main loop. ScummVM total play time feature
is used for it. Game cycle syncing is done at the same time.
Diffstat (limited to 'engines/agi/saveload.cpp')
-rw-r--r-- | engines/agi/saveload.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp index b6974ee651..b47a0cf43f 100644 --- a/engines/agi/saveload.cpp +++ b/engines/agi/saveload.cpp @@ -331,6 +331,7 @@ int AgiEngine::loadGame(const Common::String &fileName, bool checkId) { uint8 t; int16 parm[7]; Common::InSaveFile *in; + bool totalPlayTimeWasSet = false; debugC(3, kDebugLevelMain | kDebugLevelSavegame, "AgiEngine::loadGame(%s)", fileName.c_str()); @@ -380,7 +381,8 @@ int AgiEngine::loadGame(const Common::String &fileName, bool checkId) { in->readUint16BE(); // save time if (saveVersion >= 6) { uint32 playTime = in->readUint32BE(); - g_engine->setTotalPlayTime(playTime * 1000); + inGameTimerReset(playTime * 1000); + totalPlayTimeWasSet = true; } } @@ -439,6 +441,19 @@ int AgiEngine::loadGame(const Common::String &fileName, bool checkId) { for (i = 0; i < MAX_VARS; i++) _game.vars[i] = in->readByte(); + if (!totalPlayTimeWasSet) { + // If we haven't gotten total play time by now, try to calculate it by using VM Variables + // This will happen for at least saves before version 6 + // Direct access because otherwise we would trigger an update to these variables according to ScummVM total play time + byte playTimeSeconds = _game.vars[VM_VAR_SECONDS]; + byte playTimeMinutes = _game.vars[VM_VAR_MINUTES]; + byte playTimeHours = _game.vars[VM_VAR_HOURS]; + byte playTimeDays = _game.vars[VM_VAR_DAYS]; + uint32 playTime = (playTimeSeconds + (playTimeMinutes * 60) + (playTimeHours * 3600) + (playTimeDays * 86400)) * 1000; + + inGameTimerReset(playTime); + } + setVar(VM_VAR_FREE_PAGES, 180); // Set amount of free memory to realistic value (Overwriting the just loaded value) _game.horizon = in->readSint16BE(); |