[Scummvm-cvs-logs] CVS: scummvm/gob goblin.cpp,1.32,1.33 goblin.h,1.10,1.11 map.cpp,1.22,1.23

Eugene Sandulenko sev at users.sourceforge.net
Fri Jan 27 15:20:02 CET 2006


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

Modified Files:
	goblin.cpp goblin.h map.cpp 
Log Message:
Patch #1416983: "gobliiins 64bit fixes" to fix bug #1399873: "GOB1: 64-bit 
crash at load screen". Thanks, wjp.


Index: goblin.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/goblin.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- goblin.cpp	18 Jan 2006 17:39:34 -0000	1.32
+++ goblin.cpp	27 Jan 2006 23:19:18 -0000	1.33
@@ -1835,19 +1835,19 @@
 
 		for (state = 0; state < 40; state++) {
 			for (col = 0; col < 6; col++) {
-				free(_goblins[i]->stateMach[state][col]);
+				delete _goblins[i]->stateMach[state][col];
 				_goblins[i]->stateMach[state][col] = 0;
 			}
 		}
 
 		if (i == 3) {
 			for (state = 40; state < 70; state++) {
-				free(_goblins[3]->stateMach[state][0]);
+				delete _goblins[3]->stateMach[state][0];
 				_goblins[3]->stateMach[state][0] = 0;
 			}
 		}
 
-		free(_goblins[i]->stateMach);
+		delete[] _goblins[i]->stateMach;
 		free(_goblins[i]);
 		_goblins[i] = 0;
 	}
@@ -1860,12 +1860,12 @@
 
 		for (state = 0; state < 40; state++) {
 			for (col = 0; col < 6; col++) {
-				free(_objects[i]->stateMach[state][col]);
+				delete _objects[i]->stateMach[state][col];
 				_objects[i]->stateMach[state][col] = 0;
 			}
 		}
 
-		free(_objects[i]->stateMach);
+		delete[] _objects[i]->stateMach;
 		free(_objects[i]);
 		_objects[i] = 0;
 	}

Index: goblin.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/goblin.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- goblin.h	18 Jan 2006 17:39:34 -0000	1.10
+++ goblin.h	27 Jan 2006 23:19:18 -0000	1.11
@@ -47,7 +47,6 @@
 
 	typedef Gob_State *Gob_PState;
 
-#define szGob_StateLine 24
 	typedef Gob_PState Gob_StateLine[6];
 
 	typedef struct Gob_Object {

Index: map.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/map.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- map.cpp	18 Jan 2006 17:39:34 -0000	1.22
+++ map.cpp	27 Jan 2006 23:19:18 -0000	1.23
@@ -527,12 +527,17 @@
 		savedPtr2 += 2;
 
 		if (i == 3)
-			_vm->_goblin->_goblins[i]->stateMach = (Goblin::Gob_StateLine *)malloc(szGob_StateLine * 70);
+			_vm->_goblin->_goblins[i]->stateMach = new Goblin::Gob_StateLine[70];
 		else
-			_vm->_goblin->_goblins[i]->stateMach = (Goblin::Gob_StateLine *)malloc(szGob_StateLine * 40);
+			_vm->_goblin->_goblins[i]->stateMach = new Goblin::Gob_StateLine[40];
 
-		// FIXME: All is wrong further. We should unwind calls to loadDataFromAvo()
-		loadDataFromAvo((char *)_vm->_goblin->_goblins[i]->stateMach, 40 * szGob_StateLine);
+		uint32* tempstatedata = new uint32[40*6];
+		for (state = 0; state < 40; ++state) {
+			for (col = 0; col < 6; ++col) {
+				tempstatedata[state*6+col] = READ_LE_UINT32(_avoDataPtr);
+				_avoDataPtr += 4;
+			}
+		}
 		_avoDataPtr += 160;
 		_vm->_goblin->_goblins[i]->multObjIndex = *_avoDataPtr;
 		_avoDataPtr += 2;
@@ -540,10 +545,12 @@
 		_vm->_goblin->_goblins[i]->realStateMach = _vm->_goblin->_goblins[i]->stateMach;
 		for (state = 0; state < 40; state++) {
 			for (col = 0; col < 6; col++) {
-				if (_vm->_goblin->_goblins[i]->stateMach[state][col] == 0)
+				if (tempstatedata[state*6+col] == 0) {
+					_vm->_goblin->_goblins[i]->stateMach[state][col] = 0;
 					continue;
+				}
 
-				Goblin::Gob_State *tmpState = (Goblin::Gob_State *)malloc(sizeof(Goblin::Gob_State));
+				Goblin::Gob_State *tmpState = new Goblin::Gob_State;
 				_vm->_goblin->_goblins[i]->stateMach[state][col] = tmpState;
 
 				tmpState->animation = loadFromAvo_LE_UINT16();
@@ -565,9 +572,10 @@
 				tmpState->sndFrame = loadFromAvo_LE_UINT16();
 			}
 		}
+		delete[] tempstatedata;
 	}
 
-	pState = (Goblin::Gob_State *)malloc(sizeof(Goblin::Gob_State));
+	pState = new Goblin::Gob_State;
 	_vm->_goblin->_goblins[0]->stateMach[39][0] = pState;
 	pState->animation = 0;
 	pState->layer = 98;
@@ -575,7 +583,7 @@
 	pState->unk1 = 0;
 	pState->sndItem = -1;
 
-	pState = (Goblin::Gob_State *) malloc(sizeof(Goblin::Gob_State));
+	pState = new Goblin::Gob_State;
 	_vm->_goblin->_goblins[1]->stateMach[39][0] = pState;
 	pState->animation = 0;
 	pState->layer = 99;
@@ -583,7 +591,7 @@
 	pState->unk1 = 0;
 	pState->sndItem = -1;
 
-	pState = (Goblin::Gob_State *) malloc(sizeof(Goblin::Gob_State));
+	pState = new Goblin::Gob_State;
 	_vm->_goblin->_goblins[2]->stateMach[39][0] = pState;
 	pState->animation = 0;
 	pState->layer = 100;
@@ -600,7 +608,7 @@
 	_vm->_goblin->_goblins[1]->stateMach[11][0]->sndFrame = 13;
 
 	for (state = 40; state < 70; state++) {
-		pState = (Goblin::Gob_State *)malloc(sizeof(Goblin::Gob_State));
+		pState = new Goblin::Gob_State;
 		_vm->_goblin->_goblins[3]->stateMach[state][0] = pState;
 		_vm->_goblin->_goblins[3]->stateMach[state][1] = 0;
 
@@ -627,9 +635,15 @@
 		_vm->_goblin->_objects[i]->state = READ_LE_UINT16(savedPtr3);
 		savedPtr3 += 2;
 
-		_vm->_goblin->_objects[i]->stateMach = (Goblin::Gob_StateLine *)malloc(szGob_StateLine * 40);
+		_vm->_goblin->_objects[i]->stateMach = new Goblin::Gob_StateLine[40];
 
-		loadDataFromAvo((char *)_vm->_goblin->_objects[i]->stateMach, 40 * szGob_StateLine);
+		uint32* tempstatedata = new uint32[40*6];
+		for (state = 0; state < 40; ++state) {
+			for (col = 0; col < 6; ++col) {
+				tempstatedata[state*6+col] = READ_LE_UINT32(_avoDataPtr);
+				_avoDataPtr += 4;
+			}
+		}
 		_avoDataPtr += 160;
 		_vm->_goblin->_objects[i]->multObjIndex = *_avoDataPtr;
 		_avoDataPtr += 2;
@@ -637,10 +651,12 @@
 		_vm->_goblin->_objects[i]->realStateMach = _vm->_goblin->_objects[i]->stateMach;
 		for (state = 0; state < 40; state++) {
 			for (col = 0; col < 6; col++) {
-				if (_vm->_goblin->_objects[i]->stateMach[state][col] == 0)
+				if (tempstatedata[state*6+col] == 0) {
+					_vm->_goblin->_objects[i]->stateMach[state][col] = 0;
 					continue;
+				}
 
-				Goblin::Gob_State *tmpState = (Goblin::Gob_State *)malloc(sizeof(Goblin::Gob_State));
+				Goblin::Gob_State *tmpState = new Goblin::Gob_State;
 				_vm->_goblin->_objects[i]->stateMach[state][col] = tmpState;
 
 				tmpState->animation = loadFromAvo_LE_UINT16();
@@ -662,15 +678,18 @@
 				tmpState->sndFrame = loadFromAvo_LE_UINT16();
 			}
 		}
+		delete[] tempstatedata;
 	}
 
 	_vm->_goblin->_objects[10] = (Goblin::Gob_Object *)malloc(sizeof(Goblin::Gob_Object));
 	memset(_vm->_goblin->_objects[10], 0, sizeof(Goblin::Gob_Object));
 
-	_vm->_goblin->_objects[10]->stateMach = (Goblin::Gob_StateLine *)malloc(szGob_StateLine * 40);
-	memset(_vm->_goblin->_objects[10]->stateMach, 0, szGob_StateLine * 40);
+	_vm->_goblin->_objects[10]->stateMach = new Goblin::Gob_StateLine[40];
+	for (state = 0; state < 40; ++state)
+		for (col = 0; col < 6; ++col)
+			_vm->_goblin->_objects[10]->stateMach[state][col] = 0;
 
-	pState = (Goblin::Gob_State *)malloc(sizeof(Goblin::Gob_State));
+	pState = new Goblin::Gob_State;
 	_vm->_goblin->_objects[10]->stateMach[0][0] = pState;
 
 	memset(pState, 0, sizeof(Goblin::Gob_State));





More information about the Scummvm-git-logs mailing list