diff options
author | yexo <yexo@openttd.org> | 2010-03-18 18:38:32 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2010-03-18 18:38:32 +0000 |
commit | 89a069629ed2592b9b80134582d5ba2e959f7211 (patch) | |
tree | 29fa8dfb50254d94067c2768fb562243bed5af93 /src/airport.cpp | |
parent | eb8d35a16ec593c16ca720f0d1b2e623986ecea5 (diff) | |
download | openttd-89a069629ed2592b9b80134582d5ba2e959f7211.tar.xz |
(svn r19453) -Codechange: split getting the initial aircraft position to a new function
Diffstat (limited to 'src/airport.cpp')
-rw-r--r-- | src/airport.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/airport.cpp b/src/airport.cpp index 2db4b8af0..e84250282 100644 --- a/src/airport.cpp +++ b/src/airport.cpp @@ -18,6 +18,7 @@ #include "date_func.h" #include "settings_type.h" #include "newgrf_airport.h" +#include "station_base.h" #include "table/strings.h" #include "table/airporttile_ids.h" @@ -381,3 +382,25 @@ const AirportFTAClass *GetAirport(const byte airport_type) if (airport_type == AT_DUMMY) return &_airportfta_dummy; return AirportSpec::Get(airport_type)->fsm; } + +/** + * Get the vehicle position when an aircraft is build at the given tile + * @param hangar_tile The tile on which the vehicle is build + * @return The position (index in airport node array) where the aircraft ends up + */ +byte GetVehiclePosOnBuild(TileIndex hangar_tile) +{ + const Station *st = Station::GetByTile(hangar_tile); + const AirportFTAClass *apc = st->Airport(); + /* When we click on hangar we know the tile it is on. By that we know + * its position in the array of depots the airport has.....we can search + * layout for #th position of depot. Since layout must start with a listing + * of all depots, it is simple */ + for (uint i = 0;; i++) { + if (st->GetHangarTile(i) == hangar_tile) { + assert(apc->layout[i].heading == HANGAR); + return apc->layout[i].position; + } + } + NOT_REACHED(); +} |