[Scummvm-cvs-logs] CVS: scummvm/kyra kyra.cpp,1.73,1.74 script_v1.cpp,1.24,1.25 staticres.cpp,1.19,1.20

Johannes Schickel lordhoto at users.sourceforge.net
Sat Nov 26 08:38:01 CET 2005


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

Modified Files:
	kyra.cpp script_v1.cpp staticres.cpp 
Log Message:
Fixed bug that findSubPath did not update the saved facing.


Index: kyra.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/kyra.cpp,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- kyra.cpp	19 Nov 2005 00:16:45 -0000	1.73
+++ kyra.cpp	26 Nov 2005 16:37:20 -0000	1.74
@@ -286,6 +286,7 @@
 	_objectQueue = 0;
 	_animStates = new AnimObject[31];
 	assert(_animStates);
+	memset(_animStates, 0, sizeof(AnimObject)*31);
 	_charactersAnimState = &_animStates[0];
 	_sprites->_animObjects =  &_animStates[5];
 	_animItems = &_animStates[16];
@@ -329,7 +330,7 @@
 	memset(_itemTable, 0, sizeof(_itemTable));
 	memset(_exitList, 0xFFFF, sizeof(_exitList));
 	_exitListPtr = 0;
-	_pathfinderFlag = 0;
+	_pathfinderFlag = _pathfinderFlag2 = 0;
 	_lastFindWayRet = 0;
 	_sceneChangeState = _loopFlag2 = 0;
 	_timerNextRun = 0;
@@ -1337,7 +1338,7 @@
 			if (facing - 1 != 0) {
 				if (facing != 4) {
 					if (facing == 3 || facing == 5) {
-						if (facingIsFour[character] < 2) {
+						if (facingIsFour[character] > 2) {
 							facing = 4;
 						}
 						resetTables = true;
@@ -1351,6 +1352,11 @@
 				}
 				resetTables = true;
 			}
+		} else {
+			if (facingIsZero[character] > 2) {
+				facing = 0;
+			}
+			resetTables = true;
 		}
 		
 		if (resetTables) {
@@ -3158,7 +3164,7 @@
 				delete [] pathTable2;
 				return 0x7D00;
 			}
-			memcpy(&moveTable[lastUsedEntry], pathTable1, temp);
+			memcpy(&moveTable[lastUsedEntry], pathTable1, temp*sizeof(int));
 			lastUsedEntry += temp;
 		} else {
 			if (lastUsedEntry + tempValue > moveTableSize) {
@@ -3166,7 +3172,7 @@
 				delete [] pathTable2;
 				return 0x7D00;
 			}
-			memcpy(&moveTable[lastUsedEntry], pathTable2, tempValue);
+			memcpy(&moveTable[lastUsedEntry], pathTable2, tempValue*sizeof(int));
 			lastUsedEntry += tempValue;
 		}
 		x = curX;
@@ -3188,8 +3194,8 @@
 	static const int8 facingTable1[] = {  7,  0,  1,  2,  3,  4,  5,  6,  1,  2,  3,  4,  5,  6,  7,  0 };
 	static const int8 facingTable2[] = { -1,  0, -1,  2, -1,  4, -1,  6, -1,  2, -1,  4, -1,  6, -1,  0 };
 	static const int8 facingTable3[] = {  2,  4,  4,  6,  6,  0,  0,  2,  6,  6,  0,  0,  2,  2,  4,  4 };
-	static const int8 addPosTable1[] = { -1,  0, -1,  4, -1,  0, -1, -4, -1, -4, -1,  0, -1,  4, -1,  0 };
-	static const int8 addPosTable2[] = { -1,  2, -1,  0, -1, -2, -1,  0, -1,  0, -1,  2, -1,  0, -1, -2 };
+	static const int8 addPosTableX[] = { -1,  0, -1,  4, -1,  0, -1, -4, -1, -4, -1,  0, -1,  4, -1,  0 };
+	static const int8 addPosTableY[] = { -1,  2, -1,  0, -1, -2, -1,  0, -1,  0, -1,  2, -1,  0, -1, -2 };
 	
 	// debug specific
 	//++unkTable[start];
@@ -3215,19 +3221,19 @@
 				ypos1 = y;
 				continue;
 			}
+			newFacing = facingTable1[start*8 + newFacing2];
 			break;
 		}
-		newFacing = newFacing2;
 		// debug drawing
 		//if (xpos1 >= 0 && ypos1 >= 0 && xpos1 < 320 && ypos1 < 200) {
-		//	_screen->setPagePixel(0, xpos1,ypos1, unkTable[start]);
+		//	_screen->setPagePixel(0, xpos1, ypos1, unkTable[start]);
 		//	_screen->updateScreen();
 		//	waitTicks(5);
 		//}
 		if (newFacing & 1) {
-			int temp = xpos1 + addPosTable1[newFacing + start * 8];
+			int temp = xpos1 + addPosTableX[newFacing + start * 8];
 			if (toX == temp) {
-				temp = ypos1 + addPosTable2[newFacing + start * 8];
+				temp = ypos1 + addPosTableY[newFacing + start * 8];
 				if (toY == temp) {
 					moveTable[position++] = facingTable2[newFacing + start * 8];
 					return position;
@@ -3379,7 +3385,8 @@
 	
 	int *oldPosition = moveTable;
 	int *tempPosition = moveTable;
-	int *curPosition = &moveTable[1];
+	int *curPosition = moveTable + 1;
+	retValue = 1;
 
 	while (*curPosition != 8) {
 		if (*oldPosition == facingTable[*curPosition]) {
@@ -3418,16 +3425,21 @@
 			if (tempPosition != oldPosition) {
 				curPosition = oldPosition;
 				oldPosition = tempPosition;
-				if (tempPosition != moveTable) {
+				while (true) {
+					if (tempPosition == moveTable) {
+						break;
+					}
 					--tempPosition;
-					while (*tempPosition == 9) {
-						++tempPosition;
+					if (*tempPosition != 9) {
+						break;
 					}
 				}
 			} else {
-				++curPosition;
-				while (*curPosition == 9) {
+				while (true) {
 					++curPosition;
+					if (*curPosition != 9) {
+						break;
+					}
 				}
 			}
 			continue;
@@ -3436,12 +3448,14 @@
 		tempPosition = oldPosition;
 		oldPosition = curPosition;
 		++retValue;
-		++curPosition;
-		while (*curPosition == 9) {
+		while (true) {
 			++curPosition;
+			if (*curPosition != 9) {
+				break;
+			}
 		}
 	}
-	
+
 	return retValue;
 }
 
@@ -3508,7 +3522,7 @@
 }
 
 int KyraEngine::processSceneChange(int *table, int unk1, int frameReset) {
-	debug(9, "handleSceneChange(0x%X, %d, %d)", table, unk1, frameReset);
+	debug(9, "processSceneChange(0x%X, %d, %d)", table, unk1, frameReset);
 	if (queryGameFlag(0xEF)) {
 		unk1 = 0;
 	}
@@ -3517,7 +3531,7 @@
 	_loopFlag2 = 0;
 	bool running = true;
 	int returnValue = 0;
-	uint32 nextFrame;
+	uint32 nextFrame = 0;
 	while (running) {
 		// XXX
 		bool forceContinue = false;
@@ -3545,7 +3559,7 @@
 		}
 		
 		if (unk1) {
-			// XXX
+			// XXX running = false;
 			_sceneChangeState = 1;
 		}
 		
@@ -3554,16 +3568,15 @@
 		}
 		
 		int temp = 0;
-		if (table == tableStart) {
+		if (table == tableStart || table[1] == 8) {
 			temp = setCharacterPosition(0, 0);
 		} else {
 			temp = setCharacterPosition(0, table);
 		}
-		if (!temp) {
-			continue;
+		if (temp) {
+			++table;
 		}
 		
-		++table;
 		nextFrame = getTimerDelay(5) * _tickLength + _system->getMillis();
 		while (_system->getMillis() < nextFrame) {
 			_sprites->updateSceneAnims();

Index: script_v1.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/script_v1.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- script_v1.cpp	18 Nov 2005 23:55:31 -0000	1.24
+++ script_v1.cpp	26 Nov 2005 16:37:20 -0000	1.25
@@ -374,7 +374,8 @@
 int KyraEngine::cmd_walkPlayerToPoint(ScriptState *script) {
 	debug(3, "cmd_walkPlayerToPoint(0x%X) (%d, %d, %d, %d)", script, stackPos(0), stackPos(1), stackPos(2), stackPos(3));
 
-	if (!stackPos(2)) {
+	int normalTimers = stackPos(2);
+	if (!normalTimers) {
 		disableTimer(19);
 		disableTimer(14);
 		disableTimer(18);
@@ -382,7 +383,7 @@
 
 	int reinitScript = handleSceneChange(stackPos(0), stackPos(1), stackPos(2), stackPos(3));
 
-	if (!stackPos(2)) {
+	if (!normalTimers) {
 		enableTimer(19);
 		enableTimer(14);
 		enableTimer(18);

Index: staticres.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/staticres.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- staticres.cpp	18 Nov 2005 23:55:31 -0000	1.19
+++ staticres.cpp	26 Nov 2005 16:37:20 -0000	1.20
@@ -574,19 +574,19 @@
 const int KyraEngine::_xmidiFilesCount = ARRAYSIZE(_xmidiFiles);
 
 const int8 KyraEngine::_charXPosTable[] = {
-	0, 4, 4, 4, 0, -4, -4, -4
+	 0,  4,  4,  4,  0, -4, -4, -4
 };
 
 const int8 KyraEngine::_addXPosTable[] = {
-	4, 4, 0, -4, -4, -4, 0, 4
+	 4,  4,  0, -4, -4, -4,  0,  4
 };
 
 const int8 KyraEngine::_charYPosTable[] = {
-	-2, -2, 0, 2, 2, 2, 0, -2
+	-2, -2,  0,  2,  2,  2,  0, -2
 };
 
 const int8 KyraEngine::_addYPosTable[] = {
-	0, -2, -2, -2, 0, 2, 2, 2
+	 0, -2, -2, -2,  0,  2,  2,  2
 };
 
 const uint16 KyraEngine::_amuletX[] = {231, 275, 253, 253};





More information about the Scummvm-git-logs mailing list