Changeset - r28422:76582babb47f
[Not reviewed]
src/articulated_vehicles.cpp
Show inline comments
 
@@ -107,7 +107,7 @@ uint CountArticulatedParts(EngineID engi
 
static inline uint16_t GetVehicleDefaultCapacity(EngineID engine, CargoID *cargo_type)
 
{
 
	const Engine *e = Engine::Get(engine);
 
	CargoID cargo = (e->CanCarryCargo() ? e->GetDefaultCargoType() : (CargoID)CT_INVALID);
 
	CargoID cargo = (e->CanCarryCargo() ? e->GetDefaultCargoType() : INVALID_CARGO);
 
	if (cargo_type != nullptr) *cargo_type = cargo;
 
	if (!IsValidCargoID(cargo)) return 0;
 
	return e->GetDisplayDefaultCapacity();
 
@@ -259,13 +259,13 @@ CargoTypes GetUnionOfArticulatedRefitMas
 
 * Get cargo mask of all cargoes carried by an articulated vehicle.
 
 * Note: Vehicles not carrying anything are ignored
 
 * @param v the first vehicle in the chain
 
 * @param cargo_type returns the common CargoID if needed. (CT_INVALID if no part is carrying something or they are carrying different things)
 
 * @param cargo_type returns the common CargoID if needed. (INVALID_CARGO if no part is carrying something or they are carrying different things)
 
 * @return cargo mask, may be 0 if the no vehicle parts have cargo capacity
 
 */
 
CargoTypes GetCargoTypesOfArticulatedVehicle(const Vehicle *v, CargoID *cargo_type)
 
{
 
	CargoTypes cargoes = 0;
 
	CargoID first_cargo = CT_INVALID;
 
	CargoID first_cargo = INVALID_CARGO;
 

	
 
	do {
 
		if (IsValidCargoID(v->cargo_type) && v->GetEngine()->CanCarryCargo()) {
 
@@ -273,7 +273,7 @@ CargoTypes GetCargoTypesOfArticulatedVeh
 
			if (!IsValidCargoID(first_cargo)) first_cargo = v->cargo_type;
 
			if (first_cargo != v->cargo_type) {
 
				if (cargo_type != nullptr) {
 
					*cargo_type = CT_INVALID;
 
					*cargo_type = INVALID_CARGO;
 
					cargo_type = nullptr;
 
				}
 
			}
src/autoreplace_cmd.cpp
Show inline comments
 
@@ -227,7 +227,7 @@ static int GetIncompatibleRefitOrderIdFo
 
 * @param part_of_chain The vehicle is part of a train
 
 * @return The cargo type to replace to
 
 *    CT_NO_REFIT is returned if no refit is needed
 
 *    CT_INVALID is returned when both old and new vehicle got cargo capacity and refitting the new one to the old one's cargo type isn't possible
 
 *    INVALID_CARGO is returned when both old and new vehicle got cargo capacity and refitting the new one to the old one's cargo type isn't possible
 
 */
 
static CargoID GetNewCargoTypeForReplace(Vehicle *v, EngineID engine_type, bool part_of_chain)
 
{
 
@@ -244,7 +244,7 @@ static CargoID GetNewCargoTypeForReplace
 
			return CT_NO_REFIT; // engine_type is already a mixed cargo type which matches the incoming vehicle by default, no refit required
 
		}
 

	
 
		return CT_INVALID; // We cannot refit to mixed cargoes in an automated way
 
		return INVALID_CARGO; // We cannot refit to mixed cargoes in an automated way
 
	}
 

	
 
	if (!IsValidCargoID(cargo_type)) {
 
@@ -263,9 +263,9 @@ static CargoID GetNewCargoTypeForReplace
 

	
 
		return CT_NO_REFIT; // We failed to find a cargo type on the old vehicle and we will not refit the new one
 
	} else {
 
		if (!HasBit(available_cargo_types, cargo_type)) return CT_INVALID; // We can't refit the vehicle to carry the cargo we want
 
		if (!HasBit(available_cargo_types, cargo_type)) return INVALID_CARGO; // We can't refit the vehicle to carry the cargo we want
 

	
 
		if (part_of_chain && !VerifyAutoreplaceRefitForOrders(v, engine_type)) return CT_INVALID; // Some refit orders lose their effect
 
		if (part_of_chain && !VerifyAutoreplaceRefitForOrders(v, engine_type)) return INVALID_CARGO; // Some refit orders lose their effect
 

	
 
		return cargo_type;
 
	}
 
@@ -352,7 +352,7 @@ static CommandCost BuildReplacementVehic
 

	
 
	/* Build the new vehicle */
 
	VehicleID new_veh_id;
 
	std::tie(cost, new_veh_id, std::ignore, std::ignore, std::ignore) = Command<CMD_BUILD_VEHICLE>::Do(DC_EXEC | DC_AUTOREPLACE, old_veh->tile, e, true, CT_INVALID, INVALID_CLIENT_ID);
 
	std::tie(cost, new_veh_id, std::ignore, std::ignore, std::ignore) = Command<CMD_BUILD_VEHICLE>::Do(DC_EXEC | DC_AUTOREPLACE, old_veh->tile, e, true, INVALID_CARGO, INVALID_CLIENT_ID);
 
	if (cost.Failed()) return cost;
 

	
 
	Vehicle *new_veh = Vehicle::Get(new_veh_id);
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -95,7 +95,7 @@ static const NWidgetPart _nested_build_v
 

	
 
/** Special cargo filter criteria */
 
static const CargoID CF_ANY     = CT_NO_REFIT;   ///< Show all vehicles independent of carried cargo (i.e. no filtering)
 
static const CargoID CF_NONE    = CT_INVALID;    ///< Show only vehicles which do not carry cargo (e.g. train engines)
 
static const CargoID CF_NONE    = INVALID_CARGO; ///< Show only vehicles which do not carry cargo (e.g. train engines)
 
static const CargoID CF_ENGINES = CT_AUTO_REFIT; ///< Show only engines (for rail vehicles only)
 

	
 
bool _engine_sort_direction; ///< \c false = descending, \c true = ascending.
 
@@ -908,7 +908,7 @@ void TestedEngineDetails::FillDefaultCap
 
		this->all_capacities[this->cargo] = this->capacity;
 
		this->all_capacities[CT_MAIL] = this->mail_capacity;
 
	}
 
	if (this->all_capacities.GetCount() == 0) this->cargo = CT_INVALID;
 
	if (this->all_capacities.GetCount() == 0) this->cargo = INVALID_CARGO;
 
}
 

	
 
/**
 
@@ -954,7 +954,7 @@ int DrawVehiclePurchaseInfo(int left, in
 
		int new_y = DrawCargoCapacityInfo(left, right, y, te, refittable);
 

	
 
		if (new_y == y) {
 
			SetDParam(0, CT_INVALID);
 
			SetDParam(0, INVALID_CARGO);
 
			SetDParam(2, STR_EMPTY);
 
			DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY);
 
			y += GetCharacterHeight(FS_NORMAL);
 
@@ -1293,7 +1293,7 @@ struct BuildVehicleWindow : Window {
 
	void SelectEngine(EngineID engine)
 
	{
 
		CargoID cargo = this->cargo_filter_criteria;
 
		if (cargo == CF_ANY || cargo == CF_ENGINES || cargo == CF_NONE) cargo = CT_INVALID;
 
		if (cargo == CF_ANY || cargo == CF_ENGINES || cargo == CF_NONE) cargo = INVALID_CARGO;
 

	
 
		this->sel_engine = engine;
 
		this->SetBuyVehicleText();
 
@@ -1652,7 +1652,7 @@ struct BuildVehicleWindow : Window {
 
				EngineID sel_eng = this->sel_engine;
 
				if (sel_eng != INVALID_ENGINE) {
 
					CargoID cargo = this->cargo_filter_criteria;
 
					if (cargo == CF_ANY || cargo == CF_ENGINES || cargo == CF_NONE) cargo = CT_INVALID;
 
					if (cargo == CF_ANY || cargo == CF_ENGINES || cargo == CF_NONE) cargo = INVALID_CARGO;
 
					if (this->vehicle_type == VEH_TRAIN && RailVehInfo(sel_eng)->railveh_type == RAILVEH_WAGON) {
 
						Command<CMD_BUILD_VEHICLE>::Post(GetCmdBuildVehMsg(this->vehicle_type), CcBuildWagon, this->window_number, sel_eng, true, cargo, INVALID_CLIENT_ID);
 
					} else {
src/cargo_type.h
Show inline comments
 
@@ -69,10 +69,12 @@ enum CargoType {
 
	CT_INVALID      = 0xFF, ///< Invalid cargo type.
 
};
 

	
 
static const CargoID INVALID_CARGO = UINT8_MAX;
 

	
 
/** Test whether cargo type is not CT_INVALID */
 
inline bool IsValidCargoType(CargoType t) { return t != CT_INVALID; }
 
/** Test whether cargo type is not CT_INVALID */
 
inline bool IsValidCargoID(CargoID t) { return t != CT_INVALID; }
 
/** Test whether cargo type is not INVALID_CARGO */
 
inline bool IsValidCargoID(CargoID t) { return t != INVALID_CARGO; }
 

	
 
typedef uint64_t CargoTypes;
 

	
src/cargotype.cpp
Show inline comments
 
@@ -88,13 +88,13 @@ Dimension GetLargestCargoIconSize()
 
 * Get the cargo ID of a default cargo, if present.
 
 * @param l Landscape
 
 * @param ct Default cargo type.
 
 * @return ID number if the cargo exists, else #CT_INVALID
 
 * @return ID number if the cargo exists, else #INVALID_CARGO
 
 */
 
CargoID GetDefaultCargoID(LandscapeID l, CargoType ct)
 
{
 
	assert(l < lengthof(_default_climate_cargo));
 

	
 
	if (!IsValidCargoType(ct)) return CT_INVALID;
 
	if (!IsValidCargoType(ct)) return INVALID_CARGO;
 

	
 
	assert(ct < lengthof(_default_climate_cargo[0]));
 
	CargoLabel cl = _default_climate_cargo[l][ct];
 
@@ -109,7 +109,7 @@ CargoID GetDefaultCargoID(LandscapeID l,
 
/**
 
 * Get the cargo ID by cargo label.
 
 * @param cl Cargo type to get.
 
 * @return ID number if the cargo exists, else #CT_INVALID
 
 * @return ID number if the cargo exists, else #INVALID_CARGO
 
 */
 
CargoID GetCargoIDByLabel(CargoLabel cl)
 
{
 
@@ -118,25 +118,25 @@ CargoID GetCargoIDByLabel(CargoLabel cl)
 
	}
 

	
 
	/* No matching label was found, so it is invalid */
 
	return CT_INVALID;
 
	return INVALID_CARGO;
 
}
 

	
 

	
 
/**
 
 * Find the CargoID of a 'bitnum' value.
 
 * @param bitnum 'bitnum' to find.
 
 * @return First CargoID with the given bitnum, or #CT_INVALID if not found or if the provided \a bitnum is invalid.
 
 * @return First CargoID with the given bitnum, or #INVALID_CARGO if not found or if the provided \a bitnum is invalid.
 
 */
 
CargoID GetCargoIDByBitnum(uint8_t bitnum)
 
{
 
	if (bitnum == INVALID_CARGO_BITNUM) return CT_INVALID;
 
	if (bitnum == INVALID_CARGO_BITNUM) return INVALID_CARGO;
 

	
 
	for (const CargoSpec *cs : CargoSpec::Iterate()) {
 
		if (cs->bitnum == bitnum) return cs->Index();
 
	}
 

	
 
	/* No matching label was found, so it is invalid */
 
	return CT_INVALID;
 
	return INVALID_CARGO;
 
}
 

	
 
/**
src/engine.cpp
Show inline comments
 
@@ -85,8 +85,8 @@ Engine::Engine(VehicleType type, EngineI
 
		this->info.base_life = 0xFF;
 
		/* Set road vehicle tractive effort to the default value */
 
		if (type == VEH_ROAD) this->u.road.tractive_effort = 0x4C;
 
		/* Aircraft must have CT_INVALID as default, as there is no property */
 
		if (type == VEH_AIRCRAFT) this->info.cargo_type = CT_INVALID;
 
		/* Aircraft must have INVALID_CARGO as default, as there is no property */
 
		if (type == VEH_AIRCRAFT) this->info.cargo_type = INVALID_CARGO;
 
		/* Set visual effect to the default value */
 
		switch (type) {
 
			case VEH_TRAIN: this->u.rail.visual_effect = VE_DEFAULT; break;
src/engine_base.h
Show inline comments
 
@@ -88,7 +88,7 @@ struct Engine : EnginePool::PoolItem<&_e
 
	 * Usually a valid cargo is returned, even though the vehicle has zero capacity, and can therefore not carry anything. But the cargotype is still used
 
	 * for livery selection etc..
 
	 *
 
	 * Vehicles with CT_INVALID as default cargo are usually not available, but it can appear as default cargo of articulated parts.
 
	 * Vehicles with INVALID_CARGO as default cargo are usually not available, but it can appear as default cargo of articulated parts.
 
	 *
 
	 * @return The default cargo type.
 
	 * @see CanCarryCargo
src/engine_gui.cpp
Show inline comments
 
@@ -183,7 +183,7 @@ static StringID GetTrainEngineInfoString
 
		SetDParam(5, e->GetDefaultCargoType());
 
		SetDParam(6, capacity);
 
	} else {
 
		SetDParam(5, CT_INVALID);
 
		SetDParam(5, INVALID_CARGO);
 
	}
 
	return (_settings_game.vehicle.train_acceleration_model != AM_ORIGINAL && GetRailTypeInfo(e->u.rail.railtype)->acceleration_type != 2) ? STR_ENGINE_PREVIEW_COST_WEIGHT_SPEED_POWER_MAX_TE : STR_ENGINE_PREVIEW_COST_WEIGHT_SPEED_POWER;
 
}
 
@@ -224,7 +224,7 @@ static StringID GetRoadVehEngineInfoStri
 
			SetDParam(2, e->GetDefaultCargoType());
 
			SetDParam(3, capacity);
 
		} else {
 
			SetDParam(2, CT_INVALID);
 
			SetDParam(2, INVALID_CARGO);
 
		}
 
		SetDParam(4, e->GetRunningCost());
 
		return STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAP_RUNCOST;
 
@@ -242,7 +242,7 @@ static StringID GetRoadVehEngineInfoStri
 
			SetDParam(5, e->GetDefaultCargoType());
 
			SetDParam(6, capacity);
 
		} else {
 
			SetDParam(5, CT_INVALID);
 
			SetDParam(5, INVALID_CARGO);
 
		}
 
		return STR_ENGINE_PREVIEW_COST_WEIGHT_SPEED_POWER_MAX_TE;
 
	}
src/industry_cmd.cpp
Show inline comments
 
@@ -424,7 +424,7 @@ static void AddAcceptedCargo_Industry(Ti
 
			auto pos = std::find(std::begin(accepts_cargo), std::end(accepts_cargo), a.cargo);
 
			if (pos == std::end(accepts_cargo)) {
 
				/* Not found, insert */
 
				pos = std::find(std::begin(accepts_cargo), std::end(accepts_cargo), CT_INVALID);
 
				pos = std::find(std::begin(accepts_cargo), std::end(accepts_cargo), INVALID_CARGO);
 
				if (pos == std::end(accepts_cargo)) continue; // nowhere to place, give up on this one
 
				*pos = a.cargo;
 
			}
 
@@ -436,7 +436,7 @@ static void AddAcceptedCargo_Industry(Ti
 
		/* Try callback for accepts list, if success override all existing accepts */
 
		uint16_t res = GetIndustryTileCallback(CBID_INDTILE_ACCEPT_CARGO, 0, 0, gfx, Industry::GetByTile(tile), tile);
 
		if (res != CALLBACK_FAILED) {
 
			accepts_cargo.fill(CT_INVALID);
 
			accepts_cargo.fill(INVALID_CARGO);
 
			for (uint i = 0; i < 3; i++) accepts_cargo[i] = GetCargoTranslation(GB(res, i * 5, 5), itspec->grf_prop.grffile);
 
		}
 
	}
 
@@ -1838,7 +1838,7 @@ static void DoCreateNewIndustry(Industry
 

	
 
	if (HasBit(indspec->callback_mask, CBM_IND_INPUT_CARGO_TYPES)) {
 
		/* Clear all input cargo types */
 
		for (auto &a : i->accepted) a.cargo = CT_INVALID;
 
		for (auto &a : i->accepted) a.cargo = INVALID_CARGO;
 
		/* Query actual types */
 
		uint maxcargoes = (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) ? static_cast<uint>(i->accepted.size()) : 3;
 
		for (uint j = 0; j < maxcargoes; j++) {
 
@@ -1870,7 +1870,7 @@ static void DoCreateNewIndustry(Industry
 

	
 
	if (HasBit(indspec->callback_mask, CBM_IND_OUTPUT_CARGO_TYPES)) {
 
		/* Clear all output cargo types */
 
		for (auto &p : i->produced) p.cargo = CT_INVALID;
 
		for (auto &p : i->produced) p.cargo = INVALID_CARGO;
 
		/* Query actual types */
 
		uint maxcargoes = (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) ? static_cast<uint>(i->produced.size()) : 2;
 
		for (uint j = 0; j < maxcargoes; j++) {
src/industry_gui.cpp
Show inline comments
 
@@ -148,7 +148,7 @@ enum CargoSuffixInOut {
 
 * @param ind the industry (nullptr if in fund window)
 
 * @param ind_type the industry type
 
 * @param indspec the industry spec
 
 * @param cargoes array with cargotypes. for CT_INVALID no suffix will be determined
 
 * @param cargoes array with cargotypes. for INVALID_CARGO no suffix will be determined
 
 * @param suffixes is filled with the suffixes
 
 */
 
template <typename TC, typename TS>
 
@@ -197,7 +197,7 @@ static inline void GetAllCargoSuffixes(C
 
 * @param ind the industry (nullptr if in fund window)
 
 * @param ind_type the industry type
 
 * @param indspec the industry spec
 
 * @param cargo cargotype. for CT_INVALID no suffix will be determined
 
 * @param cargo cargotype. for INVALID_CARGO no suffix will be determined
 
 * @param slot accepts/produced slot number, used for old-style 3-in/2-out industries.
 
 * @param suffix is filled with the suffix
 
 */
 
@@ -1248,7 +1248,7 @@ typedef GUIList<const Industry *, const 
 
/** Special cargo filter criteria */
 
enum CargoFilterSpecialType {
 
	CF_ANY  = CT_NO_REFIT, ///< Show all industries (i.e. no filtering)
 
	CF_NONE = CT_INVALID,  ///< Show only industries which do not produce/accept cargo
 
	CF_NONE = INVALID_CARGO, ///< Show only industries which do not produce/accept cargo
 
};
 

	
 
/** Cargo filter functions */
 
@@ -1995,15 +1995,15 @@ struct CargoesField {
 
			CargoID other_accepted[MAX_CARGOES];   ///< Cargoes accepted but not used in this figure.
 
		} industry; ///< Industry data (for #CFT_INDUSTRY).
 
		struct {
 
			CargoID vertical_cargoes[MAX_CARGOES]; ///< Cargoes running from top to bottom (cargo ID or #CT_INVALID).
 
			CargoID vertical_cargoes[MAX_CARGOES]; ///< Cargoes running from top to bottom (cargo ID or #INVALID_CARGO).
 
			uint8_t num_cargoes;                   ///< Number of cargoes.
 
			CargoID supp_cargoes[MAX_CARGOES];     ///< Cargoes entering from the left (index in #vertical_cargoes, or #CT_INVALID).
 
			CargoID supp_cargoes[MAX_CARGOES];     ///< Cargoes entering from the left (index in #vertical_cargoes, or #INVALID_CARGO).
 
			uint8_t top_end;                       ///< Stop at the top of the vertical cargoes.
 
			CargoID cust_cargoes[MAX_CARGOES];     ///< Cargoes leaving to the right (index in #vertical_cargoes, or #CT_INVALID).
 
			CargoID cust_cargoes[MAX_CARGOES];     ///< Cargoes leaving to the right (index in #vertical_cargoes, or #INVALID_CARGO).
 
			uint8_t bottom_end;                    ///< Stop at the bottom of the vertical cargoes.
 
		} cargo; ///< Cargo data (for #CFT_CARGO).
 
		struct {
 
			CargoID cargoes[MAX_CARGOES];          ///< Cargoes to display (or #CT_INVALID).
 
			CargoID cargoes[MAX_CARGOES];          ///< Cargoes to display (or #INVALID_CARGO).
 
			bool left_align;                       ///< Align all cargo texts to the left (else align to the right).
 
		} cargo_label;   ///< Label data (for #CFT_CARGO_LABEL).
 
		StringID header; ///< Header text (for #CFT_HEADER).
 
@@ -2027,8 +2027,8 @@ struct CargoesField {
 
	{
 
		this->type = CFT_INDUSTRY;
 
		this->u.industry.ind_type = ind_type;
 
		std::fill(std::begin(this->u.industry.other_accepted), std::end(this->u.industry.other_accepted), CT_INVALID);
 
		std::fill(std::begin(this->u.industry.other_produced), std::end(this->u.industry.other_produced), CT_INVALID);
 
		std::fill(std::begin(this->u.industry.other_accepted), std::end(this->u.industry.other_accepted), INVALID_CARGO);
 
		std::fill(std::begin(this->u.industry.other_produced), std::end(this->u.industry.other_produced), INVALID_CARGO);
 
	}
 

	
 
	/**
 
@@ -2079,7 +2079,7 @@ struct CargoesField {
 

	
 
	/**
 
	 * Make a piece of cargo column.
 
	 * @param cargoes    Array of #CargoID (may contain #CT_INVALID).
 
	 * @param cargoes    Array of #CargoID (may contain #INVALID_CARGO).
 
	 * @param length     Number of cargoes in \a cargoes.
 
	 * @param count      Number of cargoes to display (should be at least the number of valid cargoes, or \c -1 to let the method compute it).
 
	 * @param top_end    This is the first cargo field of this column.
 
@@ -2099,16 +2099,16 @@ struct CargoesField {
 
		this->u.cargo.num_cargoes = (count < 0) ? static_cast<uint8_t>(insert - std::begin(this->u.cargo.vertical_cargoes)) : count;
 
		CargoIDComparator comparator;
 
		std::sort(std::begin(this->u.cargo.vertical_cargoes), insert, comparator);
 
		std::fill(insert, std::end(this->u.cargo.vertical_cargoes), CT_INVALID);
 
		std::fill(insert, std::end(this->u.cargo.vertical_cargoes), INVALID_CARGO);
 
		this->u.cargo.top_end = top_end;
 
		this->u.cargo.bottom_end = bottom_end;
 
		std::fill(std::begin(this->u.cargo.supp_cargoes), std::end(this->u.cargo.supp_cargoes), CT_INVALID);
 
		std::fill(std::begin(this->u.cargo.cust_cargoes), std::end(this->u.cargo.cust_cargoes), CT_INVALID);
 
		std::fill(std::begin(this->u.cargo.supp_cargoes), std::end(this->u.cargo.supp_cargoes), INVALID_CARGO);
 
		std::fill(std::begin(this->u.cargo.cust_cargoes), std::end(this->u.cargo.cust_cargoes), INVALID_CARGO);
 
	}
 

	
 
	/**
 
	 * Make a field displaying cargo type names.
 
	 * @param cargoes    Array of #CargoID (may contain #CT_INVALID).
 
	 * @param cargoes    Array of #CargoID (may contain #INVALID_CARGO).
 
	 * @param length     Number of cargoes in \a cargoes.
 
	 * @param left_align ALign texts to the left (else to the right).
 
	 */
 
@@ -2117,7 +2117,7 @@ struct CargoesField {
 
		this->type = CFT_CARGO_LABEL;
 
		uint i;
 
		for (i = 0; i < MAX_CARGOES && i < length; i++) this->u.cargo_label.cargoes[i] = cargoes[i];
 
		for (; i < MAX_CARGOES; i++) this->u.cargo_label.cargoes[i] = CT_INVALID;
 
		for (; i < MAX_CARGOES; i++) this->u.cargo_label.cargoes[i] = INVALID_CARGO;
 
		this->u.cargo_label.left_align = left_align;
 
	}
 

	
 
@@ -2290,7 +2290,7 @@ struct CargoesField {
 
	 * @param left  Left industry neighbour if available (else \c nullptr should be supplied).
 
	 * @param right Right industry neighbour if available (else \c nullptr should be supplied).
 
	 * @param pt    Click position in the cargo field.
 
	 * @return Cargo clicked at, or #CT_INVALID if none.
 
	 * @return Cargo clicked at, or #INVALID_CARGO if none.
 
	 */
 
	CargoID CargoClickedAt(const CargoesField *left, const CargoesField *right, Point pt) const
 
	{
 
@@ -2309,11 +2309,11 @@ struct CargoesField {
 
		int vpos = vert_inter_industry_space / 2 + CargoesField::cargo_border.width;
 
		uint row;
 
		for (row = 0; row < MAX_CARGOES; row++) {
 
			if (pt.y < vpos) return CT_INVALID;
 
			if (pt.y < vpos) return INVALID_CARGO;
 
			if (pt.y < vpos + GetCharacterHeight(FS_NORMAL)) break;
 
			vpos += GetCharacterHeight(FS_NORMAL) + CargoesField::cargo_space.width;
 
		}
 
		if (row == MAX_CARGOES) return CT_INVALID;
 
		if (row == MAX_CARGOES) return INVALID_CARGO;
 

	
 
		/* row = 0 -> at first horizontal row, row = 1 -> second horizontal row, 2 = 3rd horizontal row. */
 
		if (col == 0) {
 
@@ -2322,7 +2322,7 @@ struct CargoesField {
 
				if (left->type == CFT_INDUSTRY) return left->u.industry.other_produced[row];
 
				if (left->type == CFT_CARGO_LABEL && !left->u.cargo_label.left_align) return left->u.cargo_label.cargoes[row];
 
			}
 
			return CT_INVALID;
 
			return INVALID_CARGO;
 
		}
 
		if (col == this->u.cargo.num_cargoes) {
 
			if (IsValidCargoID(this->u.cargo.cust_cargoes[row])) return this->u.cargo.vertical_cargoes[this->u.cargo.cust_cargoes[row]];
 
@@ -2330,7 +2330,7 @@ struct CargoesField {
 
				if (right->type == CFT_INDUSTRY) return right->u.industry.other_accepted[row];
 
				if (right->type == CFT_CARGO_LABEL && right->u.cargo_label.left_align) return right->u.cargo_label.cargoes[row];
 
			}
 
			return CT_INVALID;
 
			return INVALID_CARGO;
 
		}
 
		if (row >= col) {
 
			/* Clicked somewhere in-between vertical cargo connection.
 
@@ -2338,17 +2338,17 @@ struct CargoesField {
 
			 * ensures we are left-below the main diagonal, thus at the supplying side.
 
			 */
 
			if (IsValidCargoID(this->u.cargo.supp_cargoes[row])) return this->u.cargo.vertical_cargoes[this->u.cargo.supp_cargoes[row]];
 
			return CT_INVALID;
 
			return INVALID_CARGO;
 
		}
 
		/* Clicked at a customer connection. */
 
		if (IsValidCargoID(this->u.cargo.cust_cargoes[row])) return this->u.cargo.vertical_cargoes[this->u.cargo.cust_cargoes[row]];
 
		return CT_INVALID;
 
		return INVALID_CARGO;
 
	}
 

	
 
	/**
 
	 * Decide what cargo the user clicked in the cargo label field.
 
	 * @param pt Click position in the cargo label field.
 
	 * @return Cargo clicked at, or #CT_INVALID if none.
 
	 * @return Cargo clicked at, or #INVALID_CARGO if none.
 
	 */
 
	CargoID CargoLabelClickedAt(Point pt) const
 
	{
 
@@ -2357,11 +2357,11 @@ struct CargoesField {
 
		int vpos = vert_inter_industry_space / 2 + CargoesField::cargo_border.height;
 
		uint row;
 
		for (row = 0; row < MAX_CARGOES; row++) {
 
			if (pt.y < vpos) return CT_INVALID;
 
			if (pt.y < vpos) return INVALID_CARGO;
 
			if (pt.y < vpos + GetCharacterHeight(FS_NORMAL)) break;
 
			vpos += GetCharacterHeight(FS_NORMAL) + CargoesField::cargo_space.height;
 
		}
 
		if (row == MAX_CARGOES) return CT_INVALID;
 
		if (row == MAX_CARGOES) return INVALID_CARGO;
 
		return this->u.cargo_label.cargoes[row];
 
	}
 

	
 
@@ -2416,7 +2416,7 @@ struct CargoesRow {
 
		CargoesField *cargo_fld = this->columns + column + 1;
 
		assert(ind_fld->type == CFT_INDUSTRY && cargo_fld->type == CFT_CARGO);
 

	
 
		std::fill(std::begin(ind_fld->u.industry.other_produced), std::end(ind_fld->u.industry.other_produced), CT_INVALID);
 
		std::fill(std::begin(ind_fld->u.industry.other_produced), std::end(ind_fld->u.industry.other_produced), INVALID_CARGO);
 

	
 
		if (ind_fld->u.industry.ind_type < NUM_INDUSTRYTYPES) {
 
			CargoID others[MAX_CARGOES]; // Produced cargoes not carried in the cargo column.
 
@@ -2450,7 +2450,7 @@ struct CargoesRow {
 
	void MakeCargoLabel(int column, bool accepting)
 
	{
 
		CargoID cargoes[MAX_CARGOES];
 
		std::fill(std::begin(cargoes), std::end(cargoes), CT_INVALID);
 
		std::fill(std::begin(cargoes), std::end(cargoes), INVALID_CARGO);
 

	
 
		CargoesField *label_fld = this->columns + column;
 
		CargoesField *cargo_fld = this->columns + (accepting ? column - 1 : column + 1);
 
@@ -2474,7 +2474,7 @@ struct CargoesRow {
 
		CargoesField *cargo_fld = this->columns + column - 1;
 
		assert(ind_fld->type == CFT_INDUSTRY && cargo_fld->type == CFT_CARGO);
 

	
 
		std::fill(std::begin(ind_fld->u.industry.other_accepted), std::end(ind_fld->u.industry.other_accepted), CT_INVALID);
 
		std::fill(std::begin(ind_fld->u.industry.other_accepted), std::end(ind_fld->u.industry.other_accepted), INVALID_CARGO);
 

	
 
		if (ind_fld->u.industry.ind_type < NUM_INDUSTRYTYPES) {
 
			CargoID others[MAX_CARGOES]; // Accepted cargoes not carried in the cargo column.
 
@@ -3157,7 +3157,7 @@ struct IndustryCargoesWindow : public Wi
 
		if (!CalculatePositionInWidget(pt, &fieldxy, &xy)) return false;
 

	
 
		const CargoesField *fld = this->fields[fieldxy.y].columns + fieldxy.x;
 
		CargoID cid = CT_INVALID;
 
		CargoID cid = INVALID_CARGO;
 
		switch (fld->type) {
 
			case CFT_CARGO: {
 
				CargoesField *lft = (fieldxy.x > 0) ? this->fields[fieldxy.y].columns + fieldxy.x - 1 : nullptr;
src/linkgraph/linkgraph.h
Show inline comments
 
@@ -189,7 +189,7 @@ public:
 
	}
 

	
 
	/** Bare constructor, only for save/load. */
 
	LinkGraph() : cargo(CT_INVALID), last_compression(0) {}
 
	LinkGraph() : cargo(INVALID_CARGO), last_compression(0) {}
 
	/**
 
	 * Real constructor.
 
	 * @param cargo Cargo the link graph is about.
src/linkgraph/linkgraph_gui.h
Show inline comments
 
@@ -21,7 +21,7 @@
 
 * Only the cargo type of the most saturated linkgraph is taken into account.
 
 */
 
struct LinkProperties {
 
	LinkProperties() : cargo(CT_INVALID), capacity(0), usage(0), planned(0), shared(false) {}
 
	LinkProperties() : cargo(INVALID_CARGO), capacity(0), usage(0), planned(0), shared(false) {}
 

	
 
	/** Return the usage of the link to display. */
 
	uint Usage() const { return std::max(this->usage, this->planned); }
src/linkgraph/refresh.cpp
Show inline comments
 
@@ -67,7 +67,7 @@ bool LinkRefresher::Hop::operator<(const
 
 * @param is_full_loading If the vehicle is full loading.
 
 */
 
LinkRefresher::LinkRefresher(Vehicle *vehicle, HopSet *seen_hops, bool allow_merge, bool is_full_loading) :
 
	vehicle(vehicle), seen_hops(seen_hops), cargo(CT_INVALID), allow_merge(allow_merge),
 
	vehicle(vehicle), seen_hops(seen_hops), cargo(INVALID_CARGO), allow_merge(allow_merge),
 
	is_full_loading(is_full_loading)
 
{
 
	memset(this->capacities, 0, sizeof(this->capacities));
src/linkgraph/refresh.h
Show inline comments
 
@@ -56,7 +56,7 @@ protected:
 
	struct Hop {
 
		OrderID from;  ///< Last order where vehicle could interact with cargo or absolute first order.
 
		OrderID to;    ///< Next order to be processed.
 
		CargoID cargo; ///< Cargo the consist is probably carrying or CT_INVALID if unknown.
 
		CargoID cargo; ///< Cargo the consist is probably carrying or INVALID_CARGO if unknown.
 

	
 
		/**
 
		 * Default constructor should not be called but has to be visible for
src/newgrf.cpp
Show inline comments
 
@@ -1140,15 +1140,15 @@ static ChangeInfoResult RailVehicleChang
 

	
 
				if (ctype == 0xFF) {
 
					/* 0xFF is specified as 'use first refittable' */
 
					ei->cargo_type = CT_INVALID;
 
					ei->cargo_type = INVALID_CARGO;
 
				} else if (_cur.grffile->grf_version >= 8) {
 
					/* Use translated cargo. Might result in CT_INVALID (first refittable), if cargo is not defined. */
 
					/* Use translated cargo. Might result in INVALID_CARGO (first refittable), if cargo is not defined. */
 
					ei->cargo_type = GetCargoTranslation(ctype, _cur.grffile);
 
				} else if (ctype < NUM_CARGO) {
 
					/* Use untranslated cargo. */
 
					ei->cargo_type = ctype;
 
				} else {
 
					ei->cargo_type = CT_INVALID;
 
					ei->cargo_type = INVALID_CARGO;
 
					GrfMsg(2, "RailVehicleChangeInfo: Invalid cargo type {}, using first refittable", ctype);
 
				}
 
				break;
 
@@ -1401,15 +1401,15 @@ static ChangeInfoResult RoadVehicleChang
 

	
 
				if (ctype == 0xFF) {
 
					/* 0xFF is specified as 'use first refittable' */
 
					ei->cargo_type = CT_INVALID;
 
					ei->cargo_type = INVALID_CARGO;
 
				} else if (_cur.grffile->grf_version >= 8) {
 
					/* Use translated cargo. Might result in CT_INVALID (first refittable), if cargo is not defined. */
 
					/* Use translated cargo. Might result in INVALID_CARGO (first refittable), if cargo is not defined. */
 
					ei->cargo_type = GetCargoTranslation(ctype, _cur.grffile);
 
				} else if (ctype < NUM_CARGO) {
 
					/* Use untranslated cargo. */
 
					ei->cargo_type = ctype;
 
				} else {
 
					ei->cargo_type = CT_INVALID;
 
					ei->cargo_type = INVALID_CARGO;
 
					GrfMsg(2, "RailVehicleChangeInfo: Invalid cargo type {}, using first refittable", ctype);
 
				}
 
				break;
 
@@ -1596,15 +1596,15 @@ static ChangeInfoResult ShipVehicleChang
 

	
 
				if (ctype == 0xFF) {
 
					/* 0xFF is specified as 'use first refittable' */
 
					ei->cargo_type = CT_INVALID;
 
					ei->cargo_type = INVALID_CARGO;
 
				} else if (_cur.grffile->grf_version >= 8) {
 
					/* Use translated cargo. Might result in CT_INVALID (first refittable), if cargo is not defined. */
 
					/* Use translated cargo. Might result in INVALID_CARGO (first refittable), if cargo is not defined. */
 
					ei->cargo_type = GetCargoTranslation(ctype, _cur.grffile);
 
				} else if (ctype < NUM_CARGO) {
 
					/* Use untranslated cargo. */
 
					ei->cargo_type = ctype;
 
				} else {
 
					ei->cargo_type = CT_INVALID;
 
					ei->cargo_type = INVALID_CARGO;
 
					GrfMsg(2, "ShipVehicleChangeInfo: Invalid cargo type {}, using first refittable", ctype);
 
				}
 
				break;
 
@@ -2588,7 +2588,7 @@ static ChangeInfoResult TownHouseChangeI
 
						housespec->accepts_cargo[i] = GetCargoTranslation(buf->ReadByte(), _cur.grffile);
 
						housespec->cargo_acceptance[i] = buf->ReadByte();
 
					} else {
 
						housespec->accepts_cargo[i] = CT_INVALID;
 
						housespec->accepts_cargo[i] = INVALID_CARGO;
 
						housespec->cargo_acceptance[i] = 0;
 
					}
 
				}
 
@@ -3306,7 +3306,7 @@ static ChangeInfoResult IndustrytilesCha
 
						/* Tile acceptance can be negative to counteract the INDTILE_SPECIAL_ACCEPTS_ALL_CARGO flag */
 
						tsp->acceptance[i] = (int8_t)buf->ReadByte();
 
					} else {
 
						tsp->accepts_cargo[i] = CT_INVALID;
 
						tsp->accepts_cargo[i] = INVALID_CARGO;
 
						tsp->acceptance[i] = 0;
 
					}
 
				}
 
@@ -3753,7 +3753,7 @@ static ChangeInfoResult IndustriesChange
 
						CargoID cargo = GetCargoTranslation(buf->ReadByte(), _cur.grffile);
 
						indsp->produced_cargo[i] = cargo;
 
					} else {
 
						indsp->produced_cargo[i] = CT_INVALID;
 
						indsp->produced_cargo[i] = INVALID_CARGO;
 
					}
 
				}
 
				break;
 
@@ -3771,7 +3771,7 @@ static ChangeInfoResult IndustriesChange
 
						CargoID cargo = GetCargoTranslation(buf->ReadByte(), _cur.grffile);
 
						indsp->accepts_cargo[i] = cargo;
 
					} else {
 
						indsp->accepts_cargo[i] = CT_INVALID;
 
						indsp->accepts_cargo[i] = INVALID_CARGO;
 
					}
 
				}
 
				break;
 
@@ -5515,7 +5515,7 @@ static CargoID TranslateCargo(uint8_t fe
 
		/* No cargo table, so use bitnum values */
 
		if (ctype >= 32) {
 
			GrfMsg(1, "TranslateCargo: Cargo bitnum {} out of range (max 31), skipping.", ctype);
 
			return CT_INVALID;
 
			return INVALID_CARGO;
 
		}
 

	
 
		for (const CargoSpec *cs : CargoSpec::Iterate()) {
 
@@ -5526,30 +5526,30 @@ static CargoID TranslateCargo(uint8_t fe
 
		}
 

	
 
		GrfMsg(5, "TranslateCargo: Cargo bitnum {} not available in this climate, skipping.", ctype);
 
		return CT_INVALID;
 
		return INVALID_CARGO;
 
	}
 

	
 
	/* Check if the cargo type is out of bounds of the cargo translation table */
 
	if (ctype >= _cur.grffile->cargo_list.size()) {
 
		GrfMsg(1, "TranslateCargo: Cargo type {} out of range (max {}), skipping.", ctype, (unsigned int)_cur.grffile->cargo_list.size() - 1);
 
		return CT_INVALID;
 
		return INVALID_CARGO;
 
	}
 

	
 
	/* Look up the cargo label from the translation table */
 
	CargoLabel cl = _cur.grffile->cargo_list[ctype];
 
	if (cl == 0) {
 
		GrfMsg(5, "TranslateCargo: Cargo type {} not available in this climate, skipping.", ctype);
 
		return CT_INVALID;
 
	}
 

	
 
	ctype = GetCargoIDByLabel(cl);
 
	if (!IsValidCargoID(ctype)) {
 
		return INVALID_CARGO;
 
	}
 

	
 
	CargoID cid = GetCargoIDByLabel(cl);
 
	if (!IsValidCargoID(cid)) {
 
		GrfMsg(5, "TranslateCargo: Cargo '{:c}{:c}{:c}{:c}' unsupported, skipping.", GB(cl, 24, 8), GB(cl, 16, 8), GB(cl, 8, 8), GB(cl, 0, 8));
 
		return CT_INVALID;
 
	}
 

	
 
	GrfMsg(6, "TranslateCargo: Cargo '{:c}{:c}{:c}{:c}' mapped to cargo type {}.", GB(cl, 24, 8), GB(cl, 16, 8), GB(cl, 8, 8), GB(cl, 0, 8), ctype);
 
	return ctype;
 
		return INVALID_CARGO;
 
	}
 

	
 
	GrfMsg(6, "TranslateCargo: Cargo '{:c}{:c}{:c}{:c}' mapped to cargo type {}.", GB(cl, 24, 8), GB(cl, 16, 8), GB(cl, 8, 8), GB(cl, 0, 8), cid);
 
	return cid;
 
}
 

	
 

	
 
@@ -5612,8 +5612,8 @@ static void VehicleMapSpriteGroup(ByteRe
 

	
 
		GrfMsg(8, "VehicleMapSpriteGroup: * [{}] Cargo type 0x{:X}, group id 0x{:02X}", c, ctype, groupid);
 

	
 
		ctype = TranslateCargo(feature, ctype);
 
		if (!IsValidCargoID(ctype)) continue;
 
		CargoID cid = TranslateCargo(feature, ctype);
 
		if (!IsValidCargoID(cid)) continue;
 

	
 
		for (uint i = 0; i < idcount; i++) {
 
			EngineID engine = engines[i];
 
@@ -5621,9 +5621,9 @@ static void VehicleMapSpriteGroup(ByteRe
 
			GrfMsg(7, "VehicleMapSpriteGroup: [{}] Engine {}...", i, engine);
 

	
 
			if (wagover) {
 
				SetWagonOverrideSprites(engine, ctype, _cur.spritegroups[groupid], last_engines, last_engines_count);
 
				SetWagonOverrideSprites(engine, cid, _cur.spritegroups[groupid], last_engines, last_engines_count);
 
			} else {
 
				SetCustomEngineSprites(engine, ctype, _cur.spritegroups[groupid]);
 
				SetCustomEngineSprites(engine, cid, _cur.spritegroups[groupid]);
 
			}
 
		}
 
	}
 
@@ -9055,12 +9055,12 @@ static void CalculateRefitMasks()
 
		}
 

	
 
		/* Clear invalid cargoslots (from default vehicles or pre-NewCargo GRFs) */
 
		if (IsValidCargoID(ei->cargo_type) && !HasBit(_cargo_mask, ei->cargo_type)) ei->cargo_type = CT_INVALID;
 
		if (IsValidCargoID(ei->cargo_type) && !HasBit(_cargo_mask, ei->cargo_type)) ei->cargo_type = INVALID_CARGO;
 

	
 
		/* Ensure that the vehicle is either not refittable, or that the default cargo is one of the refittable cargoes.
 
		 * Note: Vehicles refittable to no cargo are handle differently to vehicle refittable to a single cargo. The latter might have subtypes. */
 
		if (!only_defaultcargo && (e->type != VEH_SHIP || e->u.ship.old_refittable) && IsValidCargoID(ei->cargo_type) && !HasBit(ei->refit_mask, ei->cargo_type)) {
 
			ei->cargo_type = CT_INVALID;
 
			ei->cargo_type = INVALID_CARGO;
 
		}
 

	
 
		/* Check if this engine's cargo type is valid. If not, set to the first refittable
src/newgrf_airporttiles.h
Show inline comments
 
@@ -85,8 +85,8 @@ private:
 
};
 

	
 
void AnimateAirportTile(TileIndex tile);
 
void AirportTileAnimationTrigger(Station *st, TileIndex tile, AirpAnimationTrigger trigger, CargoID cargo_type = CT_INVALID);
 
void AirportAnimationTrigger(Station *st, AirpAnimationTrigger trigger, CargoID cargo_type = CT_INVALID);
 
void AirportTileAnimationTrigger(Station *st, TileIndex tile, AirpAnimationTrigger trigger, CargoID cargo_type = INVALID_CARGO);
 
void AirportAnimationTrigger(Station *st, AirpAnimationTrigger trigger, CargoID cargo_type = INVALID_CARGO);
 
bool DrawNewAirportTile(TileInfo *ti, Station *st, const AirportTileSpec *airts);
 

	
 
#endif /* NEWGRF_AIRPORTTILES_H */
src/newgrf_cargo.cpp
Show inline comments
 
@@ -74,13 +74,13 @@ uint16_t GetCargoCallback(CallbackID cal
 
 * @param usebit  Defines the meaning of \a cargo for GRF version < 7.
 
 *                If true, then \a cargo is a bitnum. If false, then \a cargo is a cargoslot.
 
 *                For GRF version >= 7 \a cargo is always a translated cargo bit.
 
 * @return CargoID or CT_INVALID if the cargo is not available.
 
 * @return CargoID or INVALID_CARGO if the cargo is not available.
 
 */
 
CargoID GetCargoTranslation(uint8_t cargo, const GRFFile *grffile, bool usebit)
 
{
 
	/* Pre-version 7 uses the 'climate dependent' ID in callbacks and properties, i.e. cargo is the cargo ID */
 
	if (grffile->grf_version < 7 && !usebit) {
 
		if (cargo >= CargoSpec::GetArraySize() || !CargoSpec::Get(cargo)->IsValid()) return CT_INVALID;
 
		if (cargo >= CargoSpec::GetArraySize() || !CargoSpec::Get(cargo)->IsValid()) return INVALID_CARGO;
 
		return cargo;
 
	}
 

	
 
@@ -94,5 +94,5 @@ CargoID GetCargoTranslation(uint8_t carg
 
		/* Else the cargo value is a 'climate independent' 'bitnum' */
 
		return GetCargoIDByBitnum(cargo);
 
	}
 
	return CT_INVALID;
 
	return INVALID_CARGO;
 
}
src/newgrf_engine.cpp
Show inline comments
 
@@ -451,8 +451,8 @@ static uint32_t VehicleGetVariable(Vehic
 

	
 
				/* Pick the most common cargo type */
 
				auto cargo_it = std::max_element(std::begin(common_cargoes), std::end(common_cargoes));
 
				/* Return CT_INVALID if nothing is carried */
 
				CargoID common_cargo_type = (*cargo_it == 0) ? (CargoID)CT_INVALID : static_cast<CargoID>(std::distance(std::begin(common_cargoes), cargo_it));
 
				/* Return INVALID_CARGO if nothing is carried */
 
				CargoID common_cargo_type = (*cargo_it == 0) ? INVALID_CARGO : static_cast<CargoID>(std::distance(std::begin(common_cargoes), cargo_it));
 

	
 
				/* Count subcargo types of common_cargo_type */
 
				std::array<uint8_t, UINT8_MAX + 1> common_subtypes{};
 
@@ -486,7 +486,7 @@ static uint32_t VehicleGetVariable(Vehic
 
			 *    And this is only done by CheckCaches().
 
			 */
 
			const GRFFile *grffile = object->ro.grffile;
 
			uint8_t common_bitnum = (common_cargo_type == CT_INVALID) ? 0xFF :
 
			uint8_t common_bitnum = (common_cargo_type == INVALID_CARGO) ? 0xFF :
 
				(grffile == nullptr || grffile->grf_version < 8) ? CargoSpec::Get(common_cargo_type)->bitnum : grffile->cargo_map[common_cargo_type];
 

	
 
			return (v->grf_cache.consist_cargo_information & 0xFFFF00FF) | common_bitnum << 8;
src/newgrf_roadstop.cpp
Show inline comments
 
@@ -347,7 +347,7 @@ void TriggerRoadStopAnimation(BaseStatio
 
		if (ss != nullptr && HasBit(ss->animation.triggers, trigger)) {
 
			CargoID cargo;
 
			if (!IsValidCargoID(cargo_type)) {
 
				cargo = CT_INVALID;
 
				cargo = INVALID_CARGO;
 
			} else {
 
				cargo = ss->grf_prop.grffile->cargo_map[cargo_type];
 
			}
src/newgrf_roadstop.h
Show inline comments
 
@@ -169,8 +169,8 @@ uint16_t GetRoadStopCallback(CallbackID 
 

	
 
void AnimateRoadStopTile(TileIndex tile);
 
uint8_t GetRoadStopTileAnimationSpeed(TileIndex tile);
 
void TriggerRoadStopAnimation(BaseStation *st, TileIndex tile, StationAnimationTrigger trigger, CargoID cargo_type = CT_INVALID);
 
void TriggerRoadStopRandomisation(Station *st, TileIndex tile, RoadStopRandomTrigger trigger, CargoID cargo_type = CT_INVALID);
 
void TriggerRoadStopAnimation(BaseStation *st, TileIndex tile, StationAnimationTrigger trigger, CargoID cargo_type = INVALID_CARGO);
 
void TriggerRoadStopRandomisation(Station *st, TileIndex tile, RoadStopRandomTrigger trigger, CargoID cargo_type = INVALID_CARGO);
 

	
 
bool GetIfNewStopsByType(RoadStopType rs, RoadType roadtype);
 
bool GetIfClassHasNewStopsByType(RoadStopClass *roadstopclass, RoadStopType rs, RoadType roadtype);
src/newgrf_station.cpp
Show inline comments
 
@@ -495,7 +495,7 @@ uint32_t Waypoint::GetNewGRFVariable(con
 
	const Station *st = Station::From(this->station_scope.st);
 

	
 
	switch (this->station_scope.cargo_type) {
 
		case CT_INVALID:
 
		case INVALID_CARGO:
 
		case CT_DEFAULT_NA:
 
		case CT_PURCHASE:
 
			cargo = 0;
 
@@ -887,7 +887,7 @@ void TriggerStationAnimation(BaseStation
 
			if (ss != nullptr && HasBit(ss->animation.triggers, trigger)) {
 
				CargoID cargo;
 
				if (!IsValidCargoID(cargo_type)) {
 
					cargo = CT_INVALID;
 
					cargo = INVALID_CARGO;
 
				} else {
 
					cargo = ss->grf_prop.grffile->cargo_map[cargo_type];
 
				}
src/newgrf_station.h
Show inline comments
 
@@ -36,7 +36,7 @@ struct StationScopeResolver : public Sco
 
	 * @param tile %Tile of the station.
 
	 */
 
	StationScopeResolver(ResolverObject &ro, const StationSpec *statspec, BaseStation *st, TileIndex tile)
 
		: ScopeResolver(ro), tile(tile), st(st), statspec(statspec), cargo_type(CT_INVALID), axis(INVALID_AXIS)
 
		: ScopeResolver(ro), tile(tile), st(st), statspec(statspec), cargo_type(INVALID_CARGO), axis(INVALID_AXIS)
 
	{
 
	}
 

	
 
@@ -198,8 +198,8 @@ void DeallocateSpecFromStation(BaseStati
 
bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station);
 

	
 
void AnimateStationTile(TileIndex tile);
 
void TriggerStationAnimation(BaseStation *st, TileIndex tile, StationAnimationTrigger trigger, CargoID cargo_type = CT_INVALID);
 
void TriggerStationRandomisation(Station *st, TileIndex tile, StationRandomTrigger trigger, CargoID cargo_type = CT_INVALID);
 
void TriggerStationAnimation(BaseStation *st, TileIndex tile, StationAnimationTrigger trigger, CargoID cargo_type = INVALID_CARGO);
 
void TriggerStationRandomisation(Station *st, TileIndex tile, StationRandomTrigger trigger, CargoID cargo_type = INVALID_CARGO);
 
void StationUpdateCachedTriggers(BaseStation *st);
 

	
 
#endif /* NEWGRF_STATION_H */
src/saveload/afterload.cpp
Show inline comments
 
@@ -3029,13 +3029,13 @@ bool AfterLoadGame()
 
		/* Make sure added industry cargo slots are cleared */
 
		for (Industry *i : Industry::Iterate()) {
 
			for (auto it = std::begin(i->produced) + 2; it != std::end(i->produced); ++it) {
 
				it->cargo = CT_INVALID;
 
				it->cargo = INVALID_CARGO;
 
				it->waiting = 0;
 
				it->rate = 0;
 
				it->history = {};
 
			}
 
			for (auto it = std::begin(i->accepted) + 3; it != std::end(i->accepted); ++it) {
 
				it->cargo = CT_INVALID;
 
				it->cargo = INVALID_CARGO;
 
				it->waiting = 0;
 
			}
 
			/* Make sure last_cargo_accepted_at is copied to elements for every valid input cargo.
src/script/api/script_cargo.hpp
Show inline comments
 
@@ -57,7 +57,7 @@ public:
 
		/* Note: these values represent part of the in-game CargoTypes enum */
 
		CT_AUTO_REFIT = ::CT_AUTO_REFIT, ///< Automatically choose cargo type when doing auto-refitting.
 
		CT_NO_REFIT   = ::CT_NO_REFIT,   ///< Do not refit cargo of a vehicle.
 
		CT_INVALID    = ::CT_INVALID,    ///< An invalid cargo type.
 
		CT_INVALID    = ::INVALID_CARGO, ///< An invalid cargo type.
 
	};
 

	
 
	/**
src/script/api/script_engine.cpp
Show inline comments
 
@@ -52,12 +52,12 @@
 

	
 
/* static */ CargoID ScriptEngine::GetCargoType(EngineID engine_id)
 
{
 
	if (!IsValidEngine(engine_id)) return CT_INVALID;
 
	if (!IsValidEngine(engine_id)) return INVALID_CARGO;
 

	
 
	CargoArray cap = ::GetCapacityOfArticulatedParts(engine_id);
 

	
 
	auto it = std::max_element(std::cbegin(cap), std::cend(cap));
 
	if (*it == 0) return CT_INVALID;
 
	if (*it == 0) return INVALID_CARGO;
 

	
 
	return CargoID(std::distance(std::cbegin(cap), it));
 
}
src/script/api/script_event_types.cpp
Show inline comments
 
@@ -39,11 +39,11 @@ std::optional<std::string> ScriptEventEn
 

	
 
CargoID ScriptEventEnginePreview::GetCargoType()
 
{
 
	if (!this->IsEngineValid()) return CT_INVALID;
 
	if (!this->IsEngineValid()) return INVALID_CARGO;
 
	CargoArray cap = ::GetCapacityOfArticulatedParts(this->engine);
 

	
 
	auto it = std::max_element(std::cbegin(cap), std::cend(cap));
 
	if (*it == 0) return CT_INVALID;
 
	if (*it == 0) return INVALID_CARGO;
 

	
 
	return CargoID(std::distance(std::cbegin(cap), it));
 
}
src/script/api/script_industry.hpp
Show inline comments
 
@@ -257,9 +257,9 @@ public:
 
	/**
 
	 * Get the last date this industry accepted any cargo delivery.
 
	 * @param industry_id The index of the industry.
 
	 * @param cargo_type The cargo to query, or CT_INVALID to query latest of all accepted cargoes.
 
	 * @param cargo_type The cargo to query, or INVALID_CARGO to query latest of all accepted cargoes.
 
	 * @pre IsValidIndustry(industry_id).
 
	 * @pre IsValidCargo(cargo_type) || cargo_type == CT_INVALID.
 
	 * @pre IsValidCargo(cargo_type) || cargo_type == INVALID_CARGO.
 
	 * @return Date the industry last received cargo from a delivery, or ScriptDate::DATE_INVALID on error.
 
	 * @api -ai
 
	 */
src/script/api/script_subsidy.cpp
Show inline comments
 
@@ -67,7 +67,7 @@
 

	
 
/* static */ CargoID ScriptSubsidy::GetCargoType(SubsidyID subsidy_id)
 
{
 
	if (!IsValidSubsidy(subsidy_id)) return CT_INVALID;
 
	if (!IsValidSubsidy(subsidy_id)) return INVALID_CARGO;
 

	
 
	return ::Subsidy::Get(subsidy_id)->cargo_type;
 
}
src/script/api/script_vehicle.cpp
Show inline comments
 
@@ -89,7 +89,7 @@
 

	
 
/* static */ VehicleID ScriptVehicle::BuildVehicle(TileIndex depot, EngineID engine_id)
 
{
 
	return _BuildVehicleInternal(depot, engine_id, CT_INVALID);
 
	return _BuildVehicleInternal(depot, engine_id, INVALID_CARGO);
 
}
 

	
 
/* static */ VehicleID ScriptVehicle::BuildVehicleWithRefit(TileIndex depot, EngineID engine_id, CargoID cargo)
src/station_gui.cpp
Show inline comments
 
@@ -1750,7 +1750,7 @@ struct StationViewWindow : public Window
 
	 * @param cargo Current cargo being drawn (if cargo column has been passed).
 
	 * @return row (in "pos" counting) after the one we have last drawn to.
 
	 */
 
	int DrawEntries(CargoDataEntry *entry, const Rect &r, int pos, int maxrows, int column, CargoID cargo = CT_INVALID)
 
	int DrawEntries(CargoDataEntry *entry, const Rect &r, int pos, int maxrows, int column, CargoID cargo = INVALID_CARGO)
 
	{
 
		if (this->sortings[column] == CargoSortType::AsGrouping) {
 
			if (this->groupings[column] != GR_CARGO) {
src/subsidy_base.h
Show inline comments
 
@@ -20,7 +20,7 @@ extern SubsidyPool _subsidy_pool;
 

	
 
/** Struct about subsidies, offered and awarded */
 
struct Subsidy : SubsidyPool::PoolItem<&_subsidy_pool> {
 
	CargoID cargo_type;  ///< Cargo type involved in this subsidy, CT_INVALID for invalid subsidy
 
	CargoID cargo_type;  ///< Cargo type involved in this subsidy, INVALID_CARGO for invalid subsidy
 
	uint16_t remaining;    ///< Remaining months when this subsidy is valid
 
	CompanyID awarded;   ///< Subsidy is awarded to this company; INVALID_COMPANY if it's not awarded to anyone
 
	SourceType src_type; ///< Source of subsidised path (SourceType::Industry or SourceType::Town)
src/train_gui.cpp
Show inline comments
 
@@ -273,7 +273,7 @@ static void GetCargoSummaryOfArticulated
 
		if (!v->GetEngine()->CanCarryCargo()) continue;
 

	
 
		CargoSummaryItem new_item;
 
		new_item.cargo = v->cargo_cap > 0 ? v->cargo_type : (CargoID)CT_INVALID;
 
		new_item.cargo = v->cargo_cap > 0 ? v->cargo_type : INVALID_CARGO;
 
		new_item.subtype = GetCargoSubtypeText(v);
 
		if (!IsValidCargoID(new_item.cargo) && new_item.subtype == STR_EMPTY) continue;
 

	
src/vehicle.cpp
Show inline comments
 
@@ -1902,7 +1902,7 @@ bool CanBuildVehicleInfrastructure(Vehic
 
 */
 
LiveryScheme GetEngineLiveryScheme(EngineID engine_type, EngineID parent_engine_type, const Vehicle *v)
 
{
 
	CargoID cargo_type = v == nullptr ? (CargoID)CT_INVALID : v->cargo_type;
 
	CargoID cargo_type = v == nullptr ? INVALID_CARGO : v->cargo_type;
 
	const Engine *e = Engine::Get(engine_type);
 
	switch (e->type) {
 
		default: NOT_REACHED();
src/vehicle_cmd.cpp
Show inline comments
 
@@ -874,7 +874,7 @@ std::tuple<CommandCost, VehicleID> CmdCl
 
		if ((flags & DC_EXEC) && !v->IsPrimaryVehicle()) build_flags |= DC_AUTOREPLACE;
 

	
 
		CommandCost cost;
 
		std::tie(cost, new_veh_id, std::ignore, std::ignore, std::ignore) = Command<CMD_BUILD_VEHICLE>::Do(build_flags, tile, v->engine_type, false, CT_INVALID, INVALID_CLIENT_ID);
 
		std::tie(cost, new_veh_id, std::ignore, std::ignore, std::ignore) = Command<CMD_BUILD_VEHICLE>::Do(build_flags, tile, v->engine_type, false, INVALID_CARGO, INVALID_CLIENT_ID);
 

	
 
		if (cost.Failed()) {
 
			/* Can't build a part, then sell the stuff we already made; clear up the mess */
 
@@ -953,7 +953,7 @@ std::tuple<CommandCost, VehicleID> CmdCl
 
				}
 
			} else {
 
				const Engine *e = v->GetEngine();
 
				CargoID initial_cargo = (e->CanCarryCargo() ? e->GetDefaultCargoType() : (CargoID)CT_INVALID);
 
				CargoID initial_cargo = (e->CanCarryCargo() ? e->GetDefaultCargoType() : INVALID_CARGO);
 

	
 
				if (v->cargo_type != initial_cargo && IsValidCargoID(initial_cargo)) {
 
					bool dummy;
src/vehicle_gui.cpp
Show inline comments
 
@@ -779,7 +779,7 @@ struct RefitWindow : public Window {
 
	{
 
		size_t scroll_row = 0;
 
		size_t rows = 0;
 
		CargoID cargo = this->selected_refit == nullptr ? (CargoID)CT_INVALID : this->selected_refit->cargo;
 
		CargoID cargo = this->selected_refit == nullptr ? INVALID_CARGO : this->selected_refit->cargo;
 

	
 
		for (const auto &pair : this->refit_list) {
 
			if (pair.first == cargo) {
src/vehicle_gui_base.h
Show inline comments
 
@@ -75,7 +75,7 @@ struct BaseVehicleListWindow : public Wi
 

	
 
	/** Special cargo filter criteria */
 
	enum CargoFilterSpecialType {
 
		CF_NONE = CT_INVALID,       ///< Show only vehicles which do not carry cargo (e.g. train engines)
 
		CF_NONE = INVALID_CARGO,    ///< Show only vehicles which do not carry cargo (e.g. train engines)
 
		CF_ANY = CT_NO_REFIT,       ///< Show all vehicles independent of carried cargo (i.e. no filtering)
 
		CF_FREIGHT = CT_AUTO_REFIT, ///< Show only vehicles which carry any freight (non-passenger) cargo
 
	};
0 comments (0 inline, 0 general)