(svn r19465) -Codechange: support for multi-tile hangars

This commit is contained in:
yexo
2010-03-19 11:17:52 +00:00
parent f2743cd5ed
commit 1579e9ded2
8 changed files with 59 additions and 24 deletions

View File

@@ -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;
}
};