mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use EnumBitSet for AirportFTAClass::Flags (#13535)
parent
9cdf740097
commit
0d5708ba86
|
@ -149,10 +149,10 @@ static StationID FindNearestHangar(const Aircraft *v)
|
|||
const AirportFTAClass *afc = st->airport.GetFTA();
|
||||
|
||||
/* don't crash the plane if we know it can't land at the airport */
|
||||
if ((afc->flags & AirportFTAClass::SHORT_STRIP) && (avi->subtype & AIR_FAST) && !_cheats.no_jetcrash.value) continue;
|
||||
if (afc->flags.Test(AirportFTAClass::Flag::ShortStrip) && (avi->subtype & AIR_FAST) && !_cheats.no_jetcrash.value) continue;
|
||||
|
||||
/* the plane won't land at any helicopter station */
|
||||
if (!(afc->flags & AirportFTAClass::AIRPLANES) && (avi->subtype & AIR_CTOL)) continue;
|
||||
if (!afc->flags.Test(AirportFTAClass::Flag::Airplanes) && (avi->subtype & AIR_CTOL)) continue;
|
||||
|
||||
/* Check if our last and next destinations can be reached from the depot airport. */
|
||||
if (max_range != 0) {
|
||||
|
@ -1373,7 +1373,7 @@ static void MaybeCrashAirplane(Aircraft *v)
|
|||
Station *st = Station::Get(v->targetairport);
|
||||
|
||||
uint32_t prob;
|
||||
if ((st->airport.GetFTA()->flags & AirportFTAClass::SHORT_STRIP) &&
|
||||
if (st->airport.GetFTA()->flags.Test(AirportFTAClass::Flag::ShortStrip) &&
|
||||
(AircraftVehInfo(v->engine_type)->subtype & AIR_FAST) &&
|
||||
!_cheats.no_jetcrash.value) {
|
||||
prob = 3276;
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
* @param short_strip Airport has a short land/take-off strip.
|
||||
*/
|
||||
#define AIRPORT(name, num_helipads, short_strip) \
|
||||
AIRPORT_GENERIC(name, _airport_terminal_ ## name, num_helipads, AirportFTAClass::ALL | (short_strip ? AirportFTAClass::SHORT_STRIP : (AirportFTAClass::Flags)0), 0)
|
||||
AIRPORT_GENERIC(name, _airport_terminal_ ## name, num_helipads, AirportFTAClass::Flags({AirportFTAClass::Flag::Airplanes, AirportFTAClass::Flag::Helicopters}) | (short_strip ? AirportFTAClass::Flags{AirportFTAClass::Flag::ShortStrip} : AirportFTAClass::Flags{}), 0)
|
||||
|
||||
/**
|
||||
* Define a heliport.
|
||||
|
@ -44,7 +44,7 @@
|
|||
* @param delta_z Height of the airport above the land.
|
||||
*/
|
||||
#define HELIPORT(name, num_helipads, delta_z) \
|
||||
AIRPORT_GENERIC(name, nullptr, num_helipads, AirportFTAClass::HELICOPTERS, delta_z)
|
||||
AIRPORT_GENERIC(name, nullptr, num_helipads, AirportFTAClass::Flag::Helicopters, delta_z)
|
||||
|
||||
AIRPORT(country, 0, true)
|
||||
AIRPORT(city, 0, false)
|
||||
|
@ -56,7 +56,7 @@ HELIPORT(helidepot, 1, 0)
|
|||
AIRPORT(intercontinental, 2, false)
|
||||
HELIPORT(helistation, 3, 0)
|
||||
HELIPORT(oilrig, 1, 54)
|
||||
AIRPORT_GENERIC(dummy, nullptr, 0, AirportFTAClass::ALL, 0)
|
||||
AIRPORT_GENERIC(dummy, nullptr, 0, AirportFTAClass::Flags({AirportFTAClass::Flag::Airplanes, AirportFTAClass::Flag::Helicopters}), 0)
|
||||
|
||||
#undef HELIPORT
|
||||
#undef AIRPORT
|
||||
|
|
|
@ -154,12 +154,12 @@ struct AirportFTA {
|
|||
struct AirportFTAClass {
|
||||
public:
|
||||
/** Bitmask of airport flags. */
|
||||
enum Flags : uint8_t {
|
||||
AIRPLANES = 0x1, ///< Can planes land on this airport type?
|
||||
HELICOPTERS = 0x2, ///< Can helicopters land on this airport type?
|
||||
ALL = AIRPLANES | HELICOPTERS, ///< Mask to check for both planes and helicopters.
|
||||
SHORT_STRIP = 0x4, ///< This airport has a short landing strip, dangerous for fast aircraft.
|
||||
enum class Flag : uint8_t {
|
||||
Airplanes = 0, ///< Can planes land on this airport type?
|
||||
Helicopters = 1, ///< Can helicopters land on this airport type?
|
||||
ShortStrip = 2, ///< This airport has a short landing strip, dangerous for fast aircraft.
|
||||
};
|
||||
using Flags = EnumBitSet<Flag, uint8_t>;
|
||||
|
||||
AirportFTAClass(
|
||||
const AirportMovingData *moving_data,
|
||||
|
@ -192,8 +192,6 @@ public:
|
|||
uint8_t delta_z; ///< Z adjustment for helicopter pads
|
||||
};
|
||||
|
||||
DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags)
|
||||
|
||||
|
||||
const AirportFTAClass *GetAirport(const uint8_t airport_type);
|
||||
uint8_t GetVehiclePosOnBuild(TileIndex hangar_tile);
|
||||
|
|
|
@ -1729,7 +1729,7 @@ void CheckOrders(const Vehicle *v)
|
|||
message = STR_NEWS_VEHICLE_HAS_INVALID_ENTRY;
|
||||
} else if (v->type == VEH_AIRCRAFT &&
|
||||
(AircraftVehInfo(v->engine_type)->subtype & AIR_FAST) &&
|
||||
(st->airport.GetFTA()->flags & AirportFTAClass::SHORT_STRIP) &&
|
||||
st->airport.GetFTA()->flags.Test(AirportFTAClass::Flag::ShortStrip) &&
|
||||
!_cheats.no_jetcrash.value &&
|
||||
message == INVALID_STRING_ID) {
|
||||
message = STR_NEWS_PLANE_USES_TOO_SHORT_RUNWAY;
|
||||
|
|
|
@ -2591,7 +2591,7 @@ CommandCost CmdBuildAirport(DoCommandFlag flags, TileIndex tile, uint8_t airport
|
|||
/* Distant join */
|
||||
if (st == nullptr && distant_join) st = Station::GetIfValid(station_to_join);
|
||||
|
||||
ret = BuildStationPart(&st, flags, reuse, airport_area, (GetAirport(airport_type)->flags & AirportFTAClass::AIRPLANES) ? STATIONNAMING_AIRPORT : STATIONNAMING_HELIPORT);
|
||||
ret = BuildStationPart(&st, flags, reuse, airport_area, GetAirport(airport_type)->flags.Test(AirportFTAClass::Flag::Airplanes) ? STATIONNAMING_AIRPORT : STATIONNAMING_HELIPORT);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
if (st != nullptr && st->airport.tile != INVALID_TILE) {
|
||||
|
|
|
@ -3075,7 +3075,7 @@ bool CanVehicleUseStation(EngineID engine_type, const Station *st)
|
|||
|
||||
case VEH_AIRCRAFT:
|
||||
return (st->facilities & FACIL_AIRPORT) != 0 &&
|
||||
(st->airport.GetFTA()->flags & (e->u.air.subtype & AIR_CTOL ? AirportFTAClass::AIRPLANES : AirportFTAClass::HELICOPTERS)) != 0;
|
||||
st->airport.GetFTA()->flags.Test(e->u.air.subtype & AIR_CTOL ? AirportFTAClass::Flag::Airplanes : AirportFTAClass::Flag::Helicopters);
|
||||
|
||||
default:
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue