mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-13 02:52:37 +00:00
Codechange: Simplify initialization of default cargoes.
This commit is contained in:
parent
c6864637fb
commit
e8cbc3c2c7
@ -42,13 +42,7 @@ void SetupCargoForClimate(LandscapeID l)
|
|||||||
assert(l < lengthof(_default_climate_cargo));
|
assert(l < lengthof(_default_climate_cargo));
|
||||||
|
|
||||||
/* Reset and disable all cargo types */
|
/* Reset and disable all cargo types */
|
||||||
for (CargoID i = 0; i < lengthof(CargoSpec::array); i++) {
|
std::fill(std::begin(CargoSpec::array), std::end(CargoSpec::array), CargoSpec{});
|
||||||
*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;
|
|
||||||
}
|
|
||||||
|
|
||||||
_cargo_mask = 0;
|
_cargo_mask = 0;
|
||||||
|
|
||||||
|
@ -54,12 +54,12 @@ static const byte INVALID_CARGO_BITNUM = 0xFF; ///< Constant representing invali
|
|||||||
|
|
||||||
/** Specification of a cargo type. */
|
/** Specification of a cargo type. */
|
||||||
struct CargoSpec {
|
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.
|
CargoLabel label; ///< Unique label of the cargo type.
|
||||||
uint8_t legend_colour;
|
uint8_t legend_colour;
|
||||||
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; ///< 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.
|
int32_t initial_payment; ///< Initial payment rate before inflation is applied.
|
||||||
uint8_t transit_periods[2];
|
uint8_t transit_periods[2];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user