[Scummvm-cvs-logs] SF.net SVN: scummvm:[33781] scummvm/trunk/engines/cine/part.cpp
buddha_ at users.sourceforge.net
buddha_ at users.sourceforge.net
Mon Aug 11 22:09:10 CEST 2008
Revision: 33781
http://scummvm.svn.sourceforge.net/scummvm/?rev=33781&view=rev
Author: buddha_
Date: 2008-08-11 20:09:03 +0000 (Mon, 11 Aug 2008)
Log Message:
-----------
Changed readBundleFile to unpack data in-place and added debugging messages to the function.
Modified Paths:
--------------
scummvm/trunk/engines/cine/part.cpp
Modified: scummvm/trunk/engines/cine/part.cpp
===================================================================
--- scummvm/trunk/engines/cine/part.cpp 2008-08-11 19:16:21 UTC (rev 33780)
+++ scummvm/trunk/engines/cine/part.cpp 2008-08-11 20:09:03 UTC (rev 33781)
@@ -221,19 +221,23 @@
byte *readBundleFile(int16 foundFileIdx) {
assert(foundFileIdx >= 0 && foundFileIdx < numElementInPart);
+ bool error = false;
byte *dataPtr = (byte *)calloc(partBuffer[foundFileIdx].unpackedSize, 1);
- if (partBuffer[foundFileIdx].unpackedSize != partBuffer[foundFileIdx].packedSize) {
- byte *unpackBuffer = (byte *)malloc(partBuffer[foundFileIdx].packedSize);
- readFromPart(foundFileIdx, unpackBuffer);
+ readFromPart(foundFileIdx, dataPtr);
+ if (partBuffer[foundFileIdx].unpackedSize > partBuffer[foundFileIdx].packedSize) {
CineUnpacker cineUnpacker;
- if (!cineUnpacker.unpack(unpackBuffer, partBuffer[foundFileIdx].packedSize, dataPtr, partBuffer[foundFileIdx].unpackedSize)) {
- warning("Error unpacking '%s' from bundle file '%s'", partBuffer[foundFileIdx].partName, currentPartName);
- }
- free(unpackBuffer);
- } else {
- readFromPart(foundFileIdx, dataPtr);
+ error = !cineUnpacker.unpack(dataPtr, partBuffer[foundFileIdx].packedSize, dataPtr, partBuffer[foundFileIdx].unpackedSize);
+ } else if (partBuffer[foundFileIdx].unpackedSize < partBuffer[foundFileIdx].packedSize) {
+ // Unpacked size of a file should never be less than its packed size
+ error = true;
+ } else { // partBuffer[foundFileIdx].unpackedSize == partBuffer[foundFileIdx].packedSize
+ debugC(5, kCineDebugPart, "Loaded non-compressed file '%s' from bundle file '%s'", partBuffer[foundFileIdx].partName, currentPartName);
}
+ if (error) {
+ warning("Error unpacking '%s' from bundle file '%s'", partBuffer[foundFileIdx].partName, currentPartName);
+ }
+
return dataPtr;
}
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