[Scummvm-cvs-logs] SF.net SVN: scummvm: [23843] scummvm/trunk/engines/kyra/resource.cpp
agent-q at users.sourceforge.net
agent-q at users.sourceforge.net
Sat Sep 9 14:21:54 CEST 2006
Revision: 23843
http://svn.sourceforge.net/scummvm/?rev=23843&view=rev
Author: agent-q
Date: 2006-09-09 05:21:49 -0700 (Sat, 09 Sep 2006)
Log Message:
-----------
Fixed a bug in loadPakFile(), and changed PAKFile constructor so that it doesn't load the entire file.
Modified Paths:
--------------
scummvm/trunk/engines/kyra/resource.cpp
Modified: scummvm/trunk/engines/kyra/resource.cpp
===================================================================
--- scummvm/trunk/engines/kyra/resource.cpp 2006-09-09 10:47:32 UTC (rev 23842)
+++ scummvm/trunk/engines/kyra/resource.cpp 2006-09-09 12:21:49 UTC (rev 23843)
@@ -94,8 +94,9 @@
return true;
uint32 size = 0;
- FilesystemNode *fsNode = new FilesystemNode(filename);
+ FilesystemNode *fsNode = new FilesystemNode(ConfMan.get("path") + filename);
+
Common::File handle;
if (!fileHandle(filename.c_str(), &size, handle)) {
warning("couldn't load file: '%s'", filename.c_str());
@@ -265,38 +266,43 @@
}
uint32 filesize = pakfile.size();
- buffer = new uint8[filesize];
- assert(buffer);
- pakfile.read(buffer, filesize);
- pakfile.close();
-
// works with the file
uint32 pos = 0, startoffset = 0, endoffset = 0;
+
+ uint32 startOffsetFromFile;
+ pakfile.read(&startOffsetFromFile, sizeof(uint32));
if (!_isAmiga) {
- startoffset = READ_LE_UINT32(buffer + pos);
+ startoffset = READ_LE_UINT32(&startOffsetFromFile);
} else {
- startoffset = READ_BE_UINT32(buffer + pos);
+ startoffset = READ_BE_UINT32(&startOffsetFromFile);
}
pos += 4;
while (pos < filesize) {
PakChunk chunk;
-
- // saves the name
- if (!(*((const char*)buffer + pos)))
+ uint8 buffer[256];
+ uint32 nameLength;
+
+ // Move to the position of the next file entry
+ pakfile.seek(pos);
+
+ // Read in the header
+ pakfile.read(&buffer, 256);
+
+ // Quit now if we encounter an empty string
+ if (!(*((const char*)buffer)))
break;
- chunk._name = (const char*)buffer + pos;
- pos += strlen(chunk._name.c_str()) + 1;
+ chunk._name = (const char*)buffer;
+ nameLength = strlen(chunk._name.c_str()) + 1;
if (!_isAmiga) {
- endoffset = READ_LE_UINT32(buffer + pos);
+ endoffset = READ_LE_UINT32(buffer + nameLength);
} else {
- endoffset = READ_BE_UINT32(buffer + pos);
+ endoffset = READ_BE_UINT32(buffer + nameLength);
}
- pos += 4;
if (endoffset == 0) {
endoffset = filesize;
@@ -311,9 +317,9 @@
break;
startoffset = endoffset;
+ pos += nameLength + 4;
}
_open = true;
- delete [] buffer;
_filename = file;
_physfile = physfile;
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