summaryrefslogtreecommitdiff
path: root/src/npf.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-02-19 00:15:36 +0000
committerrubidium <rubidium@openttd.org>2009-02-19 00:15:36 +0000
commitc2d9c85c0fbb26b5db2ef20b7ac610e63de2b46b (patch)
tree76c1b93af5e93efa3bcc9984e1c04884640ea566 /src/npf.cpp
parent336fda62bec39eb9ad1ee966a23faa0886a75309 (diff)
downloadopenttd-c2d9c85c0fbb26b5db2ef20b7ac610e63de2b46b.tar.xz
(svn r15518) -Fix [FS#2631]: use distance to closest station tile as estimate for YAPF too (NPF already does so). This makes it behave 'better' with wide stations.
Diffstat (limited to 'src/npf.cpp')
-rw-r--r--src/npf.cpp30
1 files changed, 1 insertions, 29 deletions
diff --git a/src/npf.cpp b/src/npf.cpp
index 9fbad2798..9b8b687a5 100644
--- a/src/npf.cpp
+++ b/src/npf.cpp
@@ -15,6 +15,7 @@
#include "tunnelbridge.h"
#include "pbs.h"
#include "settings_type.h"
+#include "pathfind.h"
static AyStar _npf_aystar;
@@ -83,35 +84,6 @@ static int32 NPFCalcZero(AyStar *as, AyStarNode *current, OpenListNode *parent)
return 0;
}
-/* Calcs the tile of given station that is closest to a given tile
- * for this we assume the station is a rectangle,
- * as defined by its top tile (st->train_tile) and its width/height (st->trainst_w, st->trainst_h)
- */
-static TileIndex CalcClosestStationTile(StationID station, TileIndex tile)
-{
- const Station *st = GetStation(station);
-
- /* If the rail station is (temporarily) not present, use the station sign to drive near the station */
- if (!IsValidTile(st->train_tile)) return st->xy;
-
- uint minx = TileX(st->train_tile); // topmost corner of station
- uint miny = TileY(st->train_tile);
- uint maxx = minx + st->trainst_w - 1; // lowermost corner of station
- uint maxy = miny + st->trainst_h - 1;
- uint x;
- uint y;
-
- /* we are going the aim for the x coordinate of the closest corner
- * but if we are between those coordinates, we will aim for our own x coordinate */
- x = Clamp(TileX(tile), minx, maxx);
-
- /* same for y coordinate, see above comment */
- y = Clamp(TileY(tile), miny, maxy);
-
- /* return the tile of our target coordinates */
- return TileXY(x, y);
-}
-
/* Calcs the heuristic to the target station or tile. For train stations, it
* takes into account the direction of approach.
*/