[Scummvm-cvs-logs] SF.net SVN: scummvm:[33783] scummvm/trunk/engines/cine

buddha_ at users.sourceforge.net buddha_ at users.sourceforge.net
Mon Aug 11 22:41:17 CEST 2008


Revision: 33783
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33783&view=rev
Author:   buddha_
Date:     2008-08-11 20:41:13 +0000 (Mon, 11 Aug 2008)

Log Message:
-----------
Changed partBuffer from a pointer to a Common::Array. Removed numElementInPart variable as it's now equivalent with partBuffer.size().

Modified Paths:
--------------
    scummvm/trunk/engines/cine/cine.cpp
    scummvm/trunk/engines/cine/part.cpp
    scummvm/trunk/engines/cine/part.h

Modified: scummvm/trunk/engines/cine/cine.cpp
===================================================================
--- scummvm/trunk/engines/cine/cine.cpp	2008-08-11 20:18:33 UTC (rev 33782)
+++ scummvm/trunk/engines/cine/cine.cpp	2008-08-11 20:41:13 UTC (rev 33783)
@@ -75,7 +75,6 @@
 	Common::clearAllSpecialDebugLevels();
 
 	free(palPtr);
-	free(partBuffer);
 	free(textDataPtr);
 }
 
@@ -154,7 +153,9 @@
 	collisionPage = new byte[320 * 200];
 	textDataPtr = (byte *)malloc(8000);
 
-	partBuffer = (PartBuffer *)malloc(NUM_MAX_PARTDATA * sizeof(PartBuffer));
+	// Clear part buffer as there's nothing loaded into it yet.
+	// Its size will change when loading data into it with the loadPart function.
+	partBuffer.clear();
 
 	if (g_cine->getGameType() == Cine::GType_OS) {
 		readVolCnf();

Modified: scummvm/trunk/engines/cine/part.cpp
===================================================================
--- scummvm/trunk/engines/cine/part.cpp	2008-08-11 20:18:33 UTC (rev 33782)
+++ scummvm/trunk/engines/cine/part.cpp	2008-08-11 20:41:13 UTC (rev 33783)
@@ -31,13 +31,10 @@
 
 namespace Cine {
 
-uint16 numElementInPart;
+Common::Array<PartBuffer> partBuffer;
 
-PartBuffer *partBuffer;
-
 void loadPart(const char *partName) {
-	memset(partBuffer, 0, sizeof(PartBuffer) * NUM_MAX_PARTDATA);
-	numElementInPart = 0;
+	partBuffer.clear();
 
 	g_cine->_partFileHandle.close();
 
@@ -48,13 +45,14 @@
 
 	setMouseCursor(MOUSE_CURSOR_DISK);
 
-	numElementInPart = g_cine->_partFileHandle.readUint16BE();
+	uint16 numElementInPart = g_cine->_partFileHandle.readUint16BE();
+	partBuffer.resize(numElementInPart);
 	g_cine->_partFileHandle.readUint16BE(); // entry size
 
 	if (currentPartName != partName)
 		strcpy(currentPartName, partName);
 
-	for (uint16 i = 0; i < numElementInPart; i++) {
+	for (uint16 i = 0; i < partBuffer.size(); i++) {
 		g_cine->_partFileHandle.read(partBuffer[i].partName, 14);
 		partBuffer[i].offset = g_cine->_partFileHandle.readUint32BE();
 		partBuffer[i].packedSize = g_cine->_partFileHandle.readUint32BE();
@@ -190,7 +188,7 @@
 int16 findFileInBundle(const char *fileName) {
 	if (g_cine->getGameType() == Cine::GType_OS) {
 		// look first in currently loaded resource file
-		for (int i = 0; i < numElementInPart; i++) {
+		for (uint i = 0; i < partBuffer.size(); i++) {
 			if (!scumm_stricmp(fileName, partBuffer[i].partName)) {
 				return i;
 			}
@@ -204,7 +202,7 @@
 		const char *part = (*it)._value;
 		loadPart(part);
 	}
-	for (int i = 0; i < numElementInPart; i++) {
+	for (uint i = 0; i < partBuffer.size(); i++) {
 		if (!scumm_stricmp(fileName, partBuffer[i].partName)) {
 			return i;
 		}
@@ -220,7 +218,7 @@
 }
 
 byte *readBundleFile(int16 foundFileIdx) {
-	assert(foundFileIdx >= 0 && foundFileIdx < numElementInPart);
+	assert(foundFileIdx >= 0 && foundFileIdx < (int32)partBuffer.size());
 	bool error = false;
 	byte *dataPtr = (byte *)calloc(partBuffer[foundFileIdx].unpackedSize, 1);
 	readFromPart(foundFileIdx, dataPtr, partBuffer[foundFileIdx].unpackedSize);
@@ -304,7 +302,7 @@
 	strcpy(tmpPart, currentPartName);
 
 	loadPart(fileName);
-	for (int i = 0; i < numElementInPart; i++) {
+	for (uint i = 0; i < partBuffer.size(); i++) {
 		byte *data = readBundleFile(i);
 
 		debug(0, "%s", partBuffer[i].partName);

Modified: scummvm/trunk/engines/cine/part.h
===================================================================
--- scummvm/trunk/engines/cine/part.h	2008-08-11 20:18:33 UTC (rev 33782)
+++ scummvm/trunk/engines/cine/part.h	2008-08-11 20:41:13 UTC (rev 33783)
@@ -37,7 +37,7 @@
 
 #define NUM_MAX_PARTDATA 255
 
-extern PartBuffer *partBuffer;
+extern Common::Array<PartBuffer> partBuffer;
 
 void loadPart(const char *partName);
 void closePart(void);


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