From e5cf0332f2d08c7f6bc45c1f1fd8edaf276ea76d Mon Sep 17 00:00:00 2001 From: Borja Lorente Date: Tue, 16 Aug 2016 12:45:08 +0200 Subject: MACVENTURE: Break up one-line ifs and fix braces --- engines/macventure/container.cpp | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'engines/macventure/container.cpp') diff --git a/engines/macventure/container.cpp b/engines/macventure/container.cpp index 1781f96a07..ff98d6961f 100644 --- a/engines/macventure/container.cpp +++ b/engines/macventure/container.cpp @@ -27,18 +27,21 @@ namespace MacVenture { Container::Container(Common::String filename) { _filename = filename; - if (!_file.open(_filename)) + if (!_file.open(_filename)) { error("CONTAINER: Could not open %s", _filename.c_str()); + } _res = _file.readStream(_file.size()); _header = _res->readUint32BE(); _simplified = false; - for (uint i = 0; i < 16; ++i) + for (uint i = 0; i < 16; ++i) { _huff.push_back(0); + } - for (uint i = 0; i < 16; ++i) + for (uint i = 0; i < 16; ++i) { _lens.push_back(0); + } if (!(_header & 0x80000000)) { // Is simplified container @@ -51,16 +54,19 @@ Container::Container(Common::String filename) { _res->seek(_header, SEEK_SET); _numObjs = _res->readUint16BE(); - for (uint i = 0; i < 15; ++i) + for (uint i = 0; i < 15; ++i) { _huff[i] = _res->readUint16BE(); + } - for (uint i = 0; i < 16; ++i) + for (uint i = 0; i < 16; ++i) { _lens[i] = _res->readByte(); + } // Read groups uint numGroups = _numObjs / 64; - if ((_numObjs % 64) > 0) + if ((_numObjs % 64) > 0) { numGroups++; + } for (uint i = 0; i < numGroups; ++i) { ItemGroup group; @@ -94,7 +100,9 @@ Container::Container(Common::String filename) { // Look in the Huffman table int x = 0; for (x = 0; x < 16; x++) { - if (_huff[x] > mask) break; + if (_huff[x] > mask) { + break; + } } // I will opt to copy the code from webventure, @@ -116,8 +124,11 @@ Container::Container(Common::String filename) { length = _res->readUint32BE(); _res->seek(-4, SEEK_CUR); bitSize--; - if (bitSize == 0) length = 0; - else length >>= (32 - bitSize) - bits; + if (bitSize == 0) { + length = 0; + } else { + length >>= (32 - bitSize) - bits; + } length &= (1 << bitSize) - 1; length |= 1 << bitSize; bits += bitSize; @@ -126,11 +137,9 @@ Container::Container(Common::String filename) { _res->seek(2, SEEK_CUR); } } - group.lengths[j] = length; debugC(4, kMVDebugContainer, "Load legth of object %d:%d is %d", i, j, length); } - _groups.push_back(group); } } @@ -166,9 +175,7 @@ Common::SeekableReadStream *Container::getItem(uint32 id) { for (uint i = 0; i < objectIndex; i++) { offset += _groups[groupID].lengths[i]; } - _res->seek(_groups[groupID].offset + offset + sizeof(_header), SEEK_SET); - } // HACK Should Limit the size of the stream returned -- cgit v1.2.3