aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2010-10-28 09:51:56 +0000
committerPaul Gilbert2010-10-28 09:51:56 +0000
commitb53d12da23e6154e0f027fef68cc21518f53018d (patch)
tree694685b9c8f50d92d8dcc54f07dcc687363a72be
parentf772de04f9d6c0ab6a386af580b69fd162568974 (diff)
downloadscummvm-rg350-b53d12da23e6154e0f027fef68cc21518f53018d.tar.gz
scummvm-rg350-b53d12da23e6154e0f027fef68cc21518f53018d.tar.bz2
scummvm-rg350-b53d12da23e6154e0f027fef68cc21518f53018d.zip
SWORD25: Standardised savegame filenames, start on advanced engine features
svn-id: r53901
-rw-r--r--engines/sword25/detection.cpp37
-rw-r--r--engines/sword25/kernel/persistenceservice.cpp15
-rw-r--r--engines/sword25/kernel/persistenceservice.h2
-rw-r--r--engines/sword25/sword25.cpp4
4 files changed, 41 insertions, 17 deletions
diff --git a/engines/sword25/detection.cpp b/engines/sword25/detection.cpp
index 1d3a5437ac..3900df2fcf 100644
--- a/engines/sword25/detection.cpp
+++ b/engines/sword25/detection.cpp
@@ -24,10 +24,12 @@
*/
#include "base/plugins.h"
-
+#include "common/savefile.h"
+#include "common/system.h"
#include "engines/advancedDetector.h"
#include "sword25/sword25.h"
+#include "sword25/kernel/persistenceservice.h"
namespace Sword25 {
uint32 Sword25Engine::getGameFlags() const { return _gameDescription->flags; }
@@ -114,6 +116,8 @@ public:
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
virtual bool hasFeature(MetaEngineFeature f) const;
+ virtual int getMaximumSaveSlot() const { return Sword25::PersistenceService::getSlotCount(); }
+ virtual SaveStateList listSaves(const char *target) const;
};
bool Sword25MetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
@@ -124,20 +128,29 @@ bool Sword25MetaEngine::createInstance(OSystem *syst, Engine **engine, const ADG
}
bool Sword25MetaEngine::hasFeature(MetaEngineFeature f) const {
- return false;
- // TODO: Implement some of these features!?
-#if 0
return
- (f == kSupportsListSaves) ||
- (f == kSupportsLoadingDuringStartup) ||
- (f == kSupportsDeleteSave) ||
- (f == kSavesSupportMetaInfo) ||
- (f == kSavesSupportThumbnail) ||
- (f == kSavesSupportCreationDate) ||
- (f == kSavesSupportPlayTime);
-#endif
+ (f == kSupportsListSaves);
}
+SaveStateList Sword25MetaEngine::listSaves(const char *target) const {
+ Common::String pattern = target;
+ pattern = pattern + ".???";
+ SaveStateList saveList;
+
+ Sword25::PersistenceService ps;
+ Sword25::setGameTarget(target);
+
+ ps.reloadSlots();
+
+ for (uint i = 0; i < ps.getSlotCount(); ++i) {
+ if (ps.isSlotOccupied(i)) {
+ Common::String desc = ps.getSavegameDescription(i);
+ saveList.push_back(SaveStateDescriptor(i, desc));
+ }
+ }
+
+ return saveList;
+}
#if PLUGIN_ENABLED_DYNAMIC(SWORD25)
REGISTER_PLUGIN_DYNAMIC(SWORD25, PLUGIN_TYPE_ENGINE, Sword25MetaEngine);
diff --git a/engines/sword25/kernel/persistenceservice.cpp b/engines/sword25/kernel/persistenceservice.cpp
index d6589b6ce9..4deda9d28e 100644
--- a/engines/sword25/kernel/persistenceservice.cpp
+++ b/engines/sword25/kernel/persistenceservice.cpp
@@ -57,12 +57,17 @@ static const uint SLOT_COUNT = 18;
static const uint FILE_COPY_BUFFER_SIZE = 1024 * 10;
static const char *VERSIONID = "SCUMMVM1";
+#define MAX_SAVEGAME_SIZE 100
+
+char gameTarget[MAX_SAVEGAME_SIZE];
+
+void setGameTarget(const char *target) {
+ strncpy(gameTarget, target, MAX_SAVEGAME_SIZE);
+}
+
static Common::String generateSavegameFilename(uint slotID) {
- // FIXME: The savename names used here are not in accordance with
- // our conventions; they really should be something like
- // "GAMEID.NUM" or "TARGET.NUM".
- char buffer[10];
- sprintf(buffer, "%d%s", slotID, SAVEGAME_EXTENSION);
+ char buffer[MAX_SAVEGAME_SIZE];
+ snprintf(buffer, MAX_SAVEGAME_SIZE, "%s.%.3d", gameTarget, slotID);
return Common::String(buffer);
}
diff --git a/engines/sword25/kernel/persistenceservice.h b/engines/sword25/kernel/persistenceservice.h
index c06cae6096..0db109d1b0 100644
--- a/engines/sword25/kernel/persistenceservice.h
+++ b/engines/sword25/kernel/persistenceservice.h
@@ -71,6 +71,8 @@ private:
Impl *_impl;
};
+void setGameTarget(const char *target);
+
} // End of namespace Sword25
#endif
diff --git a/engines/sword25/sword25.cpp b/engines/sword25/sword25.cpp
index 5d8851e63e..5864057423 100644
--- a/engines/sword25/sword25.cpp
+++ b/engines/sword25/sword25.cpp
@@ -39,6 +39,7 @@
#include "sword25/sword25.h"
#include "sword25/kernel/filesystemutil.h"
#include "sword25/kernel/kernel.h"
+#include "sword25/kernel/persistenceservice.h"
#include "sword25/package/packagemanager.h"
#include "sword25/script/script.h"
@@ -112,6 +113,9 @@ Common::Error Sword25Engine::appStart() {
return Common::kUnknownError;
}
+ // Set the game target for use in savegames
+ setGameTarget(_targetName.c_str());
+
Common::StringArray commandParameters;
scriptPtr->setCommandLine(commandParameters);