[Scummvm-cvs-logs] SF.net SVN: scummvm: [30832] scummvm/trunk/engines/kyra/resource.cpp

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sat Feb 9 15:40:52 CET 2008


Revision: 30832
          http://scummvm.svn.sourceforge.net/scummvm/?rev=30832&view=rev
Author:   lordhoto
Date:     2008-02-09 06:40:52 -0800 (Sat, 09 Feb 2008)

Log Message:
-----------
Cleanup.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/resource.cpp

Modified: scummvm/trunk/engines/kyra/resource.cpp
===================================================================
--- scummvm/trunk/engines/kyra/resource.cpp	2008-02-08 18:45:25 UTC (rev 30831)
+++ scummvm/trunk/engines/kyra/resource.cpp	2008-02-09 14:40:52 UTC (rev 30832)
@@ -405,41 +405,33 @@
 	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;
+		endoffset = switchEndian ? stream.readUint32BE() : stream.readUint32LE();
 
-		if (nameLength > 60) {
-			warning("PAK file '%s' is corrupted", filename.c_str());
-			return false;
-		}
-
-		endoffset = (switchEndian ? READ_BE_UINT32 : READ_LE_UINT32)(buffer + nameLength);
-
 		if (!endoffset)
 			endoffset = filesize;
 
@@ -453,7 +445,7 @@
 			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 @@
 			break;
 
 		startoffset = endoffset;
-		pos += nameLength + 4;
 	}
 
 	assert(filenames.size() == entries.size());


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list