(svn r3321) - Fix: A wrong use of the map m5 bits, where a previously calculated "bits" variable should have been used. This resulted in the pathfinder imagining junctions, which negatively affects performance somewhat (Darkvater).
authormatthijs
Tue, 20 Dec 2005 00:50:16 +0000
changeset 2774 4b7d8beec975
parent 2773 d51afa1ff173
child 2775 d3ed38a97250
(svn r3321) - Fix: A wrong use of the map m5 bits, where a previously calculated "bits" variable should have been used. This resulted in the pathfinder imagining junctions, which negatively affects performance somewhat (Darkvater).
- Fix: [ 1346377 ] Limiting the "depth" of the search tree fixes this assert.
Though the above fix seems to fix this bug too, it will only make it less likely to occur. The problem here was the StackedItem::depth field overflowing, which made the pathfinder think it was at the first tile again. Adding an explicit overflow check should fix this.
pathfind.c
--- a/pathfind.c	Mon Dec 19 00:19:12 2005 +0000
+++ b/pathfind.c	Tue Dec 20 00:50:16 2005 +0000
@@ -764,7 +764,7 @@
 
 			// The tile has no reachable tracks, or
 			// does the tile contain more than one track?
-			if (bits == 0 || KILL_FIRST_BIT(GB(_m[tile].m5, 0, 6)) != 0)
+			if (bits == 0 || KILL_FIRST_BIT(bits) != 0)
 				break;
 
 			// If we reach here, the tile has exactly one track, and this
@@ -859,6 +859,8 @@
 			estimation = DistanceMoo(tile, tpf->dest);
 
 		si.depth++;
+		if (si.depth == 0)
+			continue; /* We overflowed our depth. No more searching in this direction. */
 		si.tile = tile;
 		do {
 			si.track = _new_track[FIND_FIRST_BIT(bits)][direction];