Mercurial > hg > openttd
changeset 6032:3f513357d37f draft
(svn r8755) -Fix
Abbreviate GetAirport(st->airport_type) to st->Airport()
author | tron <tron@openttd.org> |
---|---|
date | Fri, 16 Feb 2007 09:38:43 +0000 (2007-02-16) |
parents | 5d5695b62ae4 |
children | a3ca3cb7b1a2 |
files | src/ai/default/default.cpp src/aircraft_cmd.cpp src/build_vehicle_gui.cpp src/newgrf_engine.cpp src/order_cmd.cpp src/station.h src/station_cmd.cpp |
diffstat | 7 files changed, 24 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ai/default/default.cpp +++ b/src/ai/default/default.cpp @@ -3267,7 +3267,7 @@ // Do we own the airport? (Oilrigs aren't owned, though.) if (st->owner != OWNER_NONE && st->owner != _current_player) continue; - AirportFTAClass::Flags flags = GetAirport(st->airport_type)->flags; + AirportFTAClass::Flags flags = st->Airport()->flags; if (!(flags & (p->ai.build_kind == 1 && i == 0 ? AirportFTAClass::HELICOPTERS : AirportFTAClass::AIRPLANES))) { continue; @@ -3469,7 +3469,7 @@ /* XXX - Have the AI pick the hangar terminal in an airport. Eg get airport-type * and offset to the FIRST depot because the AI picks the st->xy tile */ - tile += ToTileIndexDiff(GetAirport(GetStationByTile(tile)->airport_type)->airport_depots[0]); + tile += ToTileIndexDiff(GetStationByTile(tile)->Airport()->airport_depots[0]); if (CmdFailed(DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_AIRCRAFT))) return; loco_id = _new_vehicle_id;
--- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -76,7 +76,7 @@ FOR_ALL_STATIONS(st) { if (st->owner != v->owner || !(st->facilities & FACIL_AIRPORT)) continue; - const AirportFTAClass *afc = GetAirport(st->airport_type); + const AirportFTAClass *afc = st->Airport(); if (afc->nof_depots == 0 || ( /* don't crash the plane if we know it can't land at the airport */ afc->flags & AirportFTAClass::SHORT_STRIP && @@ -106,7 +106,7 @@ const Station *st = GetStation(order->station); if (st->owner == v->owner && st->facilities & FACIL_AIRPORT) { // If an airport doesn't have a hangar, skip it - if (GetAirport(st->airport_type)->nof_depots != 0) + if (st->Airport()->nof_depots != 0) return true; } } @@ -250,7 +250,7 @@ // Prevent building aircraft types at places which can't handle them const Station* st = GetStationByTile(tile); - const AirportFTAClass* apc = GetAirport(st->airport_type); + const AirportFTAClass* apc = st->Airport(); if (!(apc->flags & (avi->subtype & AIR_CTOL ? AirportFTAClass::AIRPLANES : AirportFTAClass::HELICOPTERS))) { return CMD_ERROR; } @@ -559,7 +559,7 @@ StationID next_airport_index = v->u.air.targetairport; const Station *st = GetStation(next_airport_index); /* If the station is not a valid airport or if it has no hangars */ - if (!st->IsValid() || st->airport_tile == 0 || GetAirport(st->airport_type)->nof_depots == 0) { + if (!st->IsValid() || st->airport_tile == 0 || st->Airport()->nof_depots == 0) { StationID station; // the aircraft has to search for a hangar on its own @@ -696,7 +696,7 @@ st = GetStation(v->current_order.dest); // only goto depot if the target airport has terminals (eg. it is airport) - if (st->IsValid() && st->airport_tile != 0 && GetAirport(st->airport_type)->terminals != NULL) { + if (st->IsValid() && st->airport_tile != 0 && st->Airport()->terminals != NULL) { // printf("targetairport = %d, st->index = %d\n", v->u.air.targetairport, st->index); // v->u.air.targetairport = st->index; v->current_order.type = OT_GOTO_DEPOT; @@ -970,7 +970,7 @@ } // get airport moving data - const AirportFTAClass *afc = GetAirport(st->airport_type); + const AirportFTAClass *afc = st->Airport(); const AirportMovingData *amd = afc->MovingData(v->u.air.pos); // Helicopter raise @@ -1369,7 +1369,7 @@ //FIXME -- MaybeCrashAirplane -> increase crashing chances of very modern airplanes on smaller than AT_METROPOLITAN airports prob = 0x10000 / 1500; - if (GetAirport(st->airport_type)->flags & AirportFTAClass::SHORT_STRIP && + if (st->Airport()->flags & AirportFTAClass::SHORT_STRIP && AircraftVehInfo(v->engine_type)->subtype & AIR_FAST && !_cheats.no_jetcrash.value) { prob = 0x10000 / 20; @@ -1446,15 +1446,11 @@ // set the right pos when heading to other airports after takeoff static void AircraftNextAirportPos_and_Order(Vehicle *v) { - const Station* st; - const AirportFTAClass *apc; - if (v->current_order.type == OT_GOTO_STATION || v->current_order.type == OT_GOTO_DEPOT) v->u.air.targetairport = v->current_order.dest; - st = GetStation(v->u.air.targetairport); - apc = GetAirport(st->airport_type); + const AirportFTAClass *apc = GetStation(v->u.air.targetairport)->Airport(); v->u.air.pos = v->u.air.previous_pos = apc->entry_point; } @@ -2048,10 +2044,7 @@ if (v->current_order.type >= OT_LOADING) return; - // pass the right airport structure to the functions - // DEREF_STATION gets target airport (Station *st), its type is passed to GetAirport - // that returns the correct layout depending on type - AirportGoToNextPosition(v, GetAirport(GetStation(v->u.air.targetairport)->airport_type)); + AirportGoToNextPosition(v, GetStation(v->u.air.targetairport)->Airport()); } void Aircraft_Tick(Vehicle *v) @@ -2117,7 +2110,7 @@ byte takeofftype; uint16 cnt; // only 1 station is updated per function call, so it is enough to get entry_point once - const AirportFTAClass *ap = GetAirport(st->airport_type); + const AirportFTAClass *ap = st->Airport(); FOR_ALL_VEHICLES(v) { if (v->type == VEH_Aircraft && IsNormalAircraft(v)) { if (v->u.air.targetairport == st->index) { // if heading to this airport
--- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -985,7 +985,7 @@ break; case VEH_Aircraft: bv->filter.flags = - tile == 0 ? AirportFTAClass::ALL : GetAirport(GetStationByTile(tile)->airport_type)->flags; + tile == 0 ? AirportFTAClass::ALL : GetStationByTile(tile)->Airport()->flags; ResizeWindow(w, 12, 0); break; }
--- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -288,7 +288,7 @@ static byte MapAircraftMovementState(const Vehicle *v) { const Station *st = GetStation(v->u.air.targetairport); - const AirportFTAClass *afc = GetAirport(st->airport_type); + const AirportFTAClass *afc = st->Airport(); byte amdflag = afc->MovingData(v->u.air.pos)->flag; switch (v->u.air.state) {
--- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -261,7 +261,7 @@ if (!CheckOwnership(st->owner) || !(st->facilities & FACIL_AIRPORT) || - GetAirport(st->airport_type)->nof_depots == 0) { + st->Airport()->nof_depots == 0) { return CMD_ERROR; } } else {
--- a/src/station.h +++ b/src/station.h @@ -3,6 +3,7 @@ #ifndef STATION_H #define STATION_H +#include "airport.h" #include "player.h" #include "oldpool.h" #include "sprite.h" @@ -112,6 +113,12 @@ return type == RoadStop::BUS ? bus_stops : truck_stops; } + const AirportFTAClass *Airport() const + { + assert(airport_tile != 0); + return GetAirport(airport_type); + } + TileIndex xy; RoadStop *bus_stops; RoadStop *truck_stops;
--- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -557,7 +557,7 @@ } if (st->airport_tile != 0) { - const AirportFTAClass* afc = GetAirport(st->airport_type); + const AirportFTAClass* afc = st->Airport(); MergePoint(&rect, st->airport_tile); MergePoint(&rect, @@ -1679,14 +1679,13 @@ TileIndex tile; int w,h; int32 cost; - const AirportFTAClass* afc; if (_current_player != OWNER_WATER && !CheckOwnership(st->owner)) return CMD_ERROR; tile = st->airport_tile; - afc = GetAirport(st->airport_type); + const AirportFTAClass *afc = st->Airport(); w = afc->size_x; h = afc->size_y;