aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Snover2016-01-14 10:54:27 -0600
committerColin Snover2016-01-14 16:13:22 -0600
commit76bd2eeb2e580a6a5d0b883dfc3e6b3c6e84e6b3 (patch)
treed6485ed38a1394ba2282d588c2be54a76b87dbdc
parentfb891e4c081d5f0678cdda3855daa82728dc0ac0 (diff)
downloadscummvm-rg350-76bd2eeb2e580a6a5d0b883dfc3e6b3c6e84e6b3.tar.gz
scummvm-rg350-76bd2eeb2e580a6a5d0b883dfc3e6b3c6e84e6b3.tar.bz2
scummvm-rg350-76bd2eeb2e580a6a5d0b883dfc3e6b3c6e84e6b3.zip
SCI: Use tick-based timing more consistently
This means tick-based times are saved to save games, as in SCI32 engine, instead of seconds, which are not accurate enough. It also means places in SCI engine that need to access game ticks should do so through g_sci instead of g_system or g_engine.
-rw-r--r--engines/sci/detection.cpp6
-rw-r--r--engines/sci/engine/kmisc.cpp3
-rw-r--r--engines/sci/engine/savegame.cpp12
-rw-r--r--engines/sci/engine/savegame.h2
-rw-r--r--engines/sci/graphics/palette.cpp2
-rw-r--r--engines/sci/sci.cpp7
-rw-r--r--engines/sci/sci.h1
7 files changed, 23 insertions, 10 deletions
diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp
index bac9b3467a..4179bae1d9 100644
--- a/engines/sci/detection.cpp
+++ b/engines/sci/detection.cpp
@@ -773,7 +773,11 @@ SaveStateDescriptor SciMetaEngine::querySaveMetaInfos(const char *target, int sl
desc.setSaveTime(hour, minutes);
- desc.setPlayTime(meta.playTime * 1000);
+ if (meta.version >= 34) {
+ desc.setPlayTime(meta.playTime * 1000 / 60);
+ } else {
+ desc.setPlayTime(meta.playTime * 1000);
+ }
delete in;
diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp
index 1d9dae69b7..084315e011 100644
--- a/engines/sci/engine/kmisc.cpp
+++ b/engines/sci/engine/kmisc.cpp
@@ -218,7 +218,6 @@ enum {
reg_t kGetTime(EngineState *s, int argc, reg_t *argv) {
TimeDate loc_time;
- uint32 elapsedTime = g_engine->getTotalPlayTime();
int retval = 0; // Avoid spurious warning
g_system->getTimeAndDate(loc_time);
@@ -232,7 +231,7 @@ reg_t kGetTime(EngineState *s, int argc, reg_t *argv) {
switch (mode) {
case KGETTIME_TICKS :
- retval = elapsedTime * 60 / 1000;
+ retval = g_sci->getTickCount();
debugC(kDebugLevelTime, "GetTime(elapsed) returns %d", retval);
break;
case KGETTIME_TIME_12HOUR :
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 3103be1463..481ae75907 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -273,7 +273,11 @@ static void sync_SavegameMetadata(Common::Serializer &s, SavegameMetadata &obj)
if (s.getVersion() >= 26)
s.syncAsUint32LE(obj.playTime);
} else {
- obj.playTime = g_engine->getTotalPlayTime() / 1000;
+ if (s.getVersion() >= 34) {
+ obj.playTime = g_sci->getTickCount();
+ } else {
+ obj.playTime = g_engine->getTotalPlayTime() / 1000;
+ }
s.syncAsUint32LE(obj.playTime);
}
}
@@ -1031,7 +1035,11 @@ void gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
// Time state:
s->lastWaitTime = g_system->getMillis();
s->_screenUpdateTime = g_system->getMillis();
- g_engine->setTotalPlayTime(meta.playTime * 1000);
+ if (meta.version >= 34) {
+ g_sci->setTickCount(meta.playTime);
+ } else {
+ g_engine->setTotalPlayTime(meta.playTime * 1000);
+ }
if (g_sci->_gfxPorts)
g_sci->_gfxPorts->saveLoadWithSerializer(ser);
diff --git a/engines/sci/engine/savegame.h b/engines/sci/engine/savegame.h
index 1062433d24..bb555434c9 100644
--- a/engines/sci/engine/savegame.h
+++ b/engines/sci/engine/savegame.h
@@ -37,7 +37,7 @@ struct EngineState;
*
* Version - new/changed feature
* =============================
- * 34 - SCI32 palettes
+ * 34 - SCI32 palettes, and store play time in ticks
* 33 - new overridePriority flag in MusicEntry
* 32 - new playBed flag in MusicEntry
* 31 - priority for sound effects/music is now a signed int16, instead of a byte
diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp
index 698ba632fe..106924ecd3 100644
--- a/engines/sci/graphics/palette.cpp
+++ b/engines/sci/graphics/palette.cpp
@@ -650,7 +650,7 @@ bool GfxPalette::kernelAnimate(byte fromColor, byte toColor, int speed) {
Color col;
//byte colorNr;
int16 colorCount;
- uint32 now = g_system->getMillis() * 60 / 1000;
+ uint32 now = g_sci->getTickCount();
// search for sheduled animations with the same 'from' value
// schedule animation...
diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index e568562820..9f3858e7b8 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -1037,9 +1037,10 @@ void SciEngine::loadMacExecutable() {
}
}
-// Note that SCI engine also has a corresponding TimeMgr::SetTickCount method
-// which is used by TimeMgr::SaveRestore when loading a save game.
uint32 SciEngine::getTickCount() {
- return (uint32) ((g_system->getMillis() * 60) / 1000);
+ return g_engine->getTotalPlayTime() * 60 / 1000;
+}
+void SciEngine::setTickCount(const uint32 ticks) {
+ return g_engine->setTotalPlayTime(ticks * 1000 / 60);
}
} // End of namespace Sci
diff --git a/engines/sci/sci.h b/engines/sci/sci.h
index e49345c0d4..8b47cf8876 100644
--- a/engines/sci/sci.h
+++ b/engines/sci/sci.h
@@ -237,6 +237,7 @@ public:
bool canSaveGameStateCurrently();
void syncSoundSettings();
uint32 getTickCount();
+ void setTickCount(const uint32 ticks);
/**
* Syncs the audio options of the ScummVM launcher (speech, subtitles or