diff options
author | Eugene Sandulenko | 2019-08-06 09:36:18 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:17:32 +0200 |
commit | f11c3afea9542144e6e629e371ea097e622c3d59 (patch) | |
tree | d27d214430f823e89f6c6eeb895d313517cb331e | |
parent | 361f47ff54a981bc5d506a2c18b3ff2a040a0637 (diff) | |
download | scummvm-rg350-f11c3afea9542144e6e629e371ea097e622c3d59.tar.gz scummvm-rg350-f11c3afea9542144e6e629e371ea097e622c3d59.tar.bz2 scummvm-rg350-f11c3afea9542144e6e629e371ea097e622c3d59.zip |
HDB: Fix file len usage in compressed MSD files
-rw-r--r-- | engines/hdb/file-manager.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp index c437cfd643..cafc9cd578 100644 --- a/engines/hdb/file-manager.cpp +++ b/engines/hdb/file-manager.cpp @@ -53,8 +53,7 @@ bool FileMan::openMPC(const Common::String &filename) { _compressed = true; debug("COMPRESSED MPC FILE"); return false; - } - else if (_dataHeader.id == MKTAG('M', 'P', 'C', 'U')) { + } else if (_dataHeader.id == MKTAG('M', 'P', 'C', 'U')) { _compressed = false; offset = _mpcFile->readUint32LE(); @@ -79,6 +78,8 @@ bool FileMan::openMPC(const Common::String &filename) { dirEntry->ulength = _mpcFile->readUint32LE(); dirEntry->type = (DataType)_mpcFile->readUint32LE(); + debug(9, "%d: %s off:%d len:%d ulen: %d type: %d", fileIndex, dirEntry->filename, dirEntry->offset, dirEntry->length, dirEntry->ulength, dirEntry->type); + _dir.push_back(dirEntry); } @@ -108,6 +109,8 @@ bool FileMan::openMPC(const Common::String &filename) { dirEntry->ulength = _mpcFile->readUint32LE(); dirEntry->type = (DataType)_mpcFile->readUint32LE(); + debug(9, "%d: %s off:%d len:%d ulen: %d type: %d", fileIndex, dirEntry->filename, dirEntry->offset, dirEntry->length, dirEntry->ulength, dirEntry->type); + _dir.push_back(dirEntry); } @@ -166,16 +169,16 @@ Common::SeekableReadStream *FileMan::findFirstData(const char *string, DataType // Load corresponding file into a buffer _mpcFile->seek(file->offset); - byte *buffer = (byte *)malloc(file->ulength * sizeof(byte)); + byte *buffer = (byte *)malloc(file->length); - _mpcFile->read(buffer, file->ulength); + _mpcFile->read(buffer, file->length); // Return buffer wrapped in a MemoryReadStream if (_compressed) - return Common::wrapCompressedReadStream(new Common::MemoryReadStream(buffer, file->ulength, DisposeAfterUse::YES)); + return Common::wrapCompressedReadStream(new Common::MemoryReadStream(buffer, file->length, DisposeAfterUse::YES)); else - return new Common::MemoryReadStream(buffer, file->ulength, DisposeAfterUse::YES); + return new Common::MemoryReadStream(buffer, file->length, DisposeAfterUse::YES); } int32 FileMan::getLength(const char *string, DataType type) { |