diff options
author | tron <tron@openttd.org> | 2007-02-16 09:38:43 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2007-02-16 09:38:43 +0000 |
commit | 87e03c7aa8364ab7418396079522c26ec112dc83 (patch) | |
tree | 36bede5a1addc08aa86f08b4b01dbd3f41400689 /src | |
parent | 6c17cd4c464799c3a83da3a677c8002fc26f7d9d (diff) | |
download | openttd-87e03c7aa8364ab7418396079522c26ec112dc83.tar.xz |
(svn r8755) -Fix
Abbreviate GetAirport(st->airport_type) to st->Airport()
Diffstat (limited to 'src')
-rw-r--r-- | src/ai/default/default.cpp | 4 | ||||
-rw-r--r-- | src/aircraft_cmd.cpp | 27 | ||||
-rw-r--r-- | src/build_vehicle_gui.cpp | 2 | ||||
-rw-r--r-- | src/newgrf_engine.cpp | 2 | ||||
-rw-r--r-- | src/order_cmd.cpp | 2 | ||||
-rw-r--r-- | src/station.h | 7 | ||||
-rw-r--r-- | src/station_cmd.cpp | 5 |
7 files changed, 24 insertions, 25 deletions
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp index 957993edb..33f62c7f2 100644 --- a/src/ai/default/default.cpp +++ b/src/ai/default/default.cpp @@ -3267,7 +3267,7 @@ static void AiStateAirportStuff(Player *p) // 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 @@ static void AiStateBuildAircraftVehicles(Player *p) /* 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; diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 4e74c335e..f3fdd3f1e 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -76,7 +76,7 @@ static StationID FindNearestHangar(const Vehicle *v) 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 @@ static bool HaveHangarInOrderList(Vehicle *v) 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 @@ int32 CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) // 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 @@ int32 CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uint32 p2 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 @@ static void CheckIfAircraftNeedsService(Vehicle *v) 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 @@ static bool AircraftController(Vehicle *v) } // 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 @@ static void MaybeCrashAirplane(Vehicle *v) //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 @@ static void AircraftLandAirplane(Vehicle *v) // 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 @@ static void AircraftEventHandler(Vehicle *v, int loop) 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 @@ void UpdateAirplanesOnNewStation(Station *st) 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 diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 050d9bf5a..99925fbd7 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -985,7 +985,7 @@ void ShowBuildVehicleWindow(TileIndex tile, byte type) 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; } diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index 3bf9a93a4..0a1183afb 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -288,7 +288,7 @@ enum { 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) { diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index bb2a97db7..20dbf4220 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -261,7 +261,7 @@ int32 CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) if (!CheckOwnership(st->owner) || !(st->facilities & FACIL_AIRPORT) || - GetAirport(st->airport_type)->nof_depots == 0) { + st->Airport()->nof_depots == 0) { return CMD_ERROR; } } else { diff --git a/src/station.h b/src/station.h index 6d89280aa..6ec5777c6 100644 --- 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 @@ struct Station { 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; diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 2cc1718de..463ed4487 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -557,7 +557,7 @@ static void UpdateStationAcceptance(Station *st, bool show_msg) } 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 @@ static int32 RemoveAirport(Station *st, uint32 flags) 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; |