[Scummvm-git-logs] scummvm master -> 07f2b34d2682d0b0f64c2d2d2543769d9b263924

dreammaster dreammaster at scummvm.org
Sat Jan 13 16:51:35 CET 2018


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
07f2b34d26 XEEN: Fix re-encryption of save archive indexes


Commit: 07f2b34d2682d0b0f64c2d2d2543769d9b263924
    https://github.com/scummvm/scummvm/commit/07f2b34d2682d0b0f64c2d2d2543769d9b263924
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2018-01-13T10:51:24-05:00

Commit Message:
XEEN: Fix re-encryption of save archive indexes

Changed paths:
    engines/xeen/detection.cpp
    engines/xeen/files.cpp


diff --git a/engines/xeen/detection.cpp b/engines/xeen/detection.cpp
index df3df4f..28811c3 100644
--- a/engines/xeen/detection.cpp
+++ b/engines/xeen/detection.cpp
@@ -147,7 +147,8 @@ SaveStateList XeenMetaEngine::listSaves(const char *target) const {
 				Xeen::SavesManager::readSavegameHeader(in, header);
 				saveList.push_back(SaveStateDescriptor(slot, header._saveName));
 
-				header._thumbnail->free();
+				if (header._thumbnail)
+					header._thumbnail->free();
 				delete header._thumbnail;
 				delete in;
 			}
diff --git a/engines/xeen/files.cpp b/engines/xeen/files.cpp
index 912c953..705a940 100644
--- a/engines/xeen/files.cpp
+++ b/engines/xeen/files.cpp
@@ -66,7 +66,7 @@ void BaseCCArchive::loadIndex(Common::SeekableReadStream &stream) {
 	// Decrypt the index
 	int seed = 0xac;
 	for (int i = 0; i < count * 8; ++i, seed += 0x67) {
-		rawIndex[i] = (byte)(((rawIndex[i] << 2 | rawIndex[i] >> 6) + seed) & 0xff);
+		rawIndex[i] = (byte)((((rawIndex[i] << 2) | (rawIndex[i] >> 6)) + seed) & 0xff);
 	}
 
 	// Extract the index data into entry structures
@@ -86,15 +86,7 @@ void BaseCCArchive::loadIndex(Common::SeekableReadStream &stream) {
 }
 
 void BaseCCArchive::saveIndex(Common::WriteStream &stream) {
-	// First caclculate file offsets for each resource, since replaced resources
-	// will shift file offsets for even the succeeding unchanged resources
-	for (uint idx = 1, pos = _index[0]._offset + _index[0]._size; idx < _index.size(); ++idx) {
-		_index[idx]._offset = pos;
-		pos += _index[idx]._size;
-	}
-
 	// Fill up the data for the index entries into a raw data block
-	byte data[8];
 	byte *rawIndex = new byte[_index.size() * 8];
 
 	byte *entryP = rawIndex;
@@ -109,8 +101,8 @@ void BaseCCArchive::saveIndex(Common::WriteStream &stream) {
 	// Encrypt the index
 	int seed = 0xac;
 	for (uint i = 0; i < _index.size() * 8; ++i, seed += 0x67) {
-		byte b = (seed - rawIndex[i]) && 0xff;
-		rawIndex[i] = ((b >> 2) & 0x3f) | ((b & 3) << 6);
+		byte b = (rawIndex[i] - seed) & 0xff;
+		rawIndex[i] = (byte)((b >> 2) | (b << 6));
 	}
 
 	// Write out the number of entries and the encrypted index data
@@ -487,6 +479,17 @@ void SaveArchive::save(Common::WriteStream &s) {
 	Common::Serializer sPty(nullptr, &pty);
 	_party->synchronize(sPty);
 
+	// First caclculate file offsets for each resource, since replaced resources
+	// will shift file offsets for even the succeeding unchanged resources
+	for (uint idx = 1, pos = _index[0]._offset + _index[0]._size; idx < _index.size(); ++idx) {
+		_index[idx]._offset = pos;
+		pos += _index[idx]._size;
+	}
+
+	// Write out the size of the save archive
+	_dataSize = _index.back()._offset + _index.back()._size;
+	s.writeUint32LE(_dataSize);
+
 	// Save out the index
 	saveIndex(s);
 





More information about the Scummvm-git-logs mailing list