[Scummvm-cvs-logs] scummvm master -> ef631c9e75f09e3a2a54701c1d6bf0e2dce5b71e
Tkachov
Tkachov at users.noreply.github.com
Thu Aug 4 10:17:58 CEST 2016
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
f58abd9540 COMMON: Update GZipWriteStream::pos()
ef631c9e75 WAGE: Update saves format
Commit: f58abd95409998d5e0859aaa1ef0df14c0639519
https://github.com/scummvm/scummvm/commit/f58abd95409998d5e0859aaa1ef0df14c0639519
Author: Alexander Tkachev (alexander at tkachov.ru)
Date: 2016-08-04T15:14:06+06:00
Commit Message:
COMMON: Update GZipWriteStream::pos()
Though it seemed the _wrapped stream should return valid position, it
was always 0. That's why I've added a _pos field, which is updated in
write() and returned in pos().
Changed paths:
common/zlib.cpp
diff --git a/common/zlib.cpp b/common/zlib.cpp
index 3b51d66..39130be 100644
--- a/common/zlib.cpp
+++ b/common/zlib.cpp
@@ -316,6 +316,7 @@ protected:
ScopedPtr<WriteStream> _wrapped;
z_stream _stream;
int _zlibErr;
+ uint32 _pos;
void processData(int flushType) {
// This function is called by both write() and finalize().
@@ -333,7 +334,7 @@ protected:
}
public:
- GZipWriteStream(WriteStream *w) : _wrapped(w), _stream() {
+ GZipWriteStream(WriteStream *w) : _wrapped(w), _stream(), _pos(0) {
assert(w != 0);
// Adding 16 to windowBits indicates to zlib that it is supposed to
@@ -403,10 +404,11 @@ public:
// ... and flush it to disk
processData(Z_NO_FLUSH);
+ _pos += dataSize - _stream.avail_in;
return dataSize - _stream.avail_in;
}
- virtual int32 pos() const { return _wrapped->pos(); }
+ virtual int32 pos() const { return _pos; }
};
#endif // USE_ZLIB
Commit: ef631c9e75f09e3a2a54701c1d6bf0e2dce5b71e
https://github.com/scummvm/scummvm/commit/ef631c9e75f09e3a2a54701c1d6bf0e2dce5b71e
Author: Alexander Tkachev (alexander at tkachov.ru)
Date: 2016-08-04T15:15:45+06:00
Commit Message:
WAGE: Update saves format
Offset is added in the end of the file, so ScummVM would know where to
look for description, version, thumbnail information.
Changed paths:
engines/wage/detection.cpp
engines/wage/saveload.cpp
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index e14a952..a27bfd7 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -99,7 +99,7 @@ SaveStateList WageMetaEngine::listSaves(const char *target) const {
const uint32 WAGEflag = MKTAG('W','A','G','E');
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::StringArray filenames;
- char saveDesc[31];
+ char saveDesc[128] = {0};
Common::String pattern = target;
pattern += ".###";
@@ -113,9 +113,18 @@ SaveStateList WageMetaEngine::listSaves(const char *target) const {
if (slotNum >= 0 && slotNum <= 999) {
Common::InSaveFile *in = saveFileMan->openForLoading(*file);
if (in) {
+ saveDesc[0] = 0;
+ in->seek(in->size() - 8);
+ uint32 offset = in->readUint32BE();
uint32 type = in->readUint32BE();
- if (type == WAGEflag)
- in->read(saveDesc, 31);
+ if (type == WAGEflag) {
+ in->seek(offset);
+
+ type = in->readUint32BE();
+ if (type == WAGEflag) {
+ in->read(saveDesc, 127);
+ }
+ }
saveList.push_back(SaveStateDescriptor(slotNum, saveDesc));
delete in;
}
diff --git a/engines/wage/saveload.cpp b/engines/wage/saveload.cpp
index 78e8d38..c3b20bd 100644
--- a/engines/wage/saveload.cpp
+++ b/engines/wage/saveload.cpp
@@ -335,6 +335,10 @@ int WageEngine::saveGame(const Common::String &fileName, const Common::String &d
}
// the following is appended by ScummVM
+ int32 appendixOffset = out->pos();
+ if (appendixOffset < 0) {
+ warning("OutSaveFile::pos() failed");
+ }
out->writeUint32BE(WAGEflag);
// Write description of saved game, limited to WAGE_SAVEDGAME_DESCRIPTION_LEN characters + terminating NUL
@@ -352,6 +356,8 @@ int WageEngine::saveGame(const Common::String &fileName, const Common::String &d
// Thumbnail
Graphics::saveThumbnail(*out);
+ out->writeUint32BE(appendixOffset);
+
// this one to make checking easier:
// it couldn't be added to the beginning
// and we won't be able to find it in the middle,
More information about the Scummvm-git-logs
mailing list