[Scummvm-cvs-logs] SF.net SVN: scummvm: [23843] scummvm/trunk/engines/kyra/resource.cpp
Oystein Eftevaag
oystein at geheb.com
Sat Sep 9 14:29:15 CEST 2006
Just a quick note:
FilesystemNode *fsNode = new FilesystemNode(filename);
That was a semi-dirty hack I added to be able to get the basename
of a file, which is needed to be able to actually unload named
PAK files later in the kyra code. With your fix it becomes
somewhat redundant (and breaks Kyra2 :) ).
The best solution would be some proper way of getting the basename of
a file from the File class, really.
agent-q at users.sourceforge.net wrote:
> 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.
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Scummvm-cvs-logs mailing list
> Scummvm-cvs-logs at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/scummvm-cvs-logs
>
More information about the Scummvm-git-logs
mailing list