[Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.432,2.433 resource.cpp,1.309,1.310 resource_v2.cpp,1.48,1.49 resource_v3.cpp,1.36,1.37 resource_v4.cpp,1.21,1.22 resource_v7he.cpp,1.29,1.30 scumm.cpp,1.418,1.419

Max Horn fingolfin at users.sourceforge.net
Sat Apr 9 17:52:27 CEST 2005


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5682

Modified Files:
	intern.h resource.cpp resource_v2.cpp resource_v3.cpp 
	resource_v4.cpp resource_v7he.cpp scumm.cpp 
Log Message:
Don't call allocateArrays from readMAXS, rather call it explicitly after calling readMAXS; init _palManipCounter in the proper place (only needed when restarting); free palManip data on exit

Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.432
retrieving revision 2.433
diff -u -d -r2.432 -r2.433
--- intern.h	9 Apr 2005 20:26:51 -0000	2.432
+++ intern.h	10 Apr 2005 00:51:47 -0000	2.433
@@ -261,6 +261,7 @@
 	virtual void readIndexFile();
 	void readClassicIndexFile();	// V1
 	void readEnhancedIndexFile();	// V2
+	virtual void readGlobalObjects();
 	virtual void loadCharset(int no);
 
 

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource.cpp,v
retrieving revision 1.309
retrieving revision 1.310
diff -u -d -r1.309 -r1.310
--- resource.cpp	10 Apr 2005 00:33:30 -0000	1.309
+++ resource.cpp	10 Apr 2005 00:51:47 -0000	1.310
@@ -410,6 +410,7 @@
 
 		case MKID('MAXS'):
 			readMAXS(itemsize);
+			allocateArrays();
 			break;
 
 		case MKID('DIRN'):
@@ -984,8 +985,6 @@
 
 	if (_shadowPaletteSize)
 		_shadowPalette = (byte *)calloc(_shadowPaletteSize, 1);
-
-	allocateArrays();
 }
 
 void ScummEngine_v8::readMAXS(int blockSize) {
@@ -1015,8 +1014,6 @@
 
 	_shadowPaletteSize = NUM_SHADOW_PALETTE * 256;
 	_shadowPalette = (byte *)calloc(_shadowPaletteSize, 1);
-
-	allocateArrays();
 }
 
 void ScummEngine_v7::readMAXS(int blockSize) {
@@ -1049,8 +1046,6 @@
 
 	_shadowPaletteSize = NUM_SHADOW_PALETTE * 256;
 	_shadowPalette = (byte *)calloc(_shadowPaletteSize, 1);
-
-	allocateArrays();
 }
 
 void ScummEngine_v6::readMAXS(int blockSize) {
@@ -1082,8 +1077,6 @@
 
 	_shadowPaletteSize = 256;
 	_shadowPalette = (byte *)calloc(_shadowPaletteSize, 1);
-
-	allocateArrays();
 }
 
 void ScummEngine::readGlobalObjects() {

Index: resource_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource_v2.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- resource_v2.cpp	3 Apr 2005 23:53:34 -0000	1.48
+++ resource_v2.cpp	10 Apr 2005 00:51:47 -0000	1.49
@@ -65,11 +65,7 @@
 	_fileHandle->seek(0, SEEK_SET);
 
 	readMAXS(0);
-
-	// Jamieson630: palManipulate variable initialization
-	_palManipCounter = 0;
-	_palManipPalette = 0; // Will allocate when needed
-	_palManipIntermediatePal = 0; // Will allocate when needed
+	allocateArrays();
 
 	_fileHandle->readUint16LE(); /* version magic number */
 	for (i = 0; i != _numGlobalObjects; i++) {
@@ -122,7 +118,7 @@
 		_musicEngine = new Player_V2(this, _midiDriver != MD_PCSPK);
 
 	_numGlobalObjects = _fileHandle->readUint16LE();
-	_fileHandle->seek(_numGlobalObjects, SEEK_CUR); // Skip object flags
+	_fileHandle->seek(_numGlobalObjects, SEEK_CUR);
 	_numRooms = _fileHandle->readByte();
 	_fileHandle->seek(_numRooms * 3, SEEK_CUR);
 	_numCostumes = _fileHandle->readByte();
@@ -135,24 +131,26 @@
 	_fileHandle->seek(0, SEEK_SET);
 
 	readMAXS(0);
-
-	// Jamieson630: palManipulate variable initialization
-	_palManipCounter = 0;
-	_palManipPalette = 0; // Will allocate when needed
-	_palManipIntermediatePal = 0; // Will allocate when needed
+	allocateArrays();
 
 	_fileHandle->readUint16LE(); /* version magic number */
+	readGlobalObjects();
+	readResTypeList(rtRoom, MKID('ROOM'), "room");
+	readResTypeList(rtCostume, MKID('COST'), "costume");
+	readResTypeList(rtScript, MKID('SCRP'), "script");
+	readResTypeList(rtSound, MKID('SOUN'), "sound");
+}
+
+void ScummEngine_v2::readGlobalObjects() {
+	int i;
 	int num = _fileHandle->readUint16LE();
 	assert(num == _numGlobalObjects);
-	for (int i = 0; i != num; i++) {
+
+	for (i = 0; i != num; i++) {
 		byte tmp = _fileHandle->readByte();
 		_objectOwnerTable[i] = tmp & OF_OWNER_MASK;
 		_objectStateTable[i] = tmp >> OF_STATE_SHL;
 	}
-	readResTypeList(rtRoom, MKID('ROOM'), "room");
-	readResTypeList(rtCostume, MKID('COST'), "costume");
-	readResTypeList(rtScript, MKID('SCRP'), "script");
-	readResTypeList(rtSound, MKID('SOUN'), "sound");
 }
 
 void ScummEngine_v2::readIndexFile() {

Index: resource_v3.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource_v3.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- resource_v3.cpp	6 Apr 2005 17:31:08 -0000	1.36
+++ resource_v3.cpp	10 Apr 2005 00:51:47 -0000	1.37
@@ -81,11 +81,7 @@
 	_fileHandle->seek(0, SEEK_SET);
 
 	readMAXS(0);
-
-	// Jamieson630: palManipulate variable initialization
-	_palManipCounter = 0;
-	_palManipPalette = 0; // Will allocate when needed
-	_palManipIntermediatePal = 0; // Will allocate when needed
+	allocateArrays();
 
 	_fileHandle->readUint16LE(); /* version magic number */
 	readGlobalObjects();

Index: resource_v4.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource_v4.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- resource_v4.cpp	10 Apr 2005 00:33:30 -0000	1.21
+++ resource_v4.cpp	10 Apr 2005 00:51:47 -0000	1.22
@@ -71,11 +71,7 @@
 	_fileHandle->seek(0, SEEK_SET);
 
 	readMAXS(0);
-
-	// Jamieson630: palManipulate variable initialization
-	_palManipCounter = 0;
-	_palManipPalette = 0; // Will allocate when needed
-	_palManipIntermediatePal = 0; // Will allocate when needed
+	allocateArrays();
 
 	while (1) {
 		itemsize = _fileHandle->readUint32LE();
@@ -165,7 +161,6 @@
 	_shadowPaletteSize = 256;
 
 	_shadowPalette = (byte *) calloc(_shadowPaletteSize, 1);	// FIXME - needs to be removed later
-	allocateArrays();
 }
 
 void ScummEngine_v4::readGlobalObjects() {

Index: resource_v7he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource_v7he.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- resource_v7he.cpp	10 Apr 2005 00:33:30 -0000	1.29
+++ resource_v7he.cpp	10 Apr 2005 00:51:47 -0000	1.30
@@ -1686,8 +1686,6 @@
 
 	_objectRoomTable = (byte *)calloc(_numGlobalObjects, 1);
 	_numGlobalScripts = 2048;
-
-	allocateArrays();
 }
 
 void ScummEngine_v90he::readMAXS(int blockSize) {
@@ -1719,8 +1717,6 @@
 		_numGlobalScripts = 2048;
 	else
 		_numGlobalScripts = 200;
-
-	allocateArrays();
 }
 
 void ScummEngine_v72he::readMAXS(int blockSize) {
@@ -1746,8 +1742,6 @@
 
 	_objectRoomTable = (byte *)calloc(_numGlobalObjects, 1);
 	_numGlobalScripts = 200;
-
-	allocateArrays();
 }
 
 byte *ScummEngine_v72he::getStringAddress(int i) {

Index: scumm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.cpp,v
retrieving revision 1.418
retrieving revision 1.419
diff -u -d -r1.418 -r1.419
--- scumm.cpp	10 Apr 2005 00:33:30 -0000	1.418
+++ scumm.cpp	10 Apr 2005 00:51:47 -0000	1.419
@@ -1169,6 +1169,9 @@
 	delete _costumeRenderer;
 
 	free(_shadowPalette);
+
+	free(_palManipPalette);
+	free(_palManipIntermediatePal);
 	
 	res.freeResources();
 	if (_heversion >= 70) {
@@ -1403,6 +1406,8 @@
 		initScreens(16, 144);
 	}
 
+	_palManipCounter = 0;
+
 	for (i = 0; i < 256; i++)
 		_roomPalette[i] = i;
 	if (_version == 1) {





More information about the Scummvm-git-logs mailing list