diff options
author | Johannes Schickel | 2008-02-09 14:40:52 +0000 |
---|---|---|
committer | Johannes Schickel | 2008-02-09 14:40:52 +0000 |
commit | 166698d29dc267f52e715d0d229b3e082d47718c (patch) | |
tree | 12472568a577e769821b5c986689bf31f2d5612d /engines/kyra/resource.cpp | |
parent | c98b51e40c126da037d44ee5e097cf08f33e442a (diff) | |
download | scummvm-rg350-166698d29dc267f52e715d0d229b3e082d47718c.tar.gz scummvm-rg350-166698d29dc267f52e715d0d229b3e082d47718c.tar.bz2 scummvm-rg350-166698d29dc267f52e715d0d229b3e082d47718c.zip |
Cleanup.
svn-id: r30832
Diffstat (limited to 'engines/kyra/resource.cpp')
-rw-r--r-- | engines/kyra/resource.cpp | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/engines/kyra/resource.cpp b/engines/kyra/resource.cpp index d8e4eb2f5e..b96b3c00dd 100644 --- a/engines/kyra/resource.cpp +++ b/engines/kyra/resource.cpp @@ -405,40 +405,32 @@ bool ResLoaderPak::loadFile(const Common::String &filename, Common::SeekableRead Common::List<Common::String> filenames; Common::List<ResFileEntry> entries; - uint32 pos = 0, startoffset = 0, endoffset = 0; + uint32 startoffset = 0, endoffset = 0; bool switchEndian = false; - startoffset = stream.readUint32LE(); pos += 4; + startoffset = stream.readUint32LE(); if (startoffset > filesize) { switchEndian = true; startoffset = SWAP_BYTES_32(startoffset); } - while (pos < filesize) { - uint8 buffer[64]; - uint32 nameLength; + while (!stream.eos()) { + Common::String file = ""; + byte c = 0; - // Move to the position of the next file entry - stream.seek(pos); + while (!stream.eos() && (c = stream.readByte()) != 0) + file += c; - // Read in the header - if (stream.read(&buffer, 64) < 5) { + if (stream.eos()) { warning("PAK file '%s' is corrupted", filename.c_str()); return false; } // Quit now if we encounter an empty string - if (!(*((const char*)buffer))) + if (file.empty()) break; - nameLength = strlen((const char*)buffer) + 1; - - if (nameLength > 60) { - warning("PAK file '%s' is corrupted", filename.c_str()); - return false; - } - - endoffset = (switchEndian ? READ_BE_UINT32 : READ_LE_UINT32)(buffer + nameLength); + endoffset = switchEndian ? stream.readUint32BE() : stream.readUint32LE(); if (!endoffset) endoffset = filesize; @@ -453,7 +445,7 @@ bool ResLoaderPak::loadFile(const Common::String &filename, Common::SeekableRead entry.prot = false; entry.preload = false; - filenames.push_back(Common::String((const char*)buffer)); + filenames.push_back(file); entries.push_back(entry); } @@ -461,7 +453,6 @@ bool ResLoaderPak::loadFile(const Common::String &filename, Common::SeekableRead break; startoffset = endoffset; - pos += nameLength + 4; } assert(filenames.size() == entries.size()); |