1
0
Fork 0

Codefix: cargo_(dis)allowed for default refit masks are cargo classes, not CargoTypes. (#12884)

Use an alias for CargoClasses to avoid ambiguity.
pull/9577/merge
Peter Nelson 2024-07-29 20:58:53 +01:00 committed by GitHub
parent bec37ee704
commit 3176de3f1d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 6 deletions

View File

@ -45,7 +45,7 @@ enum TownProductionEffect : uint8_t {
}; };
/** Cargo classes. */ /** Cargo classes. */
enum CargoClass { enum CargoClass : uint16_t {
CC_NOAVAILABLE = 0, ///< No cargo class has been specified CC_NOAVAILABLE = 0, ///< No cargo class has been specified
CC_PASSENGERS = 1 << 0, ///< Passengers CC_PASSENGERS = 1 << 0, ///< Passengers
CC_MAIL = 1 << 1, ///< Mail CC_MAIL = 1 << 1, ///< Mail
@ -60,6 +60,9 @@ enum CargoClass {
CC_SPECIAL = 1 << 15, ///< Special bit used for livery refit tricks instead of normal cargoes. CC_SPECIAL = 1 << 15, ///< Special bit used for livery refit tricks instead of normal cargoes.
}; };
/** Bitmask of cargo classes. */
using CargoClasses = uint16_t;
static const uint8_t INVALID_CARGO_BITNUM = 0xFF; ///< Constant representing invalid cargo static const uint8_t INVALID_CARGO_BITNUM = 0xFF; ///< Constant representing invalid cargo
static const uint TOWN_PRODUCTION_DIVISOR = 256; static const uint TOWN_PRODUCTION_DIVISOR = 256;
@ -72,7 +75,7 @@ struct CargoSpec {
uint8_t rating_colour; uint8_t rating_colour;
uint8_t weight; ///< Weight of a single unit of this cargo type in 1/16 ton (62.5 kg). uint8_t weight; ///< Weight of a single unit of this cargo type in 1/16 ton (62.5 kg).
uint16_t multiplier = 0x100; ///< Capacity multiplier for vehicles. (8 fractional bits) uint16_t multiplier = 0x100; ///< Capacity multiplier for vehicles. (8 fractional bits)
uint16_t classes; ///< Classes of this cargo type. @see CargoClass CargoClasses classes; ///< Classes of this cargo type. @see CargoClass
int32_t initial_payment; ///< Initial payment rate before inflation is applied. int32_t initial_payment; ///< Initial payment rate before inflation is applied.
uint8_t transit_periods[2]; uint8_t transit_periods[2];

View File

@ -318,8 +318,8 @@ struct GRFTempEngineData {
NONEMPTY, ///< GRF defined the vehicle as refittable. If the refitmask is empty after translation (cargotypes not available), disable the vehicle. NONEMPTY, ///< GRF defined the vehicle as refittable. If the refitmask is empty after translation (cargotypes not available), disable the vehicle.
}; };
uint16_t cargo_allowed; CargoClasses cargo_allowed;
uint16_t cargo_disallowed; CargoClasses cargo_disallowed;
RailTypeLabel railtypelabel; RailTypeLabel railtypelabel;
uint8_t roadtramtype; uint8_t roadtramtype;
const GRFFile *defaultcargo_grf; ///< GRF defining the cargo translation table to use if the default cargo is the 'first refittable'. const GRFFile *defaultcargo_grf; ///< GRF defining the cargo translation table to use if the default cargo is the 'first refittable'.
@ -9001,8 +9001,8 @@ static void CalculateRefitMasks()
static const struct DefaultRefitMasks { static const struct DefaultRefitMasks {
uint8_t climate; uint8_t climate;
CargoLabel cargo_label; CargoLabel cargo_label;
CargoTypes cargo_allowed; CargoClasses cargo_allowed;
CargoTypes cargo_disallowed; CargoClasses cargo_disallowed;
} _default_refit_masks[] = { } _default_refit_masks[] = {
{T | A | S | Y, CT_PASSENGERS, CC_PASSENGERS, 0}, {T | A | S | Y, CT_PASSENGERS, CC_PASSENGERS, 0},
{T | A | S , CT_MAIL, CC_MAIL, 0}, {T | A | S , CT_MAIL, CC_MAIL, 0},