Changeset - r27932:71246c40b69d
[Not reviewed]
master
0 2 0
Peter Nelson - 14 months ago 2023-04-27 12:26:10
peter1138@openttd.org
Codechange: Simplify initialization of default cargoes.
2 files changed with 3 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/cargotype.cpp
Show inline comments
 
@@ -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;
 

	
src/cargotype.h
Show inline comments
 
@@ -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];
 

	
0 comments (0 inline, 0 general)