diff --git a/src/cargotype.cpp b/src/cargotype.cpp --- a/src/cargotype.cpp +++ b/src/cargotype.cpp @@ -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; diff --git a/src/cargotype.h b/src/cargotype.h --- a/src/cargotype.h +++ b/src/cargotype.h @@ -54,12 +54,12 @@ static const byte INVALID_CARGO_BITNUM = /** 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];