aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25
diff options
context:
space:
mode:
authorPaul Gilbert2010-10-20 11:11:09 +0000
committerPaul Gilbert2010-10-20 11:11:09 +0000
commit14e82dbe7f25c1a31cc8afbc712ee0246c7706dc (patch)
tree4c147a55e4eef66b8f50c756bac695c32c51170b /engines/sword25
parent66ecd08868b83d166e6e01c2e4c2b66eecdbe99a (diff)
downloadscummvm-rg350-14e82dbe7f25c1a31cc8afbc712ee0246c7706dc.tar.gz
scummvm-rg350-14e82dbe7f25c1a31cc8afbc712ee0246c7706dc.tar.bz2
scummvm-rg350-14e82dbe7f25c1a31cc8afbc712ee0246c7706dc.zip
SWORD25: Added description field to savegames
This stores the date and time of when the game was saved, since ScummVM doesn't support getting a file's age like the original engine did. svn-id: r53638
Diffstat (limited to 'engines/sword25')
-rw-r--r--engines/sword25/gfx/image/b25sloader.cpp7
-rw-r--r--engines/sword25/kernel/filesystemutil.cpp9
-rw-r--r--engines/sword25/kernel/filesystemutil.h5
-rw-r--r--engines/sword25/kernel/persistenceservice.cpp24
4 files changed, 19 insertions, 26 deletions
diff --git a/engines/sword25/gfx/image/b25sloader.cpp b/engines/sword25/gfx/image/b25sloader.cpp
index 693b616e01..01bb9b39a0 100644
--- a/engines/sword25/gfx/image/b25sloader.cpp
+++ b/engines/sword25/gfx/image/b25sloader.cpp
@@ -45,7 +45,7 @@ static Common::String loadString(Common::ReadStream &in, uint maxSize = 999) {
while (!in.eos() && (result.size() < maxSize)) {
char ch = (char)in.readByte();
- if ((ch == '\0') || (ch == ' '))
+ if (ch == '\0')
break;
result += ch;
@@ -65,8 +65,9 @@ uint findEmbeddedPNG(const byte *fileDataPtr, uint fileSize) {
// Headerinformationen der Spielstandes einlesen.
uint compressedGamedataSize;
- loadString(stream);
- loadString(stream);
+ loadString(stream); // Marker
+ loadString(stream); // Version
+ loadString(stream); // Description
Common::String gameSize = loadString(stream);
compressedGamedataSize = atoi(gameSize.c_str());
loadString(stream);
diff --git a/engines/sword25/kernel/filesystemutil.cpp b/engines/sword25/kernel/filesystemutil.cpp
index 945ba0d2c2..4268cf83fa 100644
--- a/engines/sword25/kernel/filesystemutil.cpp
+++ b/engines/sword25/kernel/filesystemutil.cpp
@@ -91,15 +91,6 @@ public:
return size;
}
- virtual TimeDate getFileTime(const Common::String &filename) {
- // TODO: There isn't any way in ScummVM to get a file's modified date/time. We will need to check
- // what code makes use of it. If it's only the save game code, for example, we may be able to
- // encode the date/time inside the savegame files themselves.
- TimeDate result;
- g_system->getTimeAndDate(result);
- return result;
- }
-
virtual bool fileExists(const Common::String &filename) {
Common::File f;
if (f.exists(filename))
diff --git a/engines/sword25/kernel/filesystemutil.h b/engines/sword25/kernel/filesystemutil.h
index 904b9d4e04..4c089e1049 100644
--- a/engines/sword25/kernel/filesystemutil.h
+++ b/engines/sword25/kernel/filesystemutil.h
@@ -83,11 +83,6 @@ public:
virtual int32 getFileSize(const Common::String &filename) = 0;
/**
* @param Filename The path to a file.
- * @return Returns the timestamp of the specified file.
- */
- virtual TimeDate getFileTime(const Common::String &filename) = 0;
- /**
- * @param Filename The path to a file.
* @return Returns true if the file exists.
*/
virtual bool fileExists(const Common::String &filename) = 0;
diff --git a/engines/sword25/kernel/persistenceservice.cpp b/engines/sword25/kernel/persistenceservice.cpp
index b821b91c55..0159991e0f 100644
--- a/engines/sword25/kernel/persistenceservice.cpp
+++ b/engines/sword25/kernel/persistenceservice.cpp
@@ -87,7 +87,7 @@ Common::String loadString(Common::InSaveFile *in, uint maxSize = 999) {
Common::String result;
char ch = (char)in->readByte();
- while ((ch != '\0') && (ch != ' ')) {
+ while (ch != '\0') {
result += ch;
if (result.size() >= maxSize)
break;
@@ -155,6 +155,7 @@ struct PersistenceService::Impl {
// Read in the header
Common::String storedMarker = loadString(file);
Common::String storedVersionID = loadString(file);
+ Common::String gameDescription = loadString(file);
Common::String gameDataLength = loadString(file);
curSavegameInfo.gamedataLength = atoi(gameDataLength.c_str());
Common::String gamedataUncompressedLength = loadString(file);
@@ -169,7 +170,7 @@ struct PersistenceService::Impl {
// Dateinamen des Spielstandes speichern.
curSavegameInfo.filename = generateSavegameFilename(slotID);
// Die Beschreibung des Spielstandes besteht aus einer textuellen Darstellung des Änderungsdatums der Spielstanddatei.
- curSavegameInfo.description = formatTimestamp(FileSystemUtil::getInstance().getFileTime(filename));
+ curSavegameInfo.description = gameDescription;
// Den Offset zu den gespeicherten Spieldaten innerhalb der Datei speichern.
// Dieses entspricht der aktuellen Position, da nach der letzten Headerinformation noch ein Leerzeichen als trenner folgt.
curSavegameInfo.gamedataOffset = static_cast<uint>(file->pos());
@@ -267,9 +268,14 @@ bool PersistenceService::saveGame(uint slotID, const Common::String &screenshotF
Common::OutSaveFile *file = sfm->openForSaving(filename);
file->writeString(FILE_MARKER);
- file->writeByte(' ');
+ file->writeByte(0);
file->writeString(VERSIONID);
- file->writeByte(' ');
+ file->writeByte(0);
+
+ TimeDate dt;
+ g_system->getTimeAndDate(dt);
+ file->writeString(formatTimestamp(dt));
+ file->writeByte(0);
if (file->err()) {
error("Unable to write header data to savegame file \"%s\".", filename.c_str());
@@ -299,10 +305,10 @@ bool PersistenceService::saveGame(uint slotID, const Common::String &screenshotF
char sBuffer[10];
snprintf(sBuffer, 10, "%ld", compressedLength);
file->writeString(sBuffer);
- file->writeByte(' ');
+ file->writeByte(0);
snprintf(sBuffer, 10, "%u", writer.getDataSize());
file->writeString(sBuffer);
- file->writeByte(' ');
+ file->writeByte(0);
// Komprimierte Daten in die Datei schreiben.
file->write(reinterpret_cast<char *>(&compressionBuffer[0]), compressedLength);
@@ -325,13 +331,13 @@ bool PersistenceService::saveGame(uint slotID, const Common::String &screenshotF
BS_LOG_WARNINGLN("The screenshot file \"%s\" does not exist. Savegame is written without a screenshot.", filename.c_str());
}
- // Savegameinformationen für diesen Slot aktualisieren.
- _impl->readSlotSavegameInformation(slotID);
-
file->finalize();
delete file;
delete[] compressionBuffer;
+ // Savegameinformationen für diesen Slot aktualisieren.
+ _impl->readSlotSavegameInformation(slotID);
+
// Erfolg signalisieren.
return true;
}