diff options
-rw-r--r-- | src/ai/default/default.cpp | 16 | ||||
-rw-r--r-- | src/aircraft_cmd.cpp | 8 | ||||
-rw-r--r-- | src/airport.cpp | 25 | ||||
-rw-r--r-- | src/airport.h | 22 | ||||
-rw-r--r-- | src/build_vehicle_gui.cpp | 4 | ||||
-rw-r--r-- | src/window.h | 2 |
6 files changed, 30 insertions, 47 deletions
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp index f1e8063bf..f015de8be 100644 --- a/src/ai/default/default.cpp +++ b/src/ai/default/default.cpp @@ -3244,7 +3244,6 @@ static void AiStateDeleteRoadBlocks(Player *p) static void AiStateAirportStuff(Player *p) { const Station* st; - byte acc_planes; int i; AiBuildRec *aib; byte rule; @@ -3268,16 +3267,11 @@ 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; - acc_planes = GetAirport(st->airport_type)->acc_planes; + AirportFTAClass::Flags flags = GetAirport(st->airport_type)->flags; - // Dismiss heliports, unless we are checking an oilrig. - if (acc_planes == HELICOPTERS_ONLY && (p->ai.build_kind != 1 || i != 1)) - continue; - - // Dismiss country airports if we are doing the other - // endpoint of an oilrig route. - if (acc_planes == AIRCRAFT_ONLY && (p->ai.build_kind == 1 && i == 0)) + if (!(flags & (p->ai.build_kind == 1 && i == 0 ? AirportFTAClass::HELICOPTERS : AirportFTAClass::PLANES))) { continue; + } // Dismiss airports too far away. if (DistanceMax(st->airport_tile, aib->spec_tile) > aib->rand_rng) @@ -3298,7 +3292,7 @@ static void AiStateAirportStuff(Player *p) * broken because they will probably need different * tileoff values etc), no matter that * IsHangarTile() makes no sense. --pasky */ - if (acc_planes == HELICOPTERS_ONLY) { + if (!(flags & AirportFTAClass::PLANES)) { /* Heliports should have maybe own rulesets but * OTOH we don't want AI to pick them up when * looking for a suitable airport type to build. @@ -3372,7 +3366,7 @@ static int AiFindBestDefaultAirportBlock(TileIndex tile, byte cargo, byte heli, for (i = 0; (p = _airport_default_block_data[i]) != NULL; i++) { // If we are doing a helicopter service, avoid building // airports where they can't land. - if (heli && GetAirport(p->attr)->acc_planes == AIRCRAFT_ONLY) continue; + if (heli && !(GetAirport(p->attr)->flags & AirportFTAClass::HELICOPTERS)) continue; *cost = AiDoBuildDefaultAirportBlock(tile, p, 0); if (!CmdFailed(*cost) && AiCheckAirportResources(tile, p, cargo)) diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index b84a2c276..2108cadc3 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -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); - if ((avi->subtype & AIR_CTOL ? HELICOPTERS_ONLY : AIRCRAFT_ONLY) == apc->acc_planes) { + if (!(apc->flags & (avi->subtype & AIR_CTOL ? AirportFTAClass::PLANES : AirportFTAClass::HELICOPTERS))) { return CMD_ERROR; } @@ -1636,12 +1636,8 @@ static void AircraftEventHandler_Flying(Vehicle *v, const AirportFTAClass *apc) uint16 tcur_speed, tsubspeed; st = GetStation(v->u.air.targetairport); - // flying device is accepted at this station - // small airport --> no helicopters (AIRCRAFT_ONLY) - // all other airports --> all types of flying devices (ALL) - // heliport/oilrig, etc --> no airplanes (HELICOPTERS_ONLY) // runway busy or not allowed to use this airstation, circle - if (v->subtype != apc->acc_planes && + if (apc->flags & (v->subtype == AIR_HELICOPTER ? AirportFTAClass::HELICOPTERS : AirportFTAClass::PLANES) && st->airport_tile != 0 && (st->owner == OWNER_NONE || st->owner == v->owner)) { // {32,FLYING,NOTHING_block,37}, {32,LANDING,N,33}, {32,HELILANDING,N,41}, diff --git a/src/airport.cpp b/src/airport.cpp index 89bf9e4ac..0f299aa35 100644 --- a/src/airport.cpp +++ b/src/airport.cpp @@ -37,7 +37,7 @@ void InitializeAirports(void) _airport_terminal_country, NULL, 16, - ALL, + AirportFTAClass::ALL, _airport_fta_country, _airport_depots_country, lengthof(_airport_depots_country), @@ -50,7 +50,7 @@ void InitializeAirports(void) _airport_terminal_city, NULL, 19, - ALL, + AirportFTAClass::ALL, _airport_fta_city, _airport_depots_city, lengthof(_airport_depots_city), @@ -63,7 +63,7 @@ void InitializeAirports(void) _airport_terminal_metropolitan, NULL, 20, - ALL, + AirportFTAClass::ALL, _airport_fta_metropolitan, _airport_depots_metropolitan, lengthof(_airport_depots_metropolitan), @@ -76,7 +76,7 @@ void InitializeAirports(void) _airport_terminal_international, _airport_helipad_international, 37, - ALL, + AirportFTAClass::ALL, _airport_fta_international, _airport_depots_international, lengthof(_airport_depots_international), @@ -89,7 +89,7 @@ void InitializeAirports(void) _airport_terminal_intercontinental, _airport_helipad_intercontinental, 43, - ALL, + AirportFTAClass::ALL, _airport_fta_intercontinental, _airport_depots_intercontinental, lengthof(_airport_depots_intercontinental), @@ -102,7 +102,7 @@ void InitializeAirports(void) NULL, _airport_helipad_heliport_oilrig, 7, - HELICOPTERS_ONLY, + AirportFTAClass::HELICOPTERS, _airport_fta_heliport_oilrig, NULL, 0, @@ -115,7 +115,7 @@ void InitializeAirports(void) NULL, _airport_helipad_heliport_oilrig, 7, - HELICOPTERS_ONLY, + AirportFTAClass::HELICOPTERS, _airport_fta_heliport_oilrig, NULL, 0, @@ -128,7 +128,7 @@ void InitializeAirports(void) _airport_terminal_commuter, _airport_helipad_commuter, 22, - ALL, + AirportFTAClass::ALL, _airport_fta_commuter, _airport_depots_commuter, lengthof(_airport_depots_commuter), @@ -141,7 +141,7 @@ void InitializeAirports(void) NULL, _airport_helipad_helidepot, 4, - HELICOPTERS_ONLY, + AirportFTAClass::HELICOPTERS, _airport_fta_helidepot, _airport_depots_helidepot, lengthof(_airport_depots_helidepot), @@ -154,7 +154,7 @@ void InitializeAirports(void) NULL, _airport_helipad_helistation, 25, - HELICOPTERS_ONLY, + AirportFTAClass::HELICOPTERS, _airport_fta_helistation, _airport_depots_helistation, lengthof(_airport_depots_helistation), @@ -192,7 +192,7 @@ AirportFTAClass::AirportFTAClass( const byte *terminals_, const byte *helipads_, const byte entry_point_, - const AcceptPlanes acc_planes_, + Flags flags_, const AirportFTAbuildup *apFA, const TileIndexDiffC *depots_, const byte nof_depots_, @@ -204,6 +204,7 @@ AirportFTAClass::AirportFTAClass( terminals(terminals_), helipads(helipads_), airport_depots(depots_), + flags(flags_), nof_depots(nof_depots_), nofelements(AirportGetNofElements(apFA)), entry_point(entry_point_), @@ -213,8 +214,6 @@ AirportFTAClass::AirportFTAClass( { byte nofterminalgroups, nofhelipadgroups; - acc_planes = acc_planes_; // XXX TinyEnumT has no initialisation, only assignment - /* Set up the terminal and helipad count for an airport. * TODO: If there are more than 10 terminals or 4 helipads, internal variables * need to be changed, so don't allow that for now */ diff --git a/src/airport.h b/src/airport.h index b6c94d5b5..1d940ddf8 100644 --- a/src/airport.h +++ b/src/airport.h @@ -24,18 +24,6 @@ enum { AT_OILRIG = 15 }; -// do not change unless you change v->subtype too. This aligns perfectly with its current setting -enum AcceptPlanes { - ACC_BEGIN = 0, - AIRCRAFT_ONLY = 0, - ALL = 1, - HELICOPTERS_ONLY = 2, - ACC_END -}; - -/** Define basic enum properties */ -template <> struct EnumPropsT<AcceptPlanes> : MakeEnumPropsT<AcceptPlanes, byte, ACC_BEGIN, ACC_END, ACC_END> {}; -typedef TinyEnumT<AcceptPlanes> AcceptPlanesByte; enum { AMED_NOSPDCLAMP = 1 << 0, @@ -133,12 +121,18 @@ struct AirportFTAbuildup; // Finite sTate mAchine --> FTA typedef struct AirportFTAClass { public: + enum Flags { + PLANES = 0x1, + HELICOPTERS = 0x2, + ALL = PLANES | HELICOPTERS, + }; + AirportFTAClass( const AirportMovingData *moving_data, const byte *terminals, const byte *helipads, byte entry_point, - AcceptPlanes acc_planes, + Flags flags, const AirportFTAbuildup *apFA, const TileIndexDiffC *depots, byte nof_depots, @@ -160,10 +154,10 @@ typedef struct AirportFTAClass { const byte *terminals; const byte *helipads; const TileIndexDiffC *airport_depots; // gives the position of the depots on the airports + Flags flags; byte nof_depots; // number of depots this airport has byte nofelements; // number of positions the airport consists of byte entry_point; // when an airplane arrives at this airport, enter it at position entry_point - AcceptPlanesByte acc_planes; // accept airplanes or helicopters or both byte size_x; byte size_y; byte delta_z; // Z adjustment for helicopter pads diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 61f9f7a58..283667f30 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -984,8 +984,8 @@ void ShowBuildVehicleWindow(TileIndex tile, byte type) ResizeWindow(w, 27, 0); break; case VEH_Aircraft: - AcceptPlanes acc_planes = (tile == 0) ? ALL : GetAirport(GetStationByTile(tile)->airport_type)->acc_planes; - bv->filter.acc_planes = acc_planes; + bv->filter.flags = + tile == 0 ? AirportFTAClass::ALL : GetAirport(GetStationByTile(tile)->airport_type)->flags; ResizeWindow(w, 12, 0); break; } diff --git a/src/window.h b/src/window.h index b671271e5..bd5142756 100644 --- a/src/window.h +++ b/src/window.h @@ -321,7 +321,7 @@ typedef struct { byte vehicle_type; union { RailTypeByte railtype; - AcceptPlanesByte acc_planes; // AIRCRAFT_ONLY, ALL, HELICOPTERS_ONLY + AirportFTAClass::Flags flags; } filter; byte sel_index; // deprecated value, used for 'unified' ship and road bool descending_sort_order; |