[Scummvm-cvs-logs] scummvm master -> 80388527ea891bc9c44cd11ff31afefb253d3eaa

Strangerke Strangerke at scummvm.org
Mon Jun 25 23:42:26 CEST 2012


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:
80388527ea CGE: Fix SPR files with extra 0x1A or missing ending CRLF. Fix bug #3537527


Commit: 80388527ea891bc9c44cd11ff31afefb253d3eaa
    https://github.com/scummvm/scummvm/commit/80388527ea891bc9c44cd11ff31afefb253d3eaa
Author: Strangerke (strangerke at scummvm.org)
Date: 2012-06-25T14:40:17-07:00

Commit Message:
CGE: Fix SPR files with extra 0x1A or missing ending CRLF. Fix bug #3537527

Changed paths:
    engines/cge/fileio.cpp



diff --git a/engines/cge/fileio.cpp b/engines/cge/fileio.cpp
index c50db4e..f23105d 100644
--- a/engines/cge/fileio.cpp
+++ b/engines/cge/fileio.cpp
@@ -201,9 +201,28 @@ EncryptedStream::EncryptedStream(CGEEngine *vm, const char *name) : _vm(vm) {
 		_error = true;
 
 	_vm->_resman->seek(kp->_pos);
-	byte *dataBuffer = (byte *)malloc(kp->_size);
-	_vm->_resman->read(dataBuffer, kp->_size);
-	_readStream = new Common::MemoryReadStream(dataBuffer, kp->_size, DisposeAfterUse::YES);
+	byte *dataBuffer;
+	int bufSize;
+
+	if ((strlen(name) > 4) && (scumm_stricmp(name + strlen(name) - 4, ".SPR") == 0)) {
+		// SPR files have some inconsistencies. Some have extra 0x1A at the end, some others
+		// do not have a carriage return at the end of the last line
+		// Therefore, we remove this ending 0x1A and add extra new lines.
+		// This fixes bug #3537527
+		dataBuffer = (byte *)malloc(kp->_size + 2);
+		_vm->_resman->read(dataBuffer, kp->_size);
+		if (dataBuffer[kp->_size - 1] == 0x1A)
+			dataBuffer[kp->_size - 1] = '\n';
+		dataBuffer[kp->_size] = '\n';
+		dataBuffer[kp->_size + 1] = '\n';
+		bufSize = kp->_size + 2;
+	} else {
+		dataBuffer = (byte *)malloc(kp->_size);
+		_vm->_resman->read(dataBuffer, kp->_size);
+		bufSize = kp->_size;
+	}
+
+	_readStream = new Common::MemoryReadStream(dataBuffer, bufSize, DisposeAfterUse::YES);
 }
 
 uint32 EncryptedStream::read(void *dataPtr, uint32 dataSize) {






More information about the Scummvm-git-logs mailing list