mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r22742) -Add: Add function to query exit direction of hangars at airports.
This commit is contained in:
parent
bc6d4069fe
commit
c4118e3f6a
|
@ -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.
|
* @param tile The tile to query.
|
||||||
* @pre IsHangarTile(tile).
|
* @pre IsHangarTile(tile).
|
||||||
* @return The hangar number of the hangar at the given tile.
|
* @return The hangar number of the hangar at the given tile.
|
||||||
*/
|
*/
|
||||||
FORCEINLINE uint GetHangarNum(TileIndex tile) const
|
FORCEINLINE uint GetHangarNum(TileIndex tile) const
|
||||||
{
|
{
|
||||||
const AirportSpec *as = this->GetSpec();
|
const HangarTileTable *htt = GetHangarDataByTile(tile);
|
||||||
for (uint i = 0; i < as->nof_depots; i++) {
|
return htt->hangar_num;
|
||||||
if (this->GetRotatedTileFromOffset(as->depot_table[i].ti) == tile) {
|
|
||||||
return as->depot_table[i].hangar_num;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
NOT_REACHED();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the number of hangars on this airport. */
|
/** Get the number of hangars on this airport. */
|
||||||
|
@ -165,6 +173,24 @@ struct Airport : public TileArea {
|
||||||
}
|
}
|
||||||
return num;
|
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;
|
typedef SmallVector<Industry *, 2> IndustryVector;
|
||||||
|
|
Loading…
Reference in New Issue