aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorlolbot-iichan2019-05-21 00:00:07 +0300
committerFilippos Karapetis2020-01-11 18:05:39 +0200
commite68e82cd8cf309a3b8fc353d2695f45e165311ef (patch)
tree3b92afb14eba22f325e5c13d25859c4d62e0254b /engines
parent4bd18fd25e0dffe40bb9e2aa9e59d3b41ac17529 (diff)
downloadscummvm-rg350-e68e82cd8cf309a3b8fc353d2695f45e165311ef.tar.gz
scummvm-rg350-e68e82cd8cf309a3b8fc353d2695f45e165311ef.tar.bz2
scummvm-rg350-e68e82cd8cf309a3b8fc353d2695f45e165311ef.zip
WINTERMUTE: Add FoxTail saveslot timestamp getter
FoxTail requires Game.GetSaveSlotDescriptionTimestamp for getting information about saved games. Engine 1.2.362 and below returns object with Description and Timestamp fields. Engine 1.2.527 and above returns array[2] with Description and Timestamp as items.
Diffstat (limited to 'engines')
-rw-r--r--engines/wintermute/base/base_game.cpp43
-rw-r--r--engines/wintermute/base/base_persistence_manager.h1
-rw-r--r--engines/wintermute/base/saveload.cpp12
-rw-r--r--engines/wintermute/base/saveload.h1
4 files changed, 57 insertions, 0 deletions
diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp
index e389b6795a..58195e6faa 100644
--- a/engines/wintermute/base/base_game.cpp
+++ b/engines/wintermute/base/base_game.cpp
@@ -1368,6 +1368,49 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
return STATUS_OK;
}
+#ifdef ENABLE_FOXTAIL
+ //////////////////////////////////////////////////////////////////////////
+ // [FoxTail] GetSaveSlotDescriptionTimestamp
+ // Return struct with "Description" and "Timestamp" fields in 1.2.362-
+ // Return array with "Description" and "Timestamp" items in 1.2.527+
+ // Timestamps should be comparable types
+ // Used to sort saved games by timestamps at save.script & load.script
+ //////////////////////////////////////////////////////////////////////////
+ else if (strcmp(name, "GetSaveSlotDescriptionTimestamp") == 0) {
+ stack->correctParams(1);
+ int slot = stack->pop()->getInt();
+
+ TimeDate time;
+ SaveLoad::getSaveSlotTimestamp(slot, &time);
+ stack->pushInt(time.tm_sec);
+ stack->pushInt(time.tm_min);
+ stack->pushInt(time.tm_hour);
+ stack->pushInt(time.tm_mday);
+ stack->pushInt(time.tm_mon + 1);
+ stack->pushInt(time.tm_year + 1900);
+ stack->pushInt(6);
+ BaseScriptable *date = makeSXDate(_gameRef, stack);
+ stack->pushNative(date, false);
+
+ Common::String desc = SaveLoad::getSaveSlotDescription(slot);
+ stack->pushString(desc.c_str());
+
+ BaseScriptable *obj;
+ if (BaseEngine::instance().isFoxTail(FOXTAIL_1_2_527, FOXTAIL_LATEST_VERSION)) {
+ stack->pushInt(2);
+ obj = makeSXArray(_gameRef, stack);
+ } else {
+ stack->pushInt(0);
+ obj = makeSXObject(_gameRef, stack);
+ obj->scSetProperty("Description", stack->pop());
+ obj->scSetProperty("Timestamp", stack->pop());
+ }
+ stack->pushNative(obj, false);
+
+ return STATUS_OK;
+ }
+#endif
+
//////////////////////////////////////////////////////////////////////////
// EmptySaveSlot
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h
index 760b45c907..e8ca663cb7 100644
--- a/engines/wintermute/base/base_persistence_manager.h
+++ b/engines/wintermute/base/base_persistence_manager.h
@@ -69,6 +69,7 @@ public:
uint32 _offset;
bool getIsSaving() { return _saving; }
+ TimeDate getSavedTimestamp() { return _savedTimestamp; }
uint32 _richBufferSize;
byte *_richBuffer;
diff --git a/engines/wintermute/base/saveload.cpp b/engines/wintermute/base/saveload.cpp
index e0f97f0d88..bafe8a7a51 100644
--- a/engines/wintermute/base/saveload.cpp
+++ b/engines/wintermute/base/saveload.cpp
@@ -182,6 +182,18 @@ Common::String SaveLoad::getSaveSlotDescription(int slot) {
return description;
}
+void SaveLoad::getSaveSlotTimestamp(int slot, TimeDate *time) {
+ memset(time, 0, sizeof(TimeDate));
+ Common::String filename = getSaveSlotFilename(slot);
+ BasePersistenceManager *pm = new BasePersistenceManager();
+ if (pm) {
+ if ((pm->initLoad(filename))) {
+ *time = pm->getSavedTimestamp();
+ }
+ delete pm;
+ }
+}
+
bool SaveLoad::isSaveSlotUsed(int slot) {
Common::String filename = getSaveSlotFilename(slot);
BasePersistenceManager *pm = new BasePersistenceManager();
diff --git a/engines/wintermute/base/saveload.h b/engines/wintermute/base/saveload.h
index e98c7b2f73..295d19d543 100644
--- a/engines/wintermute/base/saveload.h
+++ b/engines/wintermute/base/saveload.h
@@ -38,6 +38,7 @@ public:
static bool emptySaveSlot(int slot);
static bool isSaveSlotUsed(int slot);
static Common::String getSaveSlotDescription(int slot);
+ static void getSaveSlotTimestamp(int slot, TimeDate *time);
static Common::String getSaveSlotFilename(int slot);
static bool loadGame(const Common::String &filename, BaseGame *gameRef);