(svn r19465) -Codechange: support for multi-tile hangars
This commit is contained in:
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user