aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
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);