Changeset - r27933:a474cb497c34
[Not reviewed]
master
0 2 0
Peter Nelson - 13 months ago 2023-09-17 16:42:34
peter1138@openttd.org
Codechange: Reorder CargoSpec to reduce alignment padding.
2 files changed with 4 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/cargotype.h
Show inline comments
 
@@ -51,18 +51,19 @@ enum CargoClass {
 
};
 

	
 
static const byte INVALID_CARGO_BITNUM = 0xFF; ///< Constant representing invalid cargo
 

	
 
/** Specification of a cargo type. */
 
struct CargoSpec {
 
	CargoLabel label;                ///< Unique label of the cargo type.
 
	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{0x100}; ///< Capacity multiplier for vehicles. (8 fractional bits)
 
	uint16_t classes;                  ///< Classes of this cargo type. @see CargoClass
 
	int32_t initial_payment;           ///< Initial payment rate before inflation is applied.
 
	uint8_t transit_periods[2];
 

	
 
	bool is_freight;                 ///< Cargo type is considered to be freight (affects train freight multiplier).
 
	TownEffect town_effect;          ///< The effect that delivering this cargo type has on towns. Also affects destination of subsidies.
 
	uint8_t callback_mask;             ///< Bitmask of cargo callbacks that have to be called
 
@@ -72,13 +73,12 @@ struct CargoSpec {
 
	StringID units_volume;           ///< Name of a single unit of cargo of this type.
 
	StringID quantifier;             ///< Text for multiple units of cargo of this type.
 
	StringID abbrev;                 ///< Two letter abbreviation for this cargo type.
 

	
 
	SpriteID sprite;                 ///< Icon to display this cargo type, may be \c 0xFFF (which means to resolve an action123 chain).
 

	
 
	uint16_t classes;                  ///< Classes of this cargo type. @see CargoClass
 
	const struct GRFFile *grffile;   ///< NewGRF where #group belongs to.
 
	const struct SpriteGroup *group;
 

	
 
	Money current_payment;
 

	
 
	/**
src/table/cargo_const.h
Show inline comments
 
@@ -41,15 +41,15 @@
 
 *                     CargoSpec->abbrev and CargoSpec->sprite. See above for more detailed information.
 
 * @param str_singular The name suffix used to populate CargoSpec->name_single. See above for more information.
 
 * @param str_volume   Name of a single unit of cargo of this type.
 
 * @param classes      Classes of this cargo type. @see CargoClass
 
 */
 
#define MK(bt, label, colour, weight, mult, ip, td1, td2, freight, te, str_plural, str_singular, str_volume, classes) \
 
		{bt, label, colour, colour, weight, mult, ip, {td1, td2}, freight, te, 0, \
 
		{label, bt, colour, colour, weight, mult, classes, ip, {td1, td2}, freight, te, 0, \
 
		MK_STR_CARGO_PLURAL(str_plural), MK_STR_CARGO_SINGULAR(str_singular), str_volume, MK_STR_QUANTITY(str_plural), MK_STR_ABBREV(str_plural), \
 
		MK_SPRITE(str_plural), classes, nullptr, nullptr, 0}
 
		MK_SPRITE(str_plural), nullptr, nullptr, 0}
 

	
 
/** Cargo types available by default. */
 
static const CargoSpec _default_cargo[] = {
 
	MK(   0, 'PASS', 152,  1, 0x400, 3185,  0,  24, false, TE_PASSENGERS,   PASSENGERS,    PASSENGER, STR_PASSENGERS, CC_PASSENGERS),
 
	MK(   1, 'COAL',   6, 16, 0x100, 5916,  7, 255,  true,       TE_NONE,         COAL,         COAL,       STR_TONS, CC_BULK),
 
	MK(   2, 'MAIL',  15,  4, 0x200, 4550, 20,  90, false,       TE_MAIL,         MAIL,         MAIL,       STR_BAGS, CC_MAIL),
0 comments (0 inline, 0 general)