[Scummvm-cvs-logs] SF.net SVN: scummvm:[53901] scummvm/trunk/engines/sword25
dreammaster at users.sourceforge.net
dreammaster at users.sourceforge.net
Thu Oct 28 11:51:56 CEST 2010
Revision: 53901
http://scummvm.svn.sourceforge.net/scummvm/?rev=53901&view=rev
Author: dreammaster
Date: 2010-10-28 09:51:56 +0000 (Thu, 28 Oct 2010)
Log Message:
-----------
SWORD25: Standardised savegame filenames, start on advanced engine features
Modified Paths:
--------------
scummvm/trunk/engines/sword25/detection.cpp
scummvm/trunk/engines/sword25/kernel/persistenceservice.cpp
scummvm/trunk/engines/sword25/kernel/persistenceservice.h
scummvm/trunk/engines/sword25/sword25.cpp
Modified: scummvm/trunk/engines/sword25/detection.cpp
===================================================================
--- scummvm/trunk/engines/sword25/detection.cpp 2010-10-28 08:16:03 UTC (rev 53900)
+++ scummvm/trunk/engines/sword25/detection.cpp 2010-10-28 09:51:56 UTC (rev 53901)
@@ -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 @@
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,21 +128,30 @@
}
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);
#else
Modified: scummvm/trunk/engines/sword25/kernel/persistenceservice.cpp
===================================================================
--- scummvm/trunk/engines/sword25/kernel/persistenceservice.cpp 2010-10-28 08:16:03 UTC (rev 53900)
+++ scummvm/trunk/engines/sword25/kernel/persistenceservice.cpp 2010-10-28 09:51:56 UTC (rev 53901)
@@ -57,12 +57,17 @@
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);
}
Modified: scummvm/trunk/engines/sword25/kernel/persistenceservice.h
===================================================================
--- scummvm/trunk/engines/sword25/kernel/persistenceservice.h 2010-10-28 08:16:03 UTC (rev 53900)
+++ scummvm/trunk/engines/sword25/kernel/persistenceservice.h 2010-10-28 09:51:56 UTC (rev 53901)
@@ -71,6 +71,8 @@
Impl *_impl;
};
+void setGameTarget(const char *target);
+
} // End of namespace Sword25
#endif
Modified: scummvm/trunk/engines/sword25/sword25.cpp
===================================================================
--- scummvm/trunk/engines/sword25/sword25.cpp 2010-10-28 08:16:03 UTC (rev 53900)
+++ scummvm/trunk/engines/sword25/sword25.cpp 2010-10-28 09:51:56 UTC (rev 53901)
@@ -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 @@
return Common::kUnknownError;
}
+ // Set the game target for use in savegames
+ setGameTarget(_targetName.c_str());
+
Common::StringArray commandParameters;
scriptPtr->setCommandLine(commandParameters);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list