diff --git a/src/cargotype.cpp b/src/cargotype.cpp index 4fff75b7d5..ace016ae32 100644 --- a/src/cargotype.cpp +++ b/src/cargotype.cpp @@ -207,11 +207,11 @@ static bool CargoSpecNameSorter(const CargoSpec * const &a, const CargoSpec * co /** Sort cargo specifications by their cargo class. */ static bool CargoSpecClassSorter(const CargoSpec * const &a, const CargoSpec * const &b) { - int res = (b->classes & CC_PASSENGERS) - (a->classes & CC_PASSENGERS); + int res = b->classes.Test(CargoClass::Passengers) - a->classes.Test(CargoClass::Passengers); if (res == 0) { - res = (b->classes & CC_MAIL) - (a->classes & CC_MAIL); + res = b->classes.Test(CargoClass::Mail) - a->classes.Test(CargoClass::Mail); if (res == 0) { - res = (a->classes & CC_SPECIAL) - (b->classes & CC_SPECIAL); + res = a->classes.Test(CargoClass::Special) - b->classes.Test(CargoClass::Special); if (res == 0) { return CargoSpecNameSorter(a, b); } @@ -245,7 +245,7 @@ void InitializeSortedCargoSpecs() for (const auto &cargo : _sorted_cargo_specs) { assert(cargo->town_production_effect != INVALID_TPE); CargoSpec::town_production_cargoes[cargo->town_production_effect].push_back(cargo); - if (cargo->classes & CC_SPECIAL) break; + if (cargo->classes.Test(CargoClass::Special)) break; nb_standard_cargo++; SetBit(_standard_cargo_mask, cargo->Index()); } diff --git a/src/cargotype.h b/src/cargotype.h index c36aa3afcb..ba351e8819 100644 --- a/src/cargotype.h +++ b/src/cargotype.h @@ -46,28 +46,25 @@ enum TownProductionEffect : uint8_t { }; /** Cargo classes. */ -enum CargoClass : uint16_t { - CC_NOAVAILABLE = 0, ///< No cargo class has been specified - CC_PASSENGERS = 1 << 0, ///< Passengers - CC_MAIL = 1 << 1, ///< Mail - CC_EXPRESS = 1 << 2, ///< Express cargo (Goods, Food, Candy, but also possible for passengers) - CC_ARMOURED = 1 << 3, ///< Armoured cargo (Valuables, Gold, Diamonds) - CC_BULK = 1 << 4, ///< Bulk cargo (Coal, Grain etc., Ores, Fruit) - CC_PIECE_GOODS = 1 << 5, ///< Piece goods (Livestock, Wood, Steel, Paper) - CC_LIQUID = 1 << 6, ///< Liquids (Oil, Water, Rubber) - CC_REFRIGERATED = 1 << 7, ///< Refrigerated cargo (Food, Fruit) - CC_HAZARDOUS = 1 << 8, ///< Hazardous cargo (Nuclear Fuel, Explosives, etc.) - CC_COVERED = 1 << 9, ///< Covered/Sheltered Freight (Transportation in Box Vans, Silo Wagons, etc.) - CC_OVERSIZED = 1 << 10, ///< Oversized (stake/flatbed wagon) - CC_POWDERIZED = 1 << 11, ///< Powderized, moist protected (powder/silo wagon) - CC_NOT_POURABLE = 1 << 12, ///< Not Pourable (open wagon, but not hopper wagon) - CC_POTABLE = 1 << 13, ///< Potable / food / clean. - CC_NON_POTABLE = 1 << 14, ///< Non-potable / non-food / dirty. - CC_SPECIAL = 1 << 15, ///< Special bit used for livery refit tricks instead of normal cargoes. +enum class CargoClass : uint8_t { + Passengers = 0, ///< Passengers + Mail = 1, ///< Mail + Express = 2, ///< Express cargo (Goods, Food, Candy, but also possible for passengers) + Armoured = 3, ///< Armoured cargo (Valuables, Gold, Diamonds) + Bulk = 4, ///< Bulk cargo (Coal, Grain etc., Ores, Fruit) + PieceGoods = 5, ///< Piece goods (Livestock, Wood, Steel, Paper) + Liquid = 6, ///< Liquids (Oil, Water, Rubber) + Refrigerated = 7, ///< Refrigerated cargo (Food, Fruit) + Hazardous = 8, ///< Hazardous cargo (Nuclear Fuel, Explosives, etc.) + Covered = 9, ///< Covered/Sheltered Freight (Transportation in Box Vans, Silo Wagons, etc.) + Oversized = 10, ///< Oversized (stake/flatbed wagon) + Powderized = 11, ///< Powderized, moist protected (powder/silo wagon) + NotPourable = 12, ///< Not Pourable (open wagon, but not hopper wagon) + Potable = 13, ///< Potable / food / clean. + NonPotable = 14, ///< Non-potable / non-food / dirty. + Special = 15, ///< Special bit used for livery refit tricks instead of normal cargoes. }; - -/** Bitmask of cargo classes. */ -using CargoClasses = uint16_t; +using CargoClasses = EnumBitSet; static const uint8_t INVALID_CARGO_BITNUM = 0xFF; ///< Constant representing invalid cargo @@ -236,9 +233,9 @@ extern std::span _sorted_standard_cargo_specs; * @param cc Cargo class. * @return The type fits in the class. */ -inline bool IsCargoInClass(CargoType c, CargoClass cc) +inline bool IsCargoInClass(CargoType c, CargoClasses cc) { - return (CargoSpec::Get(c)->classes & cc) != 0; + return CargoSpec::Get(c)->classes.Any(cc); } using SetCargoBitIterator = SetBitIterator; diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 548d6abe1e..19449b17e1 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -2713,22 +2713,22 @@ static void ConDumpCargoTypes() spec->bitnum, FormatLabel(spec->label.base()), spec->callback_mask.base(), - (spec->classes & CC_PASSENGERS) != 0 ? 'p' : '-', - (spec->classes & CC_MAIL) != 0 ? 'm' : '-', - (spec->classes & CC_EXPRESS) != 0 ? 'x' : '-', - (spec->classes & CC_ARMOURED) != 0 ? 'a' : '-', - (spec->classes & CC_BULK) != 0 ? 'b' : '-', - (spec->classes & CC_PIECE_GOODS) != 0 ? 'g' : '-', - (spec->classes & CC_LIQUID) != 0 ? 'l' : '-', - (spec->classes & CC_REFRIGERATED) != 0 ? 'r' : '-', - (spec->classes & CC_HAZARDOUS) != 0 ? 'h' : '-', - (spec->classes & CC_COVERED) != 0 ? 'c' : '-', - (spec->classes & CC_OVERSIZED) != 0 ? 'o' : '-', - (spec->classes & CC_POWDERIZED) != 0 ? 'd' : '-', - (spec->classes & CC_NOT_POURABLE) != 0 ? 'n' : '-', - (spec->classes & CC_POTABLE) != 0 ? 'e' : '-', - (spec->classes & CC_NON_POTABLE) != 0 ? 'i' : '-', - (spec->classes & CC_SPECIAL) != 0 ? 'S' : '-', + spec->classes.Test(CargoClass::Passengers) ? 'p' : '-', + spec->classes.Test(CargoClass::Mail) ? 'm' : '-', + spec->classes.Test(CargoClass::Express) ? 'x' : '-', + spec->classes.Test(CargoClass::Armoured) ? 'a' : '-', + spec->classes.Test(CargoClass::Bulk) ? 'b' : '-', + spec->classes.Test(CargoClass::PieceGoods) ? 'g' : '-', + spec->classes.Test(CargoClass::Liquid) ? 'l' : '-', + spec->classes.Test(CargoClass::Refrigerated) ? 'r' : '-', + spec->classes.Test(CargoClass::Hazardous) ? 'h' : '-', + spec->classes.Test(CargoClass::Covered) ? 'c' : '-', + spec->classes.Test(CargoClass::Oversized) ? 'o' : '-', + spec->classes.Test(CargoClass::Powderized) ? 'd' : '-', + spec->classes.Test(CargoClass::NotPourable) ? 'n' : '-', + spec->classes.Test(CargoClass::Potable) ? 'e' : '-', + spec->classes.Test(CargoClass::NonPotable) ? 'i' : '-', + spec->classes.Test(CargoClass::Special) ? 'S' : '-', std::byteswap(grfid), GetStringPtr(spec->name) ); diff --git a/src/economy.cpp b/src/economy.cpp index 08b2307f57..8bbe2b9e5f 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -1887,7 +1887,7 @@ static void LoadUnloadVehicle(Vehicle *front) if (front->current_order.GetLoadType() == OLF_FULL_LOAD_ANY) { /* if the aircraft carries passengers and is NOT full, then * continue loading, no matter how much mail is in */ - if ((front->type == VEH_AIRCRAFT && IsCargoInClass(front->cargo_type, CC_PASSENGERS) && front->cargo_cap > front->cargo.StoredCount()) || + if ((front->type == VEH_AIRCRAFT && IsCargoInClass(front->cargo_type, CargoClass::Passengers) && front->cargo_cap > front->cargo.StoredCount()) || (cargo_not_full != 0 && (cargo_full & ~cargo_not_full) == 0)) { // There are still non-full cargoes finished_loading = false; } diff --git a/src/engine.cpp b/src/engine.cpp index 3e71f43187..664aa8b43a 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -209,7 +209,7 @@ uint Engine::DetermineCapacity(const Vehicle *v, uint16_t *mail_capacity) const CargoType default_cargo = this->GetDefaultCargoType(); CargoType cargo_type = (v != nullptr) ? v->cargo_type : default_cargo; - if (mail_capacity != nullptr && this->type == VEH_AIRCRAFT && IsCargoInClass(cargo_type, CC_PASSENGERS)) { + if (mail_capacity != nullptr && this->type == VEH_AIRCRAFT && IsCargoInClass(cargo_type, CargoClass::Passengers)) { *mail_capacity = GetEngineProperty(this->index, PROP_AIRCRAFT_MAIL_CAPACITY, this->u.air.mail_capacity, v); } @@ -241,7 +241,7 @@ uint Engine::DetermineCapacity(const Vehicle *v, uint16_t *mail_capacity) const case VEH_AIRCRAFT: capacity = GetEngineProperty(this->index, PROP_AIRCRAFT_PASSENGER_CAPACITY, this->u.air.passenger_capacity, v); - if (!IsCargoInClass(cargo_type, CC_PASSENGERS)) { + if (!IsCargoInClass(cargo_type, CargoClass::Passengers)) { extra_mail_cap = GetEngineProperty(this->index, PROP_AIRCRAFT_MAIL_CAPACITY, this->u.air.mail_capacity, v); } if (IsValidCargoType(GetCargoTypeByLabel(CT_MAIL))) { diff --git a/src/linkgraph/mcf.cpp b/src/linkgraph/mcf.cpp index c47684053e..d72efb0cff 100644 --- a/src/linkgraph/mcf.cpp +++ b/src/linkgraph/mcf.cpp @@ -285,9 +285,9 @@ void MultiCommodityFlow::Dijkstra(NodeID source_node, PathVector &paths) /* Prioritize the fastest route for passengers, mail and express cargo, * and the shortest route for other classes of cargo. * In-between stops are punished with a 1 tile or 1 day penalty. */ - bool express = IsCargoInClass(this->job.Cargo(), CC_PASSENGERS) || - IsCargoInClass(this->job.Cargo(), CC_MAIL) || - IsCargoInClass(this->job.Cargo(), CC_EXPRESS); + bool express = IsCargoInClass(this->job.Cargo(), CargoClass::Passengers) || + IsCargoInClass(this->job.Cargo(), CargoClass::Mail) || + IsCargoInClass(this->job.Cargo(), CargoClass::Express); uint distance = DistanceMaxPlusManhattan(this->job[from].base.xy, this->job[to].base.xy) + 1; /* Compute a default travel time from the distance and an average speed of 1 tile/day. */ uint time = (edge.base.TravelTime() != 0) ? edge.base.TravelTime() + Ticks::DAY_TICKS : distance * Ticks::DAY_TICKS; diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 3c857f99c3..ede6313cb7 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -1299,13 +1299,13 @@ static ChangeInfoResult RailVehicleChangeInfo(uint first, uint last, int prop, B break; case 0x28: // Cargo classes allowed - _gted[e->index].cargo_allowed = buf.ReadWord(); - _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed != 0); + _gted[e->index].cargo_allowed = CargoClasses{buf.ReadWord()}; + _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed != CargoClasses{}); _gted[e->index].defaultcargo_grf = _cur.grffile; break; case 0x29: // Cargo classes disallowed - _gted[e->index].cargo_disallowed = buf.ReadWord(); + _gted[e->index].cargo_disallowed = CargoClasses{buf.ReadWord()}; _gted[e->index].UpdateRefittability(false); break; @@ -1351,7 +1351,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint first, uint last, int prop, B } case 0x32: // Cargo classes required for a refit. - _gted[e->index].cargo_allowed_required = buf.ReadWord(); + _gted[e->index].cargo_allowed_required = CargoClasses{buf.ReadWord()}; break; default: @@ -1496,13 +1496,13 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint first, uint last, int prop, B break; case 0x1D: // Cargo classes allowed - _gted[e->index].cargo_allowed = buf.ReadWord(); - _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed != 0); + _gted[e->index].cargo_allowed = CargoClasses{buf.ReadWord()}; + _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed != CargoClasses{}); _gted[e->index].defaultcargo_grf = _cur.grffile; break; case 0x1E: // Cargo classes disallowed - _gted[e->index].cargo_disallowed = buf.ReadWord(); + _gted[e->index].cargo_disallowed = CargoClasses{buf.ReadWord()}; _gted[e->index].UpdateRefittability(false); break; @@ -1562,7 +1562,7 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint first, uint last, int prop, B } case 0x29: // Cargo classes required for a refit. - _gted[e->index].cargo_allowed_required = buf.ReadWord(); + _gted[e->index].cargo_allowed_required = CargoClasses{buf.ReadWord()}; break; default: @@ -1689,13 +1689,13 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint first, uint last, int prop, B break; case 0x18: // Cargo classes allowed - _gted[e->index].cargo_allowed = buf.ReadWord(); - _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed != 0); + _gted[e->index].cargo_allowed = CargoClasses{buf.ReadWord()}; + _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed != CargoClasses{}); _gted[e->index].defaultcargo_grf = _cur.grffile; break; case 0x19: // Cargo classes disallowed - _gted[e->index].cargo_disallowed = buf.ReadWord(); + _gted[e->index].cargo_disallowed = CargoClasses{buf.ReadWord()}; _gted[e->index].UpdateRefittability(false); break; @@ -1759,7 +1759,7 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint first, uint last, int prop, B break; case 0x25: // Cargo classes required for a refit. - _gted[e->index].cargo_allowed_required = buf.ReadWord(); + _gted[e->index].cargo_allowed_required = CargoClasses{buf.ReadWord()}; break; default: @@ -1878,13 +1878,13 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint first, uint last, int pro break; case 0x18: // Cargo classes allowed - _gted[e->index].cargo_allowed = buf.ReadWord(); - _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed != 0); + _gted[e->index].cargo_allowed = CargoClasses{buf.ReadWord()}; + _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed != CargoClasses{}); _gted[e->index].defaultcargo_grf = _cur.grffile; break; case 0x19: // Cargo classes disallowed - _gted[e->index].cargo_disallowed = buf.ReadWord(); + _gted[e->index].cargo_disallowed = CargoClasses{buf.ReadWord()}; _gted[e->index].UpdateRefittability(false); break; @@ -1934,7 +1934,7 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint first, uint last, int pro } case 0x23: // Cargo classes required for a refit. - _gted[e->index].cargo_allowed_required = buf.ReadWord(); + _gted[e->index].cargo_allowed_required = CargoClasses{buf.ReadWord()}; break; default: @@ -3167,7 +3167,7 @@ static ChangeInfoResult CargoChangeInfo(uint first, uint last, int prop, ByteRea break; case 0x16: // Cargo classes - cs->classes = buf.ReadWord(); + cs->classes = CargoClasses{buf.ReadWord()}; break; case 0x17: // Cargo label @@ -9057,47 +9057,47 @@ static void CalculateRefitMasks() CargoClasses cargo_allowed; CargoClasses cargo_disallowed; } _default_refit_masks[] = { - {{T, A, S, Y}, CT_PASSENGERS, CC_PASSENGERS, 0}, - {{T, A, S }, CT_MAIL, CC_MAIL, 0}, - {{T, A, S }, CT_VALUABLES, CC_ARMOURED, CC_LIQUID}, - {{ Y}, CT_MAIL, CC_MAIL | CC_ARMOURED, CC_LIQUID}, - {{T, A }, CT_COAL, CC_BULK, 0}, - {{ S }, CT_COPPER_ORE, CC_BULK, 0}, - {{ Y}, CT_SUGAR, CC_BULK, 0}, - {{T, A, S }, CT_OIL, CC_LIQUID, 0}, - {{ Y}, CT_COLA, CC_LIQUID, 0}, - {{T }, CT_GOODS, CC_PIECE_GOODS | CC_EXPRESS, CC_LIQUID | CC_PASSENGERS}, - {{ A, S }, CT_GOODS, CC_PIECE_GOODS | CC_EXPRESS, CC_LIQUID | CC_PASSENGERS | CC_REFRIGERATED}, - {{ A, S }, CT_FOOD, CC_REFRIGERATED, 0}, - {{ Y}, CT_CANDY, CC_PIECE_GOODS | CC_EXPRESS, CC_LIQUID | CC_PASSENGERS}, + {{T, A, S, Y}, CT_PASSENGERS, {CargoClass::Passengers}, {}}, + {{T, A, S }, CT_MAIL, {CargoClass::Mail}, {}}, + {{T, A, S }, CT_VALUABLES, {CargoClass::Armoured}, {CargoClass::Liquid}}, + {{ Y}, CT_MAIL, {CargoClass::Mail, CargoClass::Armoured}, {CargoClass::Liquid}}, + {{T, A }, CT_COAL, {CargoClass::Bulk}, {}}, + {{ S }, CT_COPPER_ORE, {CargoClass::Bulk}, {}}, + {{ Y}, CT_SUGAR, {CargoClass::Bulk}, {}}, + {{T, A, S }, CT_OIL, {CargoClass::Liquid}, {}}, + {{ Y}, CT_COLA, {CargoClass::Liquid}, {}}, + {{T }, CT_GOODS, {CargoClass::PieceGoods, CargoClass::Express}, {CargoClass::Liquid, CargoClass::Passengers}}, + {{ A, S }, CT_GOODS, {CargoClass::PieceGoods, CargoClass::Express}, {CargoClass::Liquid, CargoClass::Passengers, CargoClass::Refrigerated}}, + {{ A, S }, CT_FOOD, {CargoClass::Refrigerated}, {}}, + {{ Y}, CT_CANDY, {CargoClass::PieceGoods, CargoClass::Express}, {CargoClass::Liquid, CargoClass::Passengers}}, }; if (e->type == VEH_AIRCRAFT) { /* Aircraft default to "light" cargoes */ - _gted[engine].cargo_allowed = CC_PASSENGERS | CC_MAIL | CC_ARMOURED | CC_EXPRESS; - _gted[engine].cargo_disallowed = CC_LIQUID; + _gted[engine].cargo_allowed = {CargoClass::Passengers, CargoClass::Mail, CargoClass::Armoured, CargoClass::Express}; + _gted[engine].cargo_disallowed = {CargoClass::Liquid}; } else if (e->type == VEH_SHIP) { CargoLabel label = GetActiveCargoLabel(ei->cargo_label); switch (label.base()) { case CT_PASSENGERS.base(): /* Ferries */ - _gted[engine].cargo_allowed = CC_PASSENGERS; - _gted[engine].cargo_disallowed = 0; + _gted[engine].cargo_allowed = {CargoClass::Passengers}; + _gted[engine].cargo_disallowed = {}; break; case CT_OIL.base(): /* Tankers */ - _gted[engine].cargo_allowed = CC_LIQUID; - _gted[engine].cargo_disallowed = 0; + _gted[engine].cargo_allowed = {CargoClass::Liquid}; + _gted[engine].cargo_disallowed = {}; break; default: /* Cargo ships */ if (_settings_game.game_creation.landscape == LandscapeType::Toyland) { /* No tanker in toyland :( */ - _gted[engine].cargo_allowed = CC_MAIL | CC_ARMOURED | CC_EXPRESS | CC_BULK | CC_PIECE_GOODS | CC_LIQUID; - _gted[engine].cargo_disallowed = CC_PASSENGERS; + _gted[engine].cargo_allowed = {CargoClass::Mail, CargoClass::Armoured, CargoClass::Express, CargoClass::Bulk, CargoClass::PieceGoods, CargoClass::Liquid}; + _gted[engine].cargo_disallowed = {CargoClass::Passengers}; } else { - _gted[engine].cargo_allowed = CC_MAIL | CC_ARMOURED | CC_EXPRESS | CC_BULK | CC_PIECE_GOODS; - _gted[engine].cargo_disallowed = CC_LIQUID | CC_PASSENGERS; + _gted[engine].cargo_allowed = {CargoClass::Mail, CargoClass::Armoured, CargoClass::Express, CargoClass::Bulk, CargoClass::PieceGoods}; + _gted[engine].cargo_disallowed = {CargoClass::Liquid, CargoClass::Passengers}; } break; } @@ -9105,8 +9105,8 @@ static void CalculateRefitMasks() } else if (e->type == VEH_TRAIN && e->u.rail.railveh_type != RAILVEH_WAGON) { /* Train engines default to all cargoes, so you can build single-cargo consists with fast engines. * Trains loading multiple cargoes may start stations accepting unwanted cargoes. */ - _gted[engine].cargo_allowed = CC_PASSENGERS | CC_MAIL | CC_ARMOURED | CC_EXPRESS | CC_BULK | CC_PIECE_GOODS | CC_LIQUID; - _gted[engine].cargo_disallowed = 0; + _gted[engine].cargo_allowed = {CargoClass::Passengers, CargoClass::Mail, CargoClass::Armoured, CargoClass::Express, CargoClass::Bulk, CargoClass::PieceGoods, CargoClass::Liquid}; + _gted[engine].cargo_disallowed = {}; } else { /* Train wagons and road vehicles are classified by their default cargo type */ CargoLabel label = GetActiveCargoLabel(ei->cargo_label); @@ -9123,7 +9123,7 @@ static void CalculateRefitMasks() _gted[engine].ctt_exclude_mask = original_known_cargoes; } } - _gted[engine].UpdateRefittability(_gted[engine].cargo_allowed != 0); + _gted[engine].UpdateRefittability(_gted[engine].cargo_allowed != CargoClasses{}); if (IsValidCargoType(ei->cargo_type)) ClrBit(_gted[engine].ctt_exclude_mask, ei->cargo_type); } @@ -9138,11 +9138,11 @@ static void CalculateRefitMasks() * Note: After applying the translations, the vehicle may end up carrying no defined cargo. It becomes unavailable in that case. */ only_defaultcargo = _gted[engine].refittability != GRFTempEngineData::NONEMPTY; - if (_gted[engine].cargo_allowed != 0) { + if (_gted[engine].cargo_allowed != CargoClasses{}) { /* Build up the list of cargo types from the set cargo classes. */ for (const CargoSpec *cs : CargoSpec::Iterate()) { - if ((_gted[engine].cargo_allowed & cs->classes) != 0 && (_gted[engine].cargo_allowed_required & cs->classes) == _gted[engine].cargo_allowed_required) SetBit(mask, cs->Index()); - if (_gted[engine].cargo_disallowed & cs->classes) SetBit(not_mask, cs->Index()); + if (cs->classes.Any(_gted[engine].cargo_allowed) && cs->classes.All(_gted[engine].cargo_allowed_required)) SetBit(mask, cs->Index()); + if (cs->classes.Any(_gted[engine].cargo_disallowed)) SetBit(not_mask, cs->Index()); } } @@ -9158,7 +9158,7 @@ static void CalculateRefitMasks() if (file != nullptr && e->info.callback_mask.Test(VehicleCallbackMask::CustomRefit)) { for (const CargoSpec *cs : CargoSpec::Iterate()) { uint8_t local_slot = file->cargo_map[cs->Index()]; - uint16_t callback = GetVehicleCallback(CBID_VEHICLE_CUSTOM_REFIT, cs->classes, local_slot, engine, nullptr); + uint16_t callback = GetVehicleCallback(CBID_VEHICLE_CUSTOM_REFIT, cs->classes.base(), local_slot, engine, nullptr); switch (callback) { case CALLBACK_FAILED: case 0: diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index ac0e00cc4d..e051ba8f7b 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -446,7 +446,7 @@ static uint32_t VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *objec /* Skip empty engines */ if (!u->GetEngine()->CanCarryCargo()) continue; - cargo_classes |= CargoSpec::Get(u->cargo_type)->classes; + cargo_classes |= CargoSpec::Get(u->cargo_type)->classes.base(); common_cargoes[u->cargo_type]++; } @@ -554,7 +554,7 @@ static uint32_t VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *objec * is object->ro.grffile. * In case of CBID_TRAIN_ALLOW_WAGON_ATTACH this is not the same as v->GetGRF(). */ - return (cs->classes << 16) | (cs->weight << 8) | object->ro.grffile->cargo_map[v->cargo_type]; + return (cs->classes.base() << 16) | (cs->weight << 8) | object->ro.grffile->cargo_map[v->cargo_type]; } case 0x48: return v->GetEngine()->flags.base(); // Vehicle Type Info @@ -952,7 +952,7 @@ static uint32_t VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *objec CargoType cargo_type = e->GetDefaultCargoType(); if (IsValidCargoType(cargo_type)) { const CargoSpec *cs = CargoSpec::Get(cargo_type); - return (cs->classes << 16) | (cs->weight << 8) | this->ro.grffile->cargo_map[cargo_type]; + return (cs->classes.base() << 16) | (cs->weight << 8) | this->ro.grffile->cargo_map[cargo_type]; } else { return 0x000000FF; } diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 68b2a37db6..c88c735ab7 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -82,7 +82,7 @@ static const Trackdir _road_reverse_table[DIAGDIR_END] = { bool RoadVehicle::IsBus() const { assert(this->IsFrontEngine()); - return IsCargoInClass(this->cargo_type, CC_PASSENGERS); + return IsCargoInClass(this->cargo_type, CargoClass::Passengers); } /** diff --git a/src/script/api/script_cargo.cpp b/src/script/api/script_cargo.cpp index faf14f1033..3c11089410 100644 --- a/src/script/api/script_cargo.cpp +++ b/src/script/api/script_cargo.cpp @@ -60,7 +60,7 @@ /* static */ bool ScriptCargo::HasCargoClass(CargoType cargo_type, CargoClass cargo_class) { if (!IsValidCargo(cargo_type)) return false; - return ::IsCargoInClass(cargo_type, (::CargoClass)cargo_class); + return ::IsCargoInClass(cargo_type, ::CargoClasses(to_underlying(cargo_class))); } /* static */ ScriptCargo::TownEffect ScriptCargo::GetTownEffect(CargoType cargo_type) diff --git a/src/script/api/script_cargo.hpp b/src/script/api/script_cargo.hpp index b1c3ed0e83..51a4c5fbbb 100644 --- a/src/script/api/script_cargo.hpp +++ b/src/script/api/script_cargo.hpp @@ -25,16 +25,16 @@ public: */ enum CargoClass { /* Note: these values represent part of the in-game CargoClass enum */ - CC_PASSENGERS = ::CC_PASSENGERS, ///< Passengers. Cargoes of this class appear at bus stops. Cargoes not of this class appear at truck stops. - CC_MAIL = ::CC_MAIL, ///< Mail - CC_EXPRESS = ::CC_EXPRESS, ///< Express cargo (Goods, Food, Candy, but also possible for passengers) - CC_ARMOURED = ::CC_ARMOURED, ///< Armoured cargo (Valuables, Gold, Diamonds) - CC_BULK = ::CC_BULK, ///< Bulk cargo (Coal, Grain etc., Ores, Fruit) - CC_PIECE_GOODS = ::CC_PIECE_GOODS, ///< Piece goods (Livestock, Wood, Steel, Paper) - CC_LIQUID = ::CC_LIQUID, ///< Liquids (Oil, Water, Rubber) - CC_REFRIGERATED = ::CC_REFRIGERATED, ///< Refrigerated cargo (Food, Fruit) - CC_HAZARDOUS = ::CC_HAZARDOUS, ///< Hazardous cargo (Nuclear Fuel, Explosives, etc.) - CC_COVERED = ::CC_COVERED, ///< Covered/Sheltered Freight (Transportation in Box Vans, Silo Wagons, etc.) + CC_PASSENGERS = ::CargoClasses{::CargoClass::Passengers}.base(), ///< Passengers. Cargoes of this class appear at bus stops. Cargoes not of this class appear at truck stops. + CC_MAIL = ::CargoClasses{::CargoClass::Mail}.base(), ///< Mail + CC_EXPRESS = ::CargoClasses{::CargoClass::Express}.base(), ///< Express cargo (Goods, Food, Candy, but also possible for passengers) + CC_ARMOURED = ::CargoClasses{::CargoClass::Armoured}.base(), ///< Armoured cargo (Valuables, Gold, Diamonds) + CC_BULK = ::CargoClasses{::CargoClass::Bulk}.base(), ///< Bulk cargo (Coal, Grain etc., Ores, Fruit) + CC_PIECE_GOODS = ::CargoClasses{::CargoClass::PieceGoods}.base(), ///< Piece goods (Livestock, Wood, Steel, Paper) + CC_LIQUID = ::CargoClasses{::CargoClass::Liquid}.base(), ///< Liquids (Oil, Water, Rubber) + CC_REFRIGERATED = ::CargoClasses{::CargoClass::Refrigerated}.base(), ///< Refrigerated cargo (Food, Fruit) + CC_HAZARDOUS = ::CargoClasses{::CargoClass::Hazardous}.base(), ///< Hazardous cargo (Nuclear Fuel, Explosives, etc.) + CC_COVERED = ::CargoClasses{::CargoClass::Covered}.base(), ///< Covered/Sheltered Freight (Transportation in Box Vans, Silo Wagons, etc.) }; /** diff --git a/src/settings_type.h b/src/settings_type.h index 74280e906d..9b9a56a101 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -553,9 +553,9 @@ struct LinkGraphSettings { inline DistributionType GetDistributionType(CargoType cargo) const { - if (IsCargoInClass(cargo, CC_PASSENGERS)) return this->distribution_pax; - if (IsCargoInClass(cargo, CC_MAIL)) return this->distribution_mail; - if (IsCargoInClass(cargo, CC_ARMOURED)) return this->distribution_armoured; + if (IsCargoInClass(cargo, CargoClass::Passengers)) return this->distribution_pax; + if (IsCargoInClass(cargo, CargoClass::Mail)) return this->distribution_mail; + if (IsCargoInClass(cargo, CargoClass::Armoured)) return this->distribution_armoured; return this->distribution_default; } }; diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 521202fb8e..b7198f628a 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -182,7 +182,7 @@ static bool CMSAMine(TileIndex tile) /* The industry extracts something non-liquid, i.e. no oil or plastic, so it is a mine. * Also the production of passengers and mail is ignored. */ if (IsValidCargoType(p.cargo) && - (CargoSpec::Get(p.cargo)->classes & (CC_LIQUID | CC_PASSENGERS | CC_MAIL)) == 0) { + !CargoSpec::Get(p.cargo)->classes.Any({CargoClass::Liquid, CargoClass::Passengers, CargoClass::Mail})) { return true; } } @@ -636,7 +636,7 @@ void UpdateStationAcceptance(Station *st, bool show_msg) uint amt = acceptance[i]; /* Make sure the station can accept the goods type. */ - bool is_passengers = IsCargoInClass(i, CC_PASSENGERS); + bool is_passengers = IsCargoInClass(i, CargoClass::Passengers); if ((!is_passengers && !(st->facilities & ~FACIL_BUS_STOP)) || (is_passengers && !(st->facilities & ~FACIL_TRUCK_STOP))) { amt = 0; @@ -4381,7 +4381,7 @@ static bool CanMoveGoodsToStation(const Station *st, CargoType type) /* Selectively servicing stations, and not this one. */ if (_settings_game.order.selectgoods && !st->goods[type].HasVehicleEverTriedLoading()) return false; - if (IsCargoInClass(type, CC_PASSENGERS)) { + if (IsCargoInClass(type, CargoClass::Passengers)) { /* Passengers are never served by just a truck stop. */ if (st->facilities == FACIL_TRUCK_STOP) return false; } else { diff --git a/src/station_gui.cpp b/src/station_gui.cpp index e344f55bbd..423a26a96e 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -87,8 +87,8 @@ int DrawStationCoverageAreaText(const Rect &r, StationCoverageType sct, int rad, /* Convert cargo counts to a set of cargo bits, and draw the result. */ for (CargoType i = 0; i < NUM_CARGO; i++) { switch (sct) { - case SCT_PASSENGERS_ONLY: if (!IsCargoInClass(i, CC_PASSENGERS)) continue; break; - case SCT_NON_PASSENGERS_ONLY: if (IsCargoInClass(i, CC_PASSENGERS)) continue; break; + case SCT_PASSENGERS_ONLY: if (!IsCargoInClass(i, CargoClass::Passengers)) continue; break; + case SCT_NON_PASSENGERS_ONLY: if (IsCargoInClass(i, CargoClass::Passengers)) continue; break; case SCT_ALL: break; default: NOT_REACHED(); } diff --git a/src/table/cargo_const.h b/src/table/cargo_const.h index c769182bda..07b4a396a3 100644 --- a/src/table/cargo_const.h +++ b/src/table/cargo_const.h @@ -50,48 +50,48 @@ /** Cargo types available by default. */ static const CargoSpec _default_cargo[] = { - MK( 0, CT_PASSENGERS, 152, 1, 0x400, 3185, 0, 24, false, TAE_PASSENGERS, PASSENGERS, PASSENGER, STR_PASSENGERS, CC_PASSENGERS), - MK( 1, CT_COAL, 6, 16, 0x100, 5916, 7, 255, true, TAE_NONE, COAL, COAL, STR_TONS, CC_BULK | CC_NON_POTABLE), - MK( 2, CT_MAIL, 15, 4, 0x200, 4550, 20, 90, false, TAE_MAIL, MAIL, MAIL, STR_BAGS, CC_MAIL), + MK( 0, CT_PASSENGERS, 152, 1, 0x400, 3185, 0, 24, false, TAE_PASSENGERS, PASSENGERS, PASSENGER, STR_PASSENGERS, CargoClasses({CargoClass::Passengers})), + MK( 1, CT_COAL, 6, 16, 0x100, 5916, 7, 255, true, TAE_NONE, COAL, COAL, STR_TONS, CargoClasses({CargoClass::Bulk, CargoClass::NonPotable})), + MK( 2, CT_MAIL, 15, 4, 0x200, 4550, 20, 90, false, TAE_MAIL, MAIL, MAIL, STR_BAGS, CargoClasses({CargoClass::Mail})), /* Oil in temperate and arctic */ - MK( 3, CT_OIL, 174, 16, 0x100, 4437, 25, 255, true, TAE_NONE, OIL, OIL, STR_LITERS, CC_LIQUID | CC_NON_POTABLE), + MK( 3, CT_OIL, 174, 16, 0x100, 4437, 25, 255, true, TAE_NONE, OIL, OIL, STR_LITERS, CargoClasses({CargoClass::Liquid, CargoClass::NonPotable})), /* Oil in subtropic */ - MK( 3, CT_OIL, 174, 16, 0x100, 4892, 25, 255, true, TAE_NONE, OIL, OIL, STR_LITERS, CC_LIQUID | CC_NON_POTABLE), - MK( 4, CT_LIVESTOCK, 208, 3, 0x100, 4322, 4, 18, true, TAE_NONE, LIVESTOCK, LIVESTOCK, STR_ITEMS, CC_PIECE_GOODS | CC_NON_POTABLE), - MK( 5, CT_GOODS, 194, 8, 0x200, 6144, 5, 28, true, TAE_GOODS, GOODS, GOODS, STR_CRATES, CC_EXPRESS), - MK( 6, CT_GRAIN, 191, 16, 0x100, 4778, 4, 40, true, TAE_NONE, GRAIN, GRAIN, STR_TONS, CC_BULK | CC_POTABLE), - MK( 6, CT_WHEAT, 191, 16, 0x100, 4778, 4, 40, true, TAE_NONE, WHEAT, WHEAT, STR_TONS, CC_BULK | CC_POTABLE), - MK( 6, CT_MAIZE, 191, 16, 0x100, 4322, 4, 40, true, TAE_NONE, MAIZE, MAIZE, STR_TONS, CC_BULK | CC_POTABLE), + MK( 3, CT_OIL, 174, 16, 0x100, 4892, 25, 255, true, TAE_NONE, OIL, OIL, STR_LITERS, CargoClasses({CargoClass::Liquid, CargoClass::NonPotable})), + MK( 4, CT_LIVESTOCK, 208, 3, 0x100, 4322, 4, 18, true, TAE_NONE, LIVESTOCK, LIVESTOCK, STR_ITEMS, CargoClasses({CargoClass::PieceGoods, CargoClass::NonPotable})), + MK( 5, CT_GOODS, 194, 8, 0x200, 6144, 5, 28, true, TAE_GOODS, GOODS, GOODS, STR_CRATES, CargoClasses({CargoClass::Express})), + MK( 6, CT_GRAIN, 191, 16, 0x100, 4778, 4, 40, true, TAE_NONE, GRAIN, GRAIN, STR_TONS, CargoClasses({CargoClass::Bulk, CargoClass::Potable})), + MK( 6, CT_WHEAT, 191, 16, 0x100, 4778, 4, 40, true, TAE_NONE, WHEAT, WHEAT, STR_TONS, CargoClasses({CargoClass::Bulk, CargoClass::Potable})), + MK( 6, CT_MAIZE, 191, 16, 0x100, 4322, 4, 40, true, TAE_NONE, MAIZE, MAIZE, STR_TONS, CargoClasses({CargoClass::Bulk, CargoClass::Potable})), /* Wood in temperate and arctic */ - MK( 7, CT_WOOD, 84, 16, 0x100, 5005, 15, 255, true, TAE_NONE, WOOD, WOOD, STR_TONS, CC_PIECE_GOODS), + MK( 7, CT_WOOD, 84, 16, 0x100, 5005, 15, 255, true, TAE_NONE, WOOD, WOOD, STR_TONS, CargoClasses({CargoClass::PieceGoods})), /* Wood in subtropic */ - MK( 7, CT_WOOD, 84, 16, 0x100, 7964, 15, 255, true, TAE_NONE, WOOD, WOOD, STR_TONS, CC_PIECE_GOODS), - MK( 8, CT_IRON_ORE, 184, 16, 0x100, 5120, 9, 255, true, TAE_NONE, IRON_ORE, IRON_ORE, STR_TONS, CC_BULK | CC_NON_POTABLE), - MK( 9, CT_STEEL, 10, 16, 0x100, 5688, 7, 255, true, TAE_NONE, STEEL, STEEL, STR_TONS, CC_PIECE_GOODS), - MK( 10, CT_VALUABLES, 202, 2, 0x100, 7509, 1, 32, true, TAE_NONE, VALUABLES, VALUABLES, STR_BAGS, CC_ARMOURED), - MK( 10, CT_GOLD, 202, 8, 0x100, 5802, 10, 40, true, TAE_NONE, GOLD, GOLD, STR_BAGS, CC_ARMOURED), - MK( 10, CT_DIAMONDS, 202, 2, 0x100, 5802, 10, 255, true, TAE_NONE, DIAMONDS, DIAMOND, STR_BAGS, CC_ARMOURED), - MK( 11, CT_PAPER, 10, 16, 0x100, 5461, 7, 60, true, TAE_NONE, PAPER, PAPER, STR_TONS, CC_PIECE_GOODS), - MK( 12, CT_FOOD, 48, 16, 0x100, 5688, 0, 30, true, TAE_FOOD, FOOD, FOOD, STR_TONS, CC_EXPRESS | CC_REFRIGERATED | CC_POTABLE), - MK( 13, CT_FRUIT, 208, 16, 0x100, 4209, 0, 15, true, TAE_NONE, FRUIT, FRUIT, STR_TONS, CC_BULK | CC_REFRIGERATED | CC_POTABLE), - MK( 14, CT_COPPER_ORE, 184, 16, 0x100, 4892, 12, 255, true, TAE_NONE, COPPER_ORE, COPPER_ORE, STR_TONS, CC_BULK | CC_NON_POTABLE), - MK( 15, CT_WATER, 10, 16, 0x100, 4664, 20, 80, true, TAE_WATER, WATER, WATER, STR_LITERS, CC_LIQUID | CC_POTABLE), - MK( 16, CT_RUBBER, 6, 16, 0x100, 4437, 2, 20, true, TAE_NONE, RUBBER, RUBBER, STR_LITERS, CC_LIQUID | CC_NON_POTABLE), - MK( 17, CT_SUGAR, 6, 16, 0x100, 4437, 20, 255, true, TAE_NONE, SUGAR, SUGAR, STR_TONS, CC_BULK | CC_POTABLE), - MK( 18, CT_TOYS, 174, 2, 0x100, 5574, 25, 255, true, TAE_NONE, TOYS, TOY, STR_ITEMS, CC_PIECE_GOODS), - MK( 19, CT_BATTERIES, 208, 4, 0x100, 4322, 2, 30, true, TAE_NONE, BATTERIES, BATTERY, STR_ITEMS, CC_PIECE_GOODS), - MK( 20, CT_CANDY, 194, 5, 0x200, 6144, 8, 40, true, TAE_GOODS, SWEETS, SWEETS, STR_BAGS, CC_EXPRESS), - MK( 21, CT_TOFFEE, 191, 16, 0x100, 4778, 14, 60, true, TAE_NONE, TOFFEE, TOFFEE, STR_TONS, CC_BULK), - MK( 22, CT_COLA, 84, 16, 0x100, 4892, 5, 75, true, TAE_NONE, COLA, COLA, STR_LITERS, CC_LIQUID), - MK( 23, CT_COTTON_CANDY, 184, 16, 0x100, 5005, 10, 25, true, TAE_NONE, CANDYFLOSS, CANDYFLOSS, STR_TONS, CC_BULK), - MK( 24, CT_BUBBLES, 10, 1, 0x100, 5077, 20, 80, true, TAE_NONE, BUBBLES, BUBBLE, STR_ITEMS, CC_PIECE_GOODS), - MK( 25, CT_PLASTIC, 202, 16, 0x100, 4664, 30, 255, true, TAE_NONE, PLASTIC, PLASTIC, STR_LITERS, CC_LIQUID), - MK( 26, CT_FIZZY_DRINKS, 48, 2, 0x100, 6250, 30, 50, true, TAE_FOOD, FIZZY_DRINKS, FIZZY_DRINK, STR_ITEMS, CC_PIECE_GOODS), + MK( 7, CT_WOOD, 84, 16, 0x100, 7964, 15, 255, true, TAE_NONE, WOOD, WOOD, STR_TONS, CargoClasses({CargoClass::PieceGoods})), + MK( 8, CT_IRON_ORE, 184, 16, 0x100, 5120, 9, 255, true, TAE_NONE, IRON_ORE, IRON_ORE, STR_TONS, CargoClasses({CargoClass::Bulk, CargoClass::NonPotable})), + MK( 9, CT_STEEL, 10, 16, 0x100, 5688, 7, 255, true, TAE_NONE, STEEL, STEEL, STR_TONS, CargoClasses({CargoClass::PieceGoods})), + MK( 10, CT_VALUABLES, 202, 2, 0x100, 7509, 1, 32, true, TAE_NONE, VALUABLES, VALUABLES, STR_BAGS, CargoClasses({CargoClass::Armoured})), + MK( 10, CT_GOLD, 202, 8, 0x100, 5802, 10, 40, true, TAE_NONE, GOLD, GOLD, STR_BAGS, CargoClasses({CargoClass::Armoured})), + MK( 10, CT_DIAMONDS, 202, 2, 0x100, 5802, 10, 255, true, TAE_NONE, DIAMONDS, DIAMOND, STR_BAGS, CargoClasses({CargoClass::Armoured})), + MK( 11, CT_PAPER, 10, 16, 0x100, 5461, 7, 60, true, TAE_NONE, PAPER, PAPER, STR_TONS, CargoClasses({CargoClass::PieceGoods})), + MK( 12, CT_FOOD, 48, 16, 0x100, 5688, 0, 30, true, TAE_FOOD, FOOD, FOOD, STR_TONS, CargoClasses({CargoClass::Express, CargoClass::Refrigerated, CargoClass::Potable})), + MK( 13, CT_FRUIT, 208, 16, 0x100, 4209, 0, 15, true, TAE_NONE, FRUIT, FRUIT, STR_TONS, CargoClasses({CargoClass::Bulk, CargoClass::Refrigerated, CargoClass::Potable})), + MK( 14, CT_COPPER_ORE, 184, 16, 0x100, 4892, 12, 255, true, TAE_NONE, COPPER_ORE, COPPER_ORE, STR_TONS, CargoClasses({CargoClass::Bulk, CargoClass::NonPotable})), + MK( 15, CT_WATER, 10, 16, 0x100, 4664, 20, 80, true, TAE_WATER, WATER, WATER, STR_LITERS, CargoClasses({CargoClass::Liquid, CargoClass::Potable})), + MK( 16, CT_RUBBER, 6, 16, 0x100, 4437, 2, 20, true, TAE_NONE, RUBBER, RUBBER, STR_LITERS, CargoClasses({CargoClass::Liquid, CargoClass::NonPotable})), + MK( 17, CT_SUGAR, 6, 16, 0x100, 4437, 20, 255, true, TAE_NONE, SUGAR, SUGAR, STR_TONS, CargoClasses({CargoClass::Bulk, CargoClass::Potable})), + MK( 18, CT_TOYS, 174, 2, 0x100, 5574, 25, 255, true, TAE_NONE, TOYS, TOY, STR_ITEMS, CargoClasses({CargoClass::PieceGoods})), + MK( 19, CT_BATTERIES, 208, 4, 0x100, 4322, 2, 30, true, TAE_NONE, BATTERIES, BATTERY, STR_ITEMS, CargoClasses({CargoClass::PieceGoods})), + MK( 20, CT_CANDY, 194, 5, 0x200, 6144, 8, 40, true, TAE_GOODS, SWEETS, SWEETS, STR_BAGS, CargoClasses({CargoClass::Express})), + MK( 21, CT_TOFFEE, 191, 16, 0x100, 4778, 14, 60, true, TAE_NONE, TOFFEE, TOFFEE, STR_TONS, CargoClasses({CargoClass::Bulk})), + MK( 22, CT_COLA, 84, 16, 0x100, 4892, 5, 75, true, TAE_NONE, COLA, COLA, STR_LITERS, CargoClasses({CargoClass::Liquid})), + MK( 23, CT_COTTON_CANDY, 184, 16, 0x100, 5005, 10, 25, true, TAE_NONE, CANDYFLOSS, CANDYFLOSS, STR_TONS, CargoClasses({CargoClass::Bulk})), + MK( 24, CT_BUBBLES, 10, 1, 0x100, 5077, 20, 80, true, TAE_NONE, BUBBLES, BUBBLE, STR_ITEMS, CargoClasses({CargoClass::PieceGoods})), + MK( 25, CT_PLASTIC, 202, 16, 0x100, 4664, 30, 255, true, TAE_NONE, PLASTIC, PLASTIC, STR_LITERS, CargoClasses({CargoClass::Liquid})), + MK( 26, CT_FIZZY_DRINKS, 48, 2, 0x100, 6250, 30, 50, true, TAE_FOOD, FIZZY_DRINKS, FIZZY_DRINK, STR_ITEMS, CargoClasses({CargoClass::PieceGoods})), /* Void slot in temperate */ - MK(0xFF, CT_INVALID, 1, 0, 0x100, 5688, 0, 30, true, TAE_NONE, NOTHING, NOTHING, STR_TONS, CC_NOAVAILABLE), + MK(0xFF, CT_INVALID, 1, 0, 0x100, 5688, 0, 30, true, TAE_NONE, NOTHING, NOTHING, STR_TONS, CargoClasses({})), /* Void slot in arctic */ - MK(0xFF, CT_INVALID, 184, 0, 0x100, 5120, 9, 255, true, TAE_NONE, NOTHING, NOTHING, STR_TONS, CC_NOAVAILABLE), + MK(0xFF, CT_INVALID, 184, 0, 0x100, 5120, 9, 255, true, TAE_NONE, NOTHING, NOTHING, STR_TONS, CargoClasses({})), }; diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 7c2797dd45..867cfa36f1 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -288,7 +288,7 @@ uint Vehicle::Crash(bool) /* crash all wagons, and count passengers */ for (Vehicle *v = this; v != nullptr; v = v->Next()) { /* We do not transfer reserver cargo back, so TotalCount() instead of StoredCount() */ - if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) pass += v->cargo.TotalCount(); + if (IsCargoInClass(v->cargo_type, CargoClass::Passengers)) pass += v->cargo.TotalCount(); v->vehstatus |= VS_CRASHED; v->MarkAllViewportsDirty(); } @@ -2030,17 +2030,17 @@ LiveryScheme GetEngineLiveryScheme(EngineID engine_type, EngineID parent_engine_ /* Important: Use Tram Flag of front part. Luckily engine_type refers to the front part here. */ if (e->info.misc_flags.Test(EngineMiscFlag::RoadIsTram)) { /* Tram */ - return IsCargoInClass(cargo_type, CC_PASSENGERS) ? LS_PASSENGER_TRAM : LS_FREIGHT_TRAM; + return IsCargoInClass(cargo_type, CargoClass::Passengers) ? LS_PASSENGER_TRAM : LS_FREIGHT_TRAM; } else { /* Bus or truck */ - return IsCargoInClass(cargo_type, CC_PASSENGERS) ? LS_BUS : LS_TRUCK; + return IsCargoInClass(cargo_type, CargoClass::Passengers) ? LS_BUS : LS_TRUCK; } case VEH_SHIP: if (!IsValidCargoType(cargo_type)) cargo_type = e->GetDefaultCargoType(); if (!IsValidCargoType(cargo_type)) cargo_type = GetCargoTypeByLabel(CT_GOODS); // The vehicle does not carry anything, let's pick some freight cargo assert(IsValidCargoType(cargo_type)); - return IsCargoInClass(cargo_type, CC_PASSENGERS) ? LS_PASSENGER_SHIP : LS_FREIGHT_SHIP; + return IsCargoInClass(cargo_type, CargoClass::Passengers) ? LS_PASSENGER_SHIP : LS_FREIGHT_SHIP; case VEH_AIRCRAFT: switch (e->u.air.subtype) { diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index ee4b731cbd..abad59bf5e 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -289,7 +289,7 @@ static int GetRefitCostFactor(const Vehicle *v, EngineID engine_type, CargoType /* Is this vehicle a NewGRF vehicle? */ if (e->GetGRF() != nullptr) { const CargoSpec *cs = CargoSpec::Get(new_cargo_type); - uint32_t param1 = (cs->classes << 16) | (new_subtype << 8) | e->GetGRF()->cargo_map[new_cargo_type]; + uint32_t param1 = (cs->classes.base() << 16) | (new_subtype << 8) | e->GetGRF()->cargo_map[new_cargo_type]; uint16_t cb_res = GetVehicleCallback(CBID_VEHICLE_REFIT_COST, param1, 0, engine_type, v); if (cb_res != CALLBACK_FAILED) { diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index b9509eb170..b5523a1716 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -292,7 +292,7 @@ static bool CargoFilterSingle(const Vehicle *v, const CargoType cargo_type) bool have_capacity = false; for (const Vehicle *w = v; w != nullptr; w = w->Next()) { if (w->cargo_cap > 0) { - if (IsCargoInClass(w->cargo_type, CC_PASSENGERS)) { + if (IsCargoInClass(w->cargo_type, CargoClass::Passengers)) { return false; } else { have_capacity = true;