diff options
author | alberth <alberth@openttd.org> | 2011-08-13 12:44:42 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2011-08-13 12:44:42 +0000 |
commit | c4118e3f6a7f007086ad210431b0fdb73ae0ce27 (patch) | |
tree | 38dc38fa607318d2656b7e448e60ae83da827281 /src | |
parent | bc6d4069fe43da78054842a79de8ae7e1960efbf (diff) | |
download | openttd-c4118e3f6a7f007086ad210431b0fdb73ae0ce27.tar.xz |
(svn r22742) -Add: Add function to query exit direction of hangars at airports.
Diffstat (limited to 'src')
-rw-r--r-- | src/station_base.h | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/src/station_base.h b/src/station_base.h index 984582c62..2a7fedbf7 100644 --- a/src/station_base.h +++ b/src/station_base.h @@ -135,20 +135,28 @@ struct Airport : public TileArea { } /** - * Get the hangar number of the hangar on a specific tile. + * Get the exit direction of the hangar at a specific tile. + * @param tile The tile to query. + * @pre IsHangarTile(tile). + * @return The exit direction of the hangar, taking airport rotation into account. + */ + FORCEINLINE Direction GetHangarExitDirection(TileIndex tile) const + { + const AirportSpec *as = this->GetSpec(); + const HangarTileTable *htt = GetHangarDataByTile(tile); + return ChangeDir(htt->dir, DirDifference(this->rotation, as->rotation[0])); + } + + /** + * Get the hangar number of the hangar at a specific tile. * @param tile The tile to query. * @pre IsHangarTile(tile). * @return The hangar number of the hangar at the given tile. */ FORCEINLINE uint GetHangarNum(TileIndex tile) const { - const AirportSpec *as = this->GetSpec(); - for (uint i = 0; i < as->nof_depots; i++) { - if (this->GetRotatedTileFromOffset(as->depot_table[i].ti) == tile) { - return as->depot_table[i].hangar_num; - } - } - NOT_REACHED(); + const HangarTileTable *htt = GetHangarDataByTile(tile); + return htt->hangar_num; } /** Get the number of hangars on this airport. */ @@ -165,6 +173,24 @@ struct Airport : public TileArea { } return num; } + +private: + /** + * Retrieve hangar information of a hangar at a given tile. + * @param tile %Tile containing the hangar. + * @return The requested hangar information. + * @pre The \a tile must be at a hangar tile at an airport. + */ + FORCEINLINE const HangarTileTable *GetHangarDataByTile(TileIndex tile) const + { + const AirportSpec *as = this->GetSpec(); + for (uint i = 0; i < as->nof_depots; i++) { + if (this->GetRotatedTileFromOffset(as->depot_table[i].ti) == tile) { + return as->depot_table + i; + } + } + NOT_REACHED(); + } }; typedef SmallVector<Industry *, 2> IndustryVector; |