[Scummvm-cvs-logs] SF.net SVN: scummvm: [31179] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Tue Mar 18 14:29:13 CET 2008


Revision: 31179
          http://scummvm.svn.sourceforge.net/scummvm/?rev=31179&view=rev
Author:   lordhoto
Date:     2008-03-18 06:29:12 -0700 (Tue, 18 Mar 2008)

Log Message:
-----------
Fixed pathfinder post processing in HoF, this should smooth walk paths a lot.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/kyra_v2.h
    scummvm/trunk/engines/kyra/scene_v2.cpp

Modified: scummvm/trunk/engines/kyra/kyra_v2.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.h	2008-03-18 13:01:33 UTC (rev 31178)
+++ scummvm/trunk/engines/kyra/kyra_v2.h	2008-03-18 13:29:12 UTC (rev 31179)
@@ -530,14 +530,14 @@
 	bool lineIsPassable(int x, int y);
 	bool directLinePassable(int x, int y, int toX, int toY);
 
-	int pathfinderUnk1(int *moveTable);
-	int pathfinderUnk2(int index, int v1, int v2);
-	int pathfinderUnk3(int tableLen, int x, int y);
-	int pathfinderUnk4(int index, int v);
-	void pathfinderUnk5(int *moveTable, int unk1, int x, int y, int moveTableSize);
+	int pathfinderInitPositionTable(int *moveTable);
+	int pathfinderAddToPositionTable(int index, int v1, int v2);
+	int pathfinderInitPositionIndexTable(int tableLen, int x, int y);
+	int pathfinderAddToPositionIndexTable(int index, int v);
+	void pathfinderFinializePath(int *moveTable, int unk1, int x, int y, int moveTableSize);
 
-	int _pathfinderUnkTable1[400];
-	int _pathfinderUnkTable2[200];
+	int _pathfinderPositionTable[400];
+	int _pathfinderPositionIndexTable[200];
 
 	// item
 	uint8 _itemHtDat[176];

Modified: scummvm/trunk/engines/kyra/scene_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/scene_v2.cpp	2008-03-18 13:01:33 UTC (rev 31178)
+++ scummvm/trunk/engines/kyra/scene_v2.cpp	2008-03-18 13:29:12 UTC (rev 31179)
@@ -736,12 +736,15 @@
 	x &= ~3; toX &= ~3;
 	y &= ~1; toY &= ~1;
 	int size = KyraEngine::findWay(x, y, toX, toY, moveTable, moveTableSize);
-	if (size) {
-		//int temp = pathfinderUnk1(moveTable);
-		//temp = pathfinderUnk3(temp, x, y);
-		//pathfinderUnk5(moveTable, temp, x, y, moveTableSize);
-	}
-	return getMoveTableSize(moveTable);
+	static bool usePostProcess = false;
+	if (size && !usePostProcess) {
+		usePostProcess = true;
+		int temp = pathfinderInitPositionTable(moveTable);
+		temp = pathfinderInitPositionIndexTable(temp, x, y);
+		pathfinderFinializePath(moveTable, temp, x, y, moveTableSize);
+		usePostProcess = false;
+	} 
+	return usePostProcess ? size : getMoveTableSize(moveTable);
 }
 
 bool KyraEngine_v2::lineIsPassable(int x, int y) {
@@ -795,13 +798,13 @@
 	return true;
 }
 
-int KyraEngine_v2::pathfinderUnk1(int *moveTable) {
+int KyraEngine_v2::pathfinderInitPositionTable(int *moveTable) {
 	bool breakLoop = false;
 	int *moveTableCur = moveTable;
 	int oldEntry = *moveTableCur, curEntry = *moveTableCur;
 	int oldX = 0, newX = 0, oldY = 0, newY = 0;
 	int lastEntry = 0;
-	lastEntry = pathfinderUnk2(lastEntry, 0, 0);
+	lastEntry = pathfinderAddToPositionTable(lastEntry, 0, 0);
 
 	while (*moveTableCur != 8) {
 		oldEntry = curEntry;
@@ -834,45 +837,45 @@
 		}
 
 		if (temp > 1 || oldEntry != curEntry)
-			lastEntry = pathfinderUnk2(lastEntry, oldX, oldY);
+			lastEntry = pathfinderAddToPositionTable(lastEntry, oldX, oldY);
 
 		++moveTableCur;
 	}
 
-	lastEntry = pathfinderUnk2(lastEntry, newX, newY);
-	_pathfinderUnkTable1[lastEntry*2+0] = -1;
-	_pathfinderUnkTable1[lastEntry*2+1] = -1;
+	lastEntry = pathfinderAddToPositionTable(lastEntry, newX, newY);
+	_pathfinderPositionTable[lastEntry*2+0] = -1;
+	_pathfinderPositionTable[lastEntry*2+1] = -1;
 	return lastEntry;
 }
 
-int KyraEngine_v2::pathfinderUnk2(int index, int v1, int v2) {
-	_pathfinderUnkTable1[index<<1] = v1;
-	_pathfinderUnkTable1[(index<<1)+1] = v2;
+int KyraEngine_v2::pathfinderAddToPositionTable(int index, int v1, int v2) {
+	_pathfinderPositionTable[index<<1] = v1;
+	_pathfinderPositionTable[(index<<1)+1] = v2;
 	++index;
 	if (index >= 199)
 		--index;
 	return index;
 }
 
-int KyraEngine_v2::pathfinderUnk3(int tableLen, int x, int y) {
+int KyraEngine_v2::pathfinderInitPositionIndexTable(int tableLen, int x, int y) {
 	int x1 = 0, y1 = 0;
 	int x2 = 0, y2 = 0;
 	int lastEntry = 0;
 	int index2 = tableLen-1, index1 = 0;
 	while (index2 > index1) {
-		x1 = _pathfinderUnkTable1[index1*2+0] + x;
-		y1 = _pathfinderUnkTable1[index1*2+1] + y;
-		x2 = _pathfinderUnkTable1[index2*2+0] + x;
-		y2 = _pathfinderUnkTable1[index2*2+0] + x;
+		x1 = _pathfinderPositionTable[index1*2+0] + x;
+		y1 = _pathfinderPositionTable[index1*2+1] + y;
+		x2 = _pathfinderPositionTable[index2*2+0] + x;
+		y2 = _pathfinderPositionTable[index2*2+1] + y;
 
 		if (directLinePassable(x1, y1, x2, y2)) {
-			lastEntry = pathfinderUnk4(lastEntry, index2);
+			lastEntry = pathfinderAddToPositionIndexTable(lastEntry, index2);
 			if (tableLen-1 == index2)
 				break;
 			index1 = index2;
 			index2 = tableLen-1;
 		} else if (index1+1 == index2) {
-			lastEntry = pathfinderUnk4(lastEntry, index2);
+			lastEntry = pathfinderAddToPositionIndexTable(lastEntry, index2);
 			index1 = index2;
 			index2 = tableLen-1;
 		} else {
@@ -882,25 +885,25 @@
 	return lastEntry;
 }
 
-int KyraEngine_v2::pathfinderUnk4(int index, int v) {
-	_pathfinderUnkTable2[index] = v;
+int KyraEngine_v2::pathfinderAddToPositionIndexTable(int index, int v) {
+	_pathfinderPositionIndexTable[index] = v;
 	++index;
 	if (index >= 199)
 		--index;
 	return index;
 }
 
-void KyraEngine_v2::pathfinderUnk5(int *moveTable, int tableLen, int x, int y, int moveTableSize) {
+void KyraEngine_v2::pathfinderFinializePath(int *moveTable, int tableLen, int x, int y, int moveTableSize) {
 	int x1 = 0, y1 = 0;
 	int x2 = 0, y2 = 0;
 	int index1 = 0, index2 = 0;
 	int sizeLeft = moveTableSize;
 	for (int i = 0; i < tableLen; ++i) {
-		index2 = _pathfinderUnkTable2[i];
-		x1 = _pathfinderUnkTable1[index1*2+0] + x;
-		y1 = _pathfinderUnkTable1[index1*2+1] + y;
-		x2 = _pathfinderUnkTable1[index2*2+0] + x;
-		y2 = _pathfinderUnkTable1[index2*2+0] + x;
+		index2 = _pathfinderPositionIndexTable[i];
+		x1 = _pathfinderPositionTable[index1*2+0] + x;
+		y1 = _pathfinderPositionTable[index1*2+1] + y;
+		x2 = _pathfinderPositionTable[index2*2+0] + x;
+		y2 = _pathfinderPositionTable[index2*2+1] + y;
 
 		int wayLen = findWay(x1, y1, x2, y2, moveTable, sizeLeft);
 		moveTable += wayLen;


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