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