diff options
author | celestar <celestar@openttd.org> | 2006-06-01 09:41:35 +0000 |
---|---|---|
committer | celestar <celestar@openttd.org> | 2006-06-01 09:41:35 +0000 |
commit | 65a6286345445ff29153dff66b07938113d4e521 (patch) | |
tree | 1237eb340fcae47dd0705064319849a06becbec1 /station_cmd.c | |
parent | f8982917ea8bd4cb2419cc423c1293bb341c92f9 (diff) | |
download | openttd-65a6286345445ff29153dff66b07938113d4e521.tar.xz |
(svn r5063) -Codechange: Add a function to determine the length of a platform (request by KUDr)
Diffstat (limited to 'station_cmd.c')
-rw-r--r-- | station_cmd.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/station_cmd.c b/station_cmd.c index 00254dd07..0339ec0a6 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -1255,6 +1255,28 @@ uint GetStationPlatforms(const Station *st, TileIndex tile) return len - 1; } +/** Determines the REMAINING length of a platform, starting at (and including) + * the given tile. + * @param tile the tile from which to start searching. Must be a railway station tile + * @param dir The direction in which to search. + * @return The platform length + */ +uint GetPlatformLength(TileIndex tile, DiagDirection dir) +{ + TileIndex start_tile = tile; + uint length = 0; + assert(IsRailwayStationTile(tile)); + assert(dir < DIAGDIR_END); + + do { + length ++; + tile += TileOffsByDir(dir); + } while (IsCompatibleTrainStationTile(tile, start_tile)); + + return length; +} + + static int32 RemoveRailroadStation(Station *st, TileIndex tile, uint32 flags) { int w,h; |