summaryrefslogtreecommitdiff
path: root/src/pathfinder/pathfinder_func.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-12-02 14:41:04 +0000
committerrubidium <rubidium@openttd.org>2009-12-02 14:41:04 +0000
commita1e28925e3c974a3c34a609737677ca072c559e1 (patch)
treed860a470be11edcd7eabdbe42134c584322251ee /src/pathfinder/pathfinder_func.h
parentf67c265c6f5c88d5f9d18a831da5b65329169712 (diff)
downloadopenttd-a1e28925e3c974a3c34a609737677ca072c559e1.tar.xz
(svn r18375) -Codechange: use Station::GetTileArea to get the tile area for CalcClosestStationTile
Diffstat (limited to 'src/pathfinder/pathfinder_func.h')
-rw-r--r--src/pathfinder/pathfinder_func.h16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/pathfinder/pathfinder_func.h b/src/pathfinder/pathfinder_func.h
index dc79c8024..7f5226a52 100644
--- a/src/pathfinder/pathfinder_func.h
+++ b/src/pathfinder/pathfinder_func.h
@@ -21,19 +21,23 @@
* as defined by its tile are (st->train_station)
* @param station The station to calculate the distance to
* @param tile The tile from where to calculate the distance
+ * @param station_type the station type to get the closest tile of
+ * @note for simplification STATION_RAIL is also used for waypoints!
* @return The closest station tile to the given tile.
*/
-static inline TileIndex CalcClosestStationTile(StationID station, TileIndex tile)
+static inline TileIndex CalcClosestStationTile(StationID station, TileIndex tile, StationType station_type)
{
const BaseStation *st = BaseStation::Get(station);
+ TileArea ta;
+ st->GetTileArea(&ta, station_type);
/* If the rail station is (temporarily) not present, use the station sign to drive near the station */
- if (st->train_station.tile == INVALID_TILE) return st->xy;
+ if (ta.tile == INVALID_TILE) return st->xy;
- uint minx = TileX(st->train_station.tile); // topmost corner of station
- uint miny = TileY(st->train_station.tile);
- uint maxx = minx + st->train_station.w - 1; // lowermost corner of station
- uint maxy = miny + st->train_station.h - 1;
+ uint minx = TileX(ta.tile); // topmost corner of station
+ uint miny = TileY(ta.tile);
+ uint maxx = minx + ta.w - 1; // lowermost corner of station
+ uint maxy = miny + ta.h - 1;
/* 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 */