summaryrefslogtreecommitdiff
path: root/src/ai/api
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-01-15 12:08:08 +0000
committeryexo <yexo@openttd.org>2010-01-15 12:08:08 +0000
commitd669801f1d18e295e7497eaa19d0398da67bffe8 (patch)
tree38c0215af215420346de054481c93d83f36da482 /src/ai/api
parentc37d69d161d418eaf363588df0ac67e61fd7f23e (diff)
downloadopenttd-d669801f1d18e295e7497eaa19d0398da67bffe8.tar.xz
(svn r18807) -Codechange: introduce AirportSpec and move several non-statemachine-related variables to there
Diffstat (limited to 'src/ai/api')
-rw-r--r--src/ai/api/ai_airport.cpp30
-rw-r--r--src/ai/api/ai_depotlist.cpp6
-rw-r--r--src/ai/api/ai_order.cpp10
3 files changed, 23 insertions, 23 deletions
diff --git a/src/ai/api/ai_airport.cpp b/src/ai/api/ai_airport.cpp
index 204a3a5bf..b966bc542 100644
--- a/src/ai/api/ai_airport.cpp
+++ b/src/ai/api/ai_airport.cpp
@@ -17,7 +17,7 @@
/* static */ bool AIAirport::IsValidAirportType(AirportType type)
{
- return IsAirportInformationAvailable(type) && ::GetAirport(type)->IsAvailable();
+ return IsAirportInformationAvailable(type) && ::AirportSpec::Get(type)->IsAvailable();
}
/* static */ bool AIAirport::IsAirportInformationAvailable(AirportType type)
@@ -29,8 +29,8 @@
{
if (!IsValidAirportType(type)) return -1;
- const AirportFTAClass *afc = ::GetAirport(type);
- return _price[PR_BUILD_STATION_AIRPORT] * afc->size_x * afc->size_y;
+ const AirportSpec *as = ::AirportSpec::Get(type);
+ return _price[PR_BUILD_STATION_AIRPORT] * as->size_x * as->size_y;
}
/* static */ bool AIAirport::IsHangarTile(TileIndex tile)
@@ -51,21 +51,21 @@
{
if (!IsAirportInformationAvailable(type)) return -1;
- return ::GetAirport(type)->size_x;
+ return ::AirportSpec::Get(type)->size_x;
}
/* static */ int32 AIAirport::GetAirportHeight(AirportType type)
{
if (!IsAirportInformationAvailable(type)) return -1;
- return ::GetAirport(type)->size_y;
+ return ::AirportSpec::Get(type)->size_y;
}
/* static */ int32 AIAirport::GetAirportCoverageRadius(AirportType type)
{
if (!IsAirportInformationAvailable(type)) return -1;
- return _settings_game.station.modified_catchment ? ::GetAirport(type)->catchment : (uint)CA_UNMODIFIED;
+ return _settings_game.station.modified_catchment ? ::AirportSpec::Get(type)->catchment : (uint)CA_UNMODIFIED;
}
/* static */ bool AIAirport::BuildAirport(TileIndex tile, AirportType type, StationID station_id)
@@ -96,7 +96,7 @@
if (st->owner != _current_company) return -1;
if ((st->facilities & FACIL_AIRPORT) == 0) return -1;
- return st->Airport()->nof_depots;
+ return st->GetAirportSpec()->nof_depots;
}
/* static */ TileIndex AIAirport::GetHangarOfAirport(TileIndex tile)
@@ -109,7 +109,7 @@
if (st->owner != _current_company) return INVALID_TILE;
if ((st->facilities & FACIL_AIRPORT) == 0) return INVALID_TILE;
- return ::ToTileIndexDiff(st->Airport()->airport_depots[0]) + st->airport_tile;
+ return ::ToTileIndexDiff(st->GetAirportSpec()->depot_table[0]) + st->airport_tile;
}
/* static */ AIAirport::AirportType AIAirport::GetAirportType(TileIndex tile)
@@ -126,16 +126,16 @@
/* static */ int AIAirport::GetNoiseLevelIncrease(TileIndex tile, AirportType type)
{
- extern Town *AirportGetNearestTown(const AirportFTAClass *afc, TileIndex airport_tile);
- extern uint8 GetAirportNoiseLevelForTown(const AirportFTAClass *afc, TileIndex town_tile, TileIndex tile);
+ extern Town *AirportGetNearestTown(const AirportSpec *as, TileIndex airport_tile);
+ extern uint8 GetAirportNoiseLevelForTown(const AirportSpec *as, TileIndex town_tile, TileIndex tile);
if (!::IsValidTile(tile)) return -1;
if (!IsValidAirportType(type)) return -1;
if (_settings_game.economy.station_noise_level) {
- const AirportFTAClass *afc = ::GetAirport(type);
- const Town *t = AirportGetNearestTown(afc, tile);
- return GetAirportNoiseLevelForTown(afc, t->xy, tile);
+ const AirportSpec *as = ::AirportSpec::Get(type);
+ const Town *t = AirportGetNearestTown(as, tile);
+ return GetAirportNoiseLevelForTown(as, t->xy, tile);
}
return 1;
@@ -143,10 +143,10 @@
/* static */ TownID AIAirport::GetNearestTown(TileIndex tile, AirportType type)
{
- extern Town *AirportGetNearestTown(const AirportFTAClass *afc, TileIndex airport_tile);
+ extern Town *AirportGetNearestTown(const AirportSpec *as, TileIndex airport_tile);
if (!::IsValidTile(tile)) return INVALID_TOWN;
if (!IsAirportInformationAvailable(type)) return INVALID_TOWN;
- return AirportGetNearestTown(GetAirport(type), tile)->index;
+ return AirportGetNearestTown(AirportSpec::Get(type), tile)->index;
}
diff --git a/src/ai/api/ai_depotlist.cpp b/src/ai/api/ai_depotlist.cpp
index 558b6c31d..1dc68fb7b 100644
--- a/src/ai/api/ai_depotlist.cpp
+++ b/src/ai/api/ai_depotlist.cpp
@@ -29,9 +29,9 @@ AIDepotList::AIDepotList(AITile::TransportType transport_type)
const Station *st;
FOR_ALL_STATIONS(st) {
if (st->owner == ::_current_company) {
- const AirportFTAClass *afc = st->Airport();
- for (uint i = 0; i < afc->nof_depots; i++) {
- this->AddItem(st->airport_tile + ToTileIndexDiff(afc->airport_depots[i]));
+ const AirportSpec *as = st->GetAirportSpec();
+ for (uint i = 0; i < as->nof_depots; i++) {
+ this->AddItem(st->airport_tile + ToTileIndexDiff(as->depot_table[i]));
}
}
}
diff --git a/src/ai/api/ai_order.cpp b/src/ai/api/ai_order.cpp
index 1062e501a..9cde814d8 100644
--- a/src/ai/api/ai_order.cpp
+++ b/src/ai/api/ai_order.cpp
@@ -181,9 +181,9 @@ static const Order *ResolveOrder(VehicleID vehicle_id, AIOrder::OrderPosition or
if (v->type != VEH_AIRCRAFT) return ::Depot::Get(order->GetDestination())->xy;
/* Aircraft's hangars are referenced by StationID, not DepotID */
const Station *st = ::Station::Get(order->GetDestination());
- const AirportFTAClass *airport = st->Airport();
- if (airport == NULL || airport->nof_depots == 0) return INVALID_TILE;
- return st->airport_tile + ::ToTileIndexDiff(st->Airport()->airport_depots[0]);
+ const AirportSpec *as = st->GetAirportSpec();
+ if (as == NULL || as->nof_depots == 0) return INVALID_TILE;
+ return st->airport_tile + ::ToTileIndexDiff(as->depot_table[0]);
}
case OT_GOTO_STATION: {
@@ -200,8 +200,8 @@ static const Order *ResolveOrder(VehicleID vehicle_id, AIOrder::OrderPosition or
} else if (st->truck_stops != NULL) {
return st->truck_stops->xy;
} else if (st->airport_tile != INVALID_TILE) {
- const AirportFTAClass *fta = st->Airport();
- TILE_LOOP(tile, fta->size_x, fta->size_y, st->airport_tile) {
+ const AirportSpec *as = st->GetAirportSpec();
+ TILE_LOOP(tile, as->size_x, as->size_y, st->airport_tile) {
if (!::IsHangar(tile)) return tile;
}
}