(svn r11126) -Fix: the algorithm to determine the closest water/land was flawed.
authorrubidium
Tue, 18 Sep 2007 18:55:25 +0000
changeset 8095 1ecfd01f30af
parent 8094 58a8fe00746a
child 8096 9e87db1c5925
(svn r11126) -Fix: the algorithm to determine the closest water/land was flawed.
src/newgrf_industries.cpp
--- a/src/newgrf_industries.cpp	Mon Sep 17 17:07:24 2007 +0000
+++ b/src/newgrf_industries.cpp	Tue Sep 18 18:55:25 2007 +0000
@@ -48,6 +48,7 @@
 	for (t = 0; t < MapSize(); t++) {
 		if (IsTileType(t, MP_WATER) == water) break;
 	}
+	if (t == MapSize() && !water) return 0x200;
 	best_dist = DistanceManhattan(tile, t);
 
 	for (; t < MapSize(); t++) {
@@ -72,7 +73,7 @@
 		}
 	}
 
-	return best_dist;
+	return min(best_dist, water ? 0x7F : 0x1FF);
 }
 
 /** Make an analysis of a tile and check for its belonging to the same