Changeset - r27927:f93a192f7cf1
[Not reviewed]
master
0 3 0
Peter Nelson - 13 months ago 2023-05-23 07:35:47
peter1138@openttd.org
Codechange: Rename INVALID_CARGO to INVALID_CARGO_BITNUM

... to avoid future ambiguity.
3 files changed with 7 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/cargotype.cpp
Show inline comments
 
@@ -44,7 +44,7 @@ void SetupCargoForClimate(LandscapeID l)
 
	/* Reset and disable all cargo types */
 
	for (CargoID i = 0; i < lengthof(CargoSpec::array); i++) {
 
		*CargoSpec::Get(i) = {};
 
		CargoSpec::Get(i)->bitnum = INVALID_CARGO;
 
		CargoSpec::Get(i)->bitnum = INVALID_CARGO_BITNUM;
 

	
 
		/* Set defaults for newer properties, which old GRFs do not know */
 
		CargoSpec::Get(i)->multiplier = 0x100;
 
@@ -60,7 +60,7 @@ void SetupCargoForClimate(LandscapeID l)
 
			/* Copy the indexed cargo */
 
			CargoSpec *cargo = CargoSpec::Get(i);
 
			*cargo = _default_cargo[cl];
 
			if (cargo->bitnum != INVALID_CARGO) SetBit(_cargo_mask, i);
 
			if (cargo->bitnum != INVALID_CARGO_BITNUM) SetBit(_cargo_mask, i);
 
			continue;
 
		}
 

	
 
@@ -123,7 +123,7 @@ CargoID GetCargoIDByLabel(CargoLabel cl)
 
 */
 
CargoID GetCargoIDByBitnum(uint8_t bitnum)
 
{
 
	if (bitnum == INVALID_CARGO) return CT_INVALID;
 
	if (bitnum == INVALID_CARGO_BITNUM) return CT_INVALID;
 

	
 
	for (const CargoSpec *cs : CargoSpec::Iterate()) {
 
		if (cs->bitnum == bitnum) return cs->Index();
src/cargotype.h
Show inline comments
 
@@ -50,11 +50,11 @@ enum CargoClass {
 
	CC_SPECIAL      = 1 << 15, ///< Special bit used for livery refit tricks instead of normal cargoes.
 
};
 

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

	
 
/** Specification of a cargo type. */
 
struct CargoSpec {
 
	uint8_t bitnum;                    ///< Cargo bit number, is #INVALID_CARGO for a non-used spec.
 
	uint8_t 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;
 
@@ -97,7 +97,7 @@ struct CargoSpec {
 
	 */
 
	inline bool IsValid() const
 
	{
 
		return this->bitnum != INVALID_CARGO;
 
		return this->bitnum != INVALID_CARGO_BITNUM;
 
	}
 

	
 
	/**
src/table/cargo_const.h
Show inline comments
 
@@ -27,7 +27,7 @@
 
 * And the following sprite:
 
 * - SPR_CARGO_<str_plural>
 
 *
 
 * @param bt           Cargo bit number, is #INVALID_CARGO for a non-used spec.
 
 * @param bt           Cargo bit number, is #INVALID_CARGO_BITNUM for a non-used spec.
 
 * @param label        Unique label of the cargo type.
 
 * @param colour       CargoSpec->legend_colour and CargoSpec->rating_colour.
 
 * @param weight       Weight of a single unit of this cargo type in 1/16 ton (62.5 kg).
0 comments (0 inline, 0 general)