diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 019f9731a5..e87fcd9f39 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -1415,8 +1415,8 @@ static void AircraftEntersTerminal(Aircraft *v) v->last_station_visited = v->targetairport; /* Check if station was ever visited before */ - if (!(st->had_vehicle_of_type & HVOT_AIRCRAFT)) { - st->had_vehicle_of_type |= HVOT_AIRCRAFT; + if (!st->had_vehicle_of_type.Test(StationVehicleType::Aircraft)) { + st->had_vehicle_of_type.Set(StationVehicleType::Aircraft); /* show newsitem of celebrating citizens */ AddVehicleNewsItem( GetEncodedString(STR_NEWS_FIRST_AIRCRAFT_ARRIVAL, st->index), diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp index 21c18b20df..32c6483115 100644 --- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -430,7 +430,7 @@ uint32_t Station::GetNewGRFVariable(const ResolverObject &object, uint8_t variab return value; } - case 0x8A: return this->had_vehicle_of_type; + case 0x8A: return this->had_vehicle_of_type.base(); case 0xF1: return (this->airport.tile != INVALID_TILE) ? this->airport.GetSpec()->ttd_airport_type : ATP_TTDP_LARGE; case 0xF2: return (this->truck_stops != nullptr) ? this->truck_stops->status.base() : 0; case 0xF3: return (this->bus_stops != nullptr) ? this->bus_stops->status.base() : 0; @@ -487,7 +487,7 @@ uint32_t Waypoint::GetNewGRFVariable(const ResolverObject &, uint8_t variable, [ { switch (variable) { case 0x48: return 0; // Accepted cargo types - case 0x8A: return HVOT_WAYPOINT; + case 0x8A: return StationVehicleTypes{StationVehicleType::Waypoint}.base(); case 0xF1: return 0; // airport type case 0xF2: return 0; // truck stop status case 0xF3: return 0; // bus stop status diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 6a0d8e69e1..70373eed0e 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -705,8 +705,8 @@ static void RoadVehArrivesAt(const RoadVehicle *v, Station *st) { if (v->IsBus()) { /* Check if station was ever visited before */ - if (!(st->had_vehicle_of_type & HVOT_BUS)) { - st->had_vehicle_of_type |= HVOT_BUS; + if (!st->had_vehicle_of_type.Test(StationVehicleType::Bus)) { + st->had_vehicle_of_type.Set(StationVehicleType::Bus); AddVehicleNewsItem( GetEncodedString(RoadTypeIsRoad(v->roadtype) ? STR_NEWS_FIRST_BUS_ARRIVAL : STR_NEWS_FIRST_PASSENGER_TRAM_ARRIVAL, st->index), (v->owner == _local_company) ? NewsType::ArrivalCompany : NewsType::ArrivalOther, @@ -718,8 +718,8 @@ static void RoadVehArrivesAt(const RoadVehicle *v, Station *st) } } else { /* Check if station was ever visited before */ - if (!(st->had_vehicle_of_type & HVOT_TRUCK)) { - st->had_vehicle_of_type |= HVOT_TRUCK; + if (!st->had_vehicle_of_type.Test(StationVehicleType::Truck)) { + st->had_vehicle_of_type.Set(StationVehicleType::Truck); AddVehicleNewsItem( GetEncodedString(RoadTypeIsRoad(v->roadtype) ? STR_NEWS_FIRST_TRUCK_ARRIVAL : STR_NEWS_FIRST_CARGO_TRAM_ARRIVAL, st->index), (v->owner == _local_company) ? NewsType::ArrivalCompany : NewsType::ArrivalOther, diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp index 68dfa445db..6b6440e32a 100644 --- a/src/saveload/station_sl.cpp +++ b/src/saveload/station_sl.cpp @@ -33,7 +33,7 @@ static void UpdateWaypointOrder(Order &o) if (!o.IsType(OT_GOTO_STATION)) return; const Station *st = Station::Get(o.GetDestination().ToStationID()); - if ((st->had_vehicle_of_type & HVOT_WAYPOINT) == 0) return; + if (!st->had_vehicle_of_type.Test(StationVehicleType::Waypoint)) return; o.MakeGoToWaypoint(o.GetDestination().ToStationID()); } @@ -61,7 +61,7 @@ void MoveBuoysToWaypoints() /* Now make the stations waypoints */ for (Station *st : Station::Iterate()) { - if ((st->had_vehicle_of_type & HVOT_WAYPOINT) == 0) continue; + if (!st->had_vehicle_of_type.Test(StationVehicleType::Waypoint)) continue; StationID index = st->index; TileIndex xy = st->xy; diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index 4e3c5d9954..d4548d5ec8 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -440,8 +440,8 @@ static uint ShipAccelerate(Vehicle *v) static void ShipArrivesAt(const Vehicle *v, Station *st) { /* Check if station was ever visited before */ - if (!(st->had_vehicle_of_type & HVOT_SHIP)) { - st->had_vehicle_of_type |= HVOT_SHIP; + if (!st->had_vehicle_of_type.Test(StationVehicleType::Ship)) { + st->had_vehicle_of_type.Set(StationVehicleType::Ship); AddVehicleNewsItem( GetEncodedString(STR_NEWS_FIRST_SHIP_ARRIVAL, st->index), diff --git a/src/station_base.h b/src/station_base.h index e7eb8772d8..fc7c66e1da 100644 --- a/src/station_base.h +++ b/src/station_base.h @@ -546,7 +546,7 @@ public: BitmapTileArea catchment_tiles{}; ///< NOSAVE: Set of individual tiles covered by catchment area - StationHadVehicleOfType had_vehicle_of_type{}; + StationVehicleTypes had_vehicle_of_type{}; uint8_t time_since_load = 0; uint8_t time_since_unload = 0; diff --git a/src/station_type.h b/src/station_type.h index a8dcb5ae4e..0c0db0f561 100644 --- a/src/station_type.h +++ b/src/station_type.h @@ -61,17 +61,18 @@ using StationFacilities = EnumBitSet; static constexpr StationFacility STATION_FACILITY_GHOST{6}; /** The vehicles that may have visited a station */ -enum StationHadVehicleOfType : uint8_t { - HVOT_NONE = 0, ///< Station has seen no vehicles - HVOT_TRAIN = 1 << 1, ///< Station has seen a train - HVOT_BUS = 1 << 2, ///< Station has seen a bus - HVOT_TRUCK = 1 << 3, ///< Station has seen a truck - HVOT_AIRCRAFT = 1 << 4, ///< Station has seen an aircraft - HVOT_SHIP = 1 << 5, ///< Station has seen a ship +enum class StationVehicleType : uint8_t { + Train = 1, ///< Station has seen a train + Bus = 2, ///< Station has seen a bus + Truck = 3, ///< Station has seen a truck + Aircraft = 4, ///< Station has seen an aircraft + Ship = 5, ///< Station has seen a ship - HVOT_WAYPOINT = 1 << 6, ///< Station is a waypoint (NewGRF only!) + Waypoint = 6, ///< Station is a waypoint (Save load conversion and NewGRF only!) }; -DECLARE_ENUM_AS_BIT_SET(StationHadVehicleOfType) + +/** Bitset of \c StationVehicleType elements. */ +using StationVehicleTypes = EnumBitSet; /** Randomisation triggers for stations and roadstops */ enum class StationRandomTrigger : uint8_t { diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index da6bd43e05..b676250aee 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -3092,8 +3092,8 @@ static void TrainEnterStation(Train *consist, StationID station) /* check if a train ever visited this station before */ Station *st = Station::Get(station); - if (!(st->had_vehicle_of_type & HVOT_TRAIN)) { - st->had_vehicle_of_type |= HVOT_TRAIN; + if (!st->had_vehicle_of_type.Test(StationVehicleType::Train)) { + st->had_vehicle_of_type.Set(StationVehicleType::Train); AddVehicleNewsItem( GetEncodedString(STR_NEWS_FIRST_TRAIN_ARRIVAL, st->index), consist->owner == _local_company ? NewsType::ArrivalCompany : NewsType::ArrivalOther,