diff options
author | Strangerke | 2012-06-25 23:33:17 +0200 |
---|---|---|
committer | Strangerke | 2012-06-25 23:40:17 +0200 |
commit | 80388527ea891bc9c44cd11ff31afefb253d3eaa (patch) | |
tree | 5b5cc5c41eff88d193206a8d8697bde450d59bf0 /engines | |
parent | 7b44c20eb114515a1117df7f930ed98af0528db4 (diff) | |
download | scummvm-rg350-80388527ea891bc9c44cd11ff31afefb253d3eaa.tar.gz scummvm-rg350-80388527ea891bc9c44cd11ff31afefb253d3eaa.tar.bz2 scummvm-rg350-80388527ea891bc9c44cd11ff31afefb253d3eaa.zip |
CGE: Fix SPR files with extra 0x1A or missing ending CRLF. Fix bug #3537527
Diffstat (limited to 'engines')
-rw-r--r-- | engines/cge/fileio.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/engines/cge/fileio.cpp b/engines/cge/fileio.cpp index c50db4e929..f23105d823 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) { |