diff options
author | Eugene Sandulenko | 2019-08-07 23:48:55 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:17:32 +0200 |
commit | 1f02749874d2047d8694ccd5f142326848c54e6c (patch) | |
tree | 53d0eb13d3aa144aa322b0ddfd4663a59afbacf3 /engines/hdb | |
parent | d548d1dfb8f44b9c3c8071518ac4616c961a79fa (diff) | |
download | scummvm-rg350-1f02749874d2047d8694ccd5f142326848c54e6c.tar.gz scummvm-rg350-1f02749874d2047d8694ccd5f142326848c54e6c.tar.bz2 scummvm-rg350-1f02749874d2047d8694ccd5f142326848c54e6c.zip |
HDB: Simplify openMPC()
Diffstat (limited to 'engines/hdb')
-rw-r--r-- | engines/hdb/file-manager.cpp | 86 | ||||
-rw-r--r-- | engines/hdb/file-manager.h | 1 |
2 files changed, 28 insertions, 59 deletions
diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp index c7f39f7893..3af8066fbc 100644 --- a/engines/hdb/file-manager.cpp +++ b/engines/hdb/file-manager.cpp @@ -50,79 +50,49 @@ bool FileMan::openMPC(const Common::String &filename) { _dataHeader.id = _mpcFile->readUint32BE(); if (_dataHeader.id == MKTAG('M', 'P', 'C', 'C')) { - _compressed = true; debug("COMPRESSED MPC FILE"); return false; } else if (_dataHeader.id == MKTAG('M', 'P', 'C', 'U')) { - _compressed = false; - - offset = _mpcFile->readUint32LE(); - _mpcFile->seek((int32)offset); - - // Note: The MPC archive format assumes the offset to be uint32, - // but Common::File::seek() takes the offset as int32. - - _dataHeader.dirSize = _mpcFile->readUint32LE(); - - debug(8, "MPCU: Read %d entries", _dataHeader.dirSize); - - for (uint32 fileIndex = 0; fileIndex < _dataHeader.dirSize; fileIndex++) { - MPCEntry *dirEntry = new MPCEntry(); - - for (int i = 0; i < 64; i++) { - dirEntry->filename[i] = tolower(_mpcFile->readByte()); - } - - dirEntry->offset = _mpcFile->readUint32LE(); - dirEntry->length = _mpcFile->readUint32LE(); - 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); - } - - return true; + // we're fine } else if (_dataHeader.id == MKTAG('M', 'S', 'D', 'C')) { - _compressed = true; - - offset = _mpcFile->readUint32LE(); - _mpcFile->seek((int32)offset); + // we're fine + } else if (_dataHeader.id == MKTAG('M', 'S', 'D', 'U')) { + debug("UNCOMPRESSED MSD FILE"); + return false; + } else { + error("Invalid MPC/MSD File."); + return false; + } - // Note: The MPC archive format assumes the offset to be uint32, - // but Common::File::seek() takes the offset as int32. + // read the directory + offset = _mpcFile->readUint32LE(); + _mpcFile->seek((int32)offset); - _dataHeader.dirSize = _mpcFile->readUint32LE(); + // Note: The MPC archive format assumes the offset to be uint32, + // but Common::File::seek() takes the offset as int32. - debug(8, "MSDC: Read %d entries", _dataHeader.dirSize); + _dataHeader.dirSize = _mpcFile->readUint32LE(); - for (uint32 fileIndex = 0; fileIndex < _dataHeader.dirSize; fileIndex++) { - MPCEntry *dirEntry = new MPCEntry(); + debug(8, "MPCU: Read %d entries", _dataHeader.dirSize); - for (int i = 0; i < 64; i++) { - dirEntry->filename[i] = tolower(_mpcFile->readByte()); - } + for (uint32 fileIndex = 0; fileIndex < _dataHeader.dirSize; fileIndex++) { + MPCEntry *dirEntry = new MPCEntry(); - dirEntry->offset = _mpcFile->readUint32LE(); - dirEntry->length = _mpcFile->readUint32LE(); - dirEntry->ulength = _mpcFile->readUint32LE(); - dirEntry->type = (DataType)_mpcFile->readUint32LE(); + for (int i = 0; i < 64; i++) { + dirEntry->filename[i] = tolower(_mpcFile->readByte()); + } - debug(9, "%d: %s off:%d len:%d ulen: %d type: %d", fileIndex, dirEntry->filename, dirEntry->offset, dirEntry->length, dirEntry->ulength, dirEntry->type); + dirEntry->offset = _mpcFile->readUint32LE(); + dirEntry->length = _mpcFile->readUint32LE(); + dirEntry->ulength = _mpcFile->readUint32LE(); + dirEntry->type = (DataType)_mpcFile->readUint32LE(); - _dir.push_back(dirEntry); - } + debug(9, "%d: %s off:%d len:%d ulen: %d type: %d", fileIndex, dirEntry->filename, dirEntry->offset, dirEntry->length, dirEntry->ulength, dirEntry->type); - return true; - } else if (_dataHeader.id == MKTAG('M', 'S', 'D', 'U')) { - _compressed = false; - debug("UNCOMPRESSED MSD FILE"); - return false; + _dir.push_back(dirEntry); } - error("Invalid MPC/MSD File."); - return false; + return true; } void FileMan::closeMPC() { diff --git a/engines/hdb/file-manager.h b/engines/hdb/file-manager.h index d4cae4ddad..faa8e84062 100644 --- a/engines/hdb/file-manager.h +++ b/engines/hdb/file-manager.h @@ -57,7 +57,6 @@ private: Common::File *_mpcFile; Common::Array<MPCEntry *> _dir; - bool _compressed; public: |