diff options
author | yexo <yexo@openttd.org> | 2010-03-19 11:17:52 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2010-03-19 11:17:52 +0000 |
commit | 1579e9ded29b89678e4c56ac82b6907537a920a7 (patch) | |
tree | c043257beec5af4474692a648fcc16b39d33c4d2 /src/station_base.h | |
parent | f2743cd5ed72a2d6224ffa828aab796ed771cef2 (diff) | |
download | openttd-1579e9ded29b89678e4c56ac82b6907537a920a7.tar.xz |
(svn r19465) -Codechange: support for multi-tile hangars
Diffstat (limited to 'src/station_base.h')
-rw-r--r-- | src/station_base.h | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/src/station_base.h b/src/station_base.h index 9a0da91dc..83ef41825 100644 --- a/src/station_base.h +++ b/src/station_base.h @@ -70,9 +70,38 @@ struct Airport : public TileArea { FORCEINLINE TileIndex GetHangarTile(uint hangar_num) const { - assert(this->tile != INVALID_TILE); - assert(hangar_num < this->GetSpec()->nof_depots); - return this->tile + ToTileIndexDiff(this->GetSpec()->depot_table[hangar_num]); + const AirportSpec *as = this->GetSpec(); + for (uint i = 0; i < as->nof_depots; i++) { + if (as->depot_table[i].hangar_num == hangar_num) { + return this->tile + ToTileIndexDiff(as->depot_table[i].ti); + } + } + NOT_REACHED(); + } + + FORCEINLINE uint GetHangarNum(TileIndex tile) const + { + const AirportSpec *as = this->GetSpec(); + for (uint i = 0; i < as->nof_depots; i++) { + if (this->tile + ToTileIndexDiff(as->depot_table[i].ti) == tile) { + return as->depot_table[i].hangar_num; + } + } + NOT_REACHED(); + } + + FORCEINLINE uint GetNumHangars() const + { + uint num = 0; + uint counted = 0; + const AirportSpec *as = this->GetSpec(); + for (uint i = 0; i < as->nof_depots; i++) { + if (!HasBit(counted, as->depot_table[i].hangar_num)) { + num++; + SetBit(counted, as->depot_table[i].hangar_num); + } + } + return num; } }; |