Codechange: Simplify initialization of default cargoes.

This commit is contained in:
Peter Nelson 2023-04-27 13:26:10 +01:00 committed by PeterN
parent c6864637fb
commit e8cbc3c2c7
2 changed files with 3 additions and 9 deletions

View File

@ -42,13 +42,7 @@ void SetupCargoForClimate(LandscapeID l)
assert(l < lengthof(_default_climate_cargo));
/* Reset and disable all cargo types */
for (CargoID i = 0; i < lengthof(CargoSpec::array); i++) {
*CargoSpec::Get(i) = {};
CargoSpec::Get(i)->bitnum = INVALID_CARGO_BITNUM;
/* Set defaults for newer properties, which old GRFs do not know */
CargoSpec::Get(i)->multiplier = 0x100;
}
std::fill(std::begin(CargoSpec::array), std::end(CargoSpec::array), CargoSpec{});
_cargo_mask = 0;

View File

@ -54,12 +54,12 @@ static const byte INVALID_CARGO_BITNUM = 0xFF; ///< Constant representing invali
/** Specification of a cargo type. */
struct CargoSpec {
uint8_t bitnum; ///< Cargo bit number, is #INVALID_CARGO_BITNUM for a non-used spec.
uint8_t bitnum{INVALID_CARGO_BITNUM}; ///< Cargo bit number, is #INVALID_CARGO_BITNUM for a non-used spec.
CargoLabel label; ///< Unique label of the cargo type.
uint8_t legend_colour;
uint8_t rating_colour;
uint8_t weight; ///< Weight of a single unit of this cargo type in 1/16 ton (62.5 kg).
uint16_t multiplier; ///< Capacity multiplier for vehicles. (8 fractional bits)
uint16_t multiplier{0x100}; ///< Capacity multiplier for vehicles. (8 fractional bits)
int32_t initial_payment; ///< Initial payment rate before inflation is applied.
uint8_t transit_periods[2];