Codechange: Split CT_INVALID into CT_INVALID and INVALID_CARGO.

INVALID_CARGO is a CargoID and should be used for most purposes in game.
CT_INVALID is a CargoType used for defining default properties.
This commit is contained in:
Peter Nelson 2024-01-06 15:15:37 +00:00 committed by Peter Nelson
parent 4fd986bd07
commit 952d111b94
36 changed files with 131 additions and 129 deletions

View File

@ -107,7 +107,7 @@ uint CountArticulatedParts(EngineID engine_type, bool purchase_window)
static inline uint16_t GetVehicleDefaultCapacity(EngineID engine, CargoID *cargo_type) static inline uint16_t GetVehicleDefaultCapacity(EngineID engine, CargoID *cargo_type)
{ {
const Engine *e = Engine::Get(engine); 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 (cargo_type != nullptr) *cargo_type = cargo;
if (!IsValidCargoID(cargo)) return 0; if (!IsValidCargoID(cargo)) return 0;
return e->GetDisplayDefaultCapacity(); return e->GetDisplayDefaultCapacity();
@ -259,13 +259,13 @@ CargoTypes GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial
* Get cargo mask of all cargoes carried by an articulated vehicle. * Get cargo mask of all cargoes carried by an articulated vehicle.
* Note: Vehicles not carrying anything are ignored * Note: Vehicles not carrying anything are ignored
* @param v the first vehicle in the chain * @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 * @return cargo mask, may be 0 if the no vehicle parts have cargo capacity
*/ */
CargoTypes GetCargoTypesOfArticulatedVehicle(const Vehicle *v, CargoID *cargo_type) CargoTypes GetCargoTypesOfArticulatedVehicle(const Vehicle *v, CargoID *cargo_type)
{ {
CargoTypes cargoes = 0; CargoTypes cargoes = 0;
CargoID first_cargo = CT_INVALID; CargoID first_cargo = INVALID_CARGO;
do { do {
if (IsValidCargoID(v->cargo_type) && v->GetEngine()->CanCarryCargo()) { if (IsValidCargoID(v->cargo_type) && v->GetEngine()->CanCarryCargo()) {
@ -273,7 +273,7 @@ CargoTypes GetCargoTypesOfArticulatedVehicle(const Vehicle *v, CargoID *cargo_ty
if (!IsValidCargoID(first_cargo)) first_cargo = v->cargo_type; if (!IsValidCargoID(first_cargo)) first_cargo = v->cargo_type;
if (first_cargo != v->cargo_type) { if (first_cargo != v->cargo_type) {
if (cargo_type != nullptr) { if (cargo_type != nullptr) {
*cargo_type = CT_INVALID; *cargo_type = INVALID_CARGO;
cargo_type = nullptr; cargo_type = nullptr;
} }
} }

View File

@ -227,7 +227,7 @@ static int GetIncompatibleRefitOrderIdForAutoreplace(const Vehicle *v, EngineID
* @param part_of_chain The vehicle is part of a train * @param part_of_chain The vehicle is part of a train
* @return The cargo type to replace to * @return The cargo type to replace to
* CT_NO_REFIT is returned if no refit is needed * 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) static CargoID GetNewCargoTypeForReplace(Vehicle *v, EngineID engine_type, bool part_of_chain)
{ {
@ -244,7 +244,7 @@ static CargoID GetNewCargoTypeForReplace(Vehicle *v, EngineID engine_type, bool
return CT_NO_REFIT; // engine_type is already a mixed cargo type which matches the incoming vehicle by default, no refit required 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)) { if (!IsValidCargoID(cargo_type)) {
@ -263,9 +263,9 @@ static CargoID GetNewCargoTypeForReplace(Vehicle *v, EngineID engine_type, bool
return CT_NO_REFIT; // We failed to find a cargo type on the old vehicle and we will not refit the new one return CT_NO_REFIT; // We failed to find a cargo type on the old vehicle and we will not refit the new one
} else { } 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; return cargo_type;
} }
@ -352,7 +352,7 @@ static CommandCost BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehic
/* Build the new vehicle */ /* Build the new vehicle */
VehicleID new_veh_id; 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; if (cost.Failed()) return cost;
Vehicle *new_veh = Vehicle::Get(new_veh_id); Vehicle *new_veh = Vehicle::Get(new_veh_id);

View File

@ -95,7 +95,7 @@ static const NWidgetPart _nested_build_vehicle_widgets[] = {
/** Special cargo filter criteria */ /** 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_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) 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. bool _engine_sort_direction; ///< \c false = descending, \c true = ascending.
@ -908,7 +908,7 @@ void TestedEngineDetails::FillDefaultCapacities(const Engine *e)
this->all_capacities[this->cargo] = this->capacity; this->all_capacities[this->cargo] = this->capacity;
this->all_capacities[CT_MAIL] = this->mail_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, int right, int y, EngineID engine_number,
int new_y = DrawCargoCapacityInfo(left, right, y, te, refittable); int new_y = DrawCargoCapacityInfo(left, right, y, te, refittable);
if (new_y == y) { if (new_y == y) {
SetDParam(0, CT_INVALID); SetDParam(0, INVALID_CARGO);
SetDParam(2, STR_EMPTY); SetDParam(2, STR_EMPTY);
DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY); DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY);
y += GetCharacterHeight(FS_NORMAL); y += GetCharacterHeight(FS_NORMAL);
@ -1293,7 +1293,7 @@ struct BuildVehicleWindow : Window {
void SelectEngine(EngineID engine) void SelectEngine(EngineID engine)
{ {
CargoID cargo = this->cargo_filter_criteria; 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->sel_engine = engine;
this->SetBuyVehicleText(); this->SetBuyVehicleText();
@ -1652,7 +1652,7 @@ struct BuildVehicleWindow : Window {
EngineID sel_eng = this->sel_engine; EngineID sel_eng = this->sel_engine;
if (sel_eng != INVALID_ENGINE) { if (sel_eng != INVALID_ENGINE) {
CargoID cargo = this->cargo_filter_criteria; 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) { 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); Command<CMD_BUILD_VEHICLE>::Post(GetCmdBuildVehMsg(this->vehicle_type), CcBuildWagon, this->window_number, sel_eng, true, cargo, INVALID_CLIENT_ID);
} else { } else {

View File

@ -69,10 +69,12 @@ enum CargoType {
CT_INVALID = 0xFF, ///< Invalid cargo type. CT_INVALID = 0xFF, ///< Invalid cargo type.
}; };
static const CargoID INVALID_CARGO = UINT8_MAX;
/** Test whether cargo type is not CT_INVALID */ /** Test whether cargo type is not CT_INVALID */
inline bool IsValidCargoType(CargoType t) { return t != CT_INVALID; } inline bool IsValidCargoType(CargoType t) { return t != CT_INVALID; }
/** Test whether cargo type is not CT_INVALID */ /** Test whether cargo type is not INVALID_CARGO */
inline bool IsValidCargoID(CargoID t) { return t != CT_INVALID; } inline bool IsValidCargoID(CargoID t) { return t != INVALID_CARGO; }
typedef uint64_t CargoTypes; typedef uint64_t CargoTypes;

View File

@ -88,13 +88,13 @@ Dimension GetLargestCargoIconSize()
* Get the cargo ID of a default cargo, if present. * Get the cargo ID of a default cargo, if present.
* @param l Landscape * @param l Landscape
* @param ct Default cargo type. * @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) CargoID GetDefaultCargoID(LandscapeID l, CargoType ct)
{ {
assert(l < lengthof(_default_climate_cargo)); 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])); assert(ct < lengthof(_default_climate_cargo[0]));
CargoLabel cl = _default_climate_cargo[l][ct]; CargoLabel cl = _default_climate_cargo[l][ct];
@ -109,7 +109,7 @@ CargoID GetDefaultCargoID(LandscapeID l, CargoType ct)
/** /**
* Get the cargo ID by cargo label. * Get the cargo ID by cargo label.
* @param cl Cargo type to get. * @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) CargoID GetCargoIDByLabel(CargoLabel cl)
{ {
@ -118,25 +118,25 @@ CargoID GetCargoIDByLabel(CargoLabel cl)
} }
/* No matching label was found, so it is invalid */ /* No matching label was found, so it is invalid */
return CT_INVALID; return INVALID_CARGO;
} }
/** /**
* Find the CargoID of a 'bitnum' value. * Find the CargoID of a 'bitnum' value.
* @param bitnum 'bitnum' to find. * @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) 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()) { for (const CargoSpec *cs : CargoSpec::Iterate()) {
if (cs->bitnum == bitnum) return cs->Index(); if (cs->bitnum == bitnum) return cs->Index();
} }
/* No matching label was found, so it is invalid */ /* No matching label was found, so it is invalid */
return CT_INVALID; return INVALID_CARGO;
} }
/** /**

View File

@ -85,8 +85,8 @@ Engine::Engine(VehicleType type, EngineID base)
this->info.base_life = 0xFF; this->info.base_life = 0xFF;
/* Set road vehicle tractive effort to the default value */ /* Set road vehicle tractive effort to the default value */
if (type == VEH_ROAD) this->u.road.tractive_effort = 0x4C; if (type == VEH_ROAD) this->u.road.tractive_effort = 0x4C;
/* Aircraft must have CT_INVALID as default, as there is no property */ /* Aircraft must have INVALID_CARGO as default, as there is no property */
if (type == VEH_AIRCRAFT) this->info.cargo_type = CT_INVALID; if (type == VEH_AIRCRAFT) this->info.cargo_type = INVALID_CARGO;
/* Set visual effect to the default value */ /* Set visual effect to the default value */
switch (type) { switch (type) {
case VEH_TRAIN: this->u.rail.visual_effect = VE_DEFAULT; break; case VEH_TRAIN: this->u.rail.visual_effect = VE_DEFAULT; break;

View File

@ -88,7 +88,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
* 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 * 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.. * 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. * @return The default cargo type.
* @see CanCarryCargo * @see CanCarryCargo

View File

@ -183,7 +183,7 @@ static StringID GetTrainEngineInfoString(const Engine *e)
SetDParam(5, e->GetDefaultCargoType()); SetDParam(5, e->GetDefaultCargoType());
SetDParam(6, capacity); SetDParam(6, capacity);
} else { } 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; 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 GetRoadVehEngineInfoString(const Engine *e)
SetDParam(2, e->GetDefaultCargoType()); SetDParam(2, e->GetDefaultCargoType());
SetDParam(3, capacity); SetDParam(3, capacity);
} else { } else {
SetDParam(2, CT_INVALID); SetDParam(2, INVALID_CARGO);
} }
SetDParam(4, e->GetRunningCost()); SetDParam(4, e->GetRunningCost());
return STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAP_RUNCOST; return STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAP_RUNCOST;
@ -242,7 +242,7 @@ static StringID GetRoadVehEngineInfoString(const Engine *e)
SetDParam(5, e->GetDefaultCargoType()); SetDParam(5, e->GetDefaultCargoType());
SetDParam(6, capacity); SetDParam(6, capacity);
} else { } else {
SetDParam(5, CT_INVALID); SetDParam(5, INVALID_CARGO);
} }
return STR_ENGINE_PREVIEW_COST_WEIGHT_SPEED_POWER_MAX_TE; return STR_ENGINE_PREVIEW_COST_WEIGHT_SPEED_POWER_MAX_TE;
} }

View File

@ -424,7 +424,7 @@ static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray &acceptance, Ca
auto pos = std::find(std::begin(accepts_cargo), std::end(accepts_cargo), a.cargo); auto pos = std::find(std::begin(accepts_cargo), std::end(accepts_cargo), a.cargo);
if (pos == std::end(accepts_cargo)) { if (pos == std::end(accepts_cargo)) {
/* Not found, insert */ /* 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 if (pos == std::end(accepts_cargo)) continue; // nowhere to place, give up on this one
*pos = a.cargo; *pos = a.cargo;
} }
@ -436,7 +436,7 @@ static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray &acceptance, Ca
/* Try callback for accepts list, if success override all existing accepts */ /* 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); uint16_t res = GetIndustryTileCallback(CBID_INDTILE_ACCEPT_CARGO, 0, 0, gfx, Industry::GetByTile(tile), tile);
if (res != CALLBACK_FAILED) { 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); 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 *i, TileIndex tile, IndustryType type,
if (HasBit(indspec->callback_mask, CBM_IND_INPUT_CARGO_TYPES)) { if (HasBit(indspec->callback_mask, CBM_IND_INPUT_CARGO_TYPES)) {
/* Clear all 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 */ /* Query actual types */
uint maxcargoes = (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) ? static_cast<uint>(i->accepted.size()) : 3; uint maxcargoes = (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) ? static_cast<uint>(i->accepted.size()) : 3;
for (uint j = 0; j < maxcargoes; j++) { for (uint j = 0; j < maxcargoes; j++) {
@ -1870,7 +1870,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
if (HasBit(indspec->callback_mask, CBM_IND_OUTPUT_CARGO_TYPES)) { if (HasBit(indspec->callback_mask, CBM_IND_OUTPUT_CARGO_TYPES)) {
/* Clear all 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 */ /* Query actual types */
uint maxcargoes = (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) ? static_cast<uint>(i->produced.size()) : 2; uint maxcargoes = (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) ? static_cast<uint>(i->produced.size()) : 2;
for (uint j = 0; j < maxcargoes; j++) { for (uint j = 0; j < maxcargoes; j++) {

View File

@ -148,7 +148,7 @@ enum CargoSuffixInOut {
* @param ind the industry (nullptr if in fund window) * @param ind the industry (nullptr if in fund window)
* @param ind_type the industry type * @param ind_type the industry type
* @param indspec the industry spec * @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 * @param suffixes is filled with the suffixes
*/ */
template <typename TC, typename TS> template <typename TC, typename TS>
@ -197,7 +197,7 @@ static inline void GetAllCargoSuffixes(CargoSuffixInOut use_input, CargoSuffixTy
* @param ind the industry (nullptr if in fund window) * @param ind the industry (nullptr if in fund window)
* @param ind_type the industry type * @param ind_type the industry type
* @param indspec the industry spec * @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 slot accepts/produced slot number, used for old-style 3-in/2-out industries.
* @param suffix is filled with the suffix * @param suffix is filled with the suffix
*/ */
@ -1248,7 +1248,7 @@ typedef GUIList<const Industry *, const CargoID &, const std::pair<CargoID, Carg
/** Special cargo filter criteria */ /** Special cargo filter criteria */
enum CargoFilterSpecialType { enum CargoFilterSpecialType {
CF_ANY = CT_NO_REFIT, ///< Show all industries (i.e. no filtering) 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 */ /** Cargo filter functions */
@ -1995,15 +1995,15 @@ struct CargoesField {
CargoID other_accepted[MAX_CARGOES]; ///< Cargoes accepted but not used in this figure. CargoID other_accepted[MAX_CARGOES]; ///< Cargoes accepted but not used in this figure.
} industry; ///< Industry data (for #CFT_INDUSTRY). } industry; ///< Industry data (for #CFT_INDUSTRY).
struct { 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. 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. 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. uint8_t bottom_end; ///< Stop at the bottom of the vertical cargoes.
} cargo; ///< Cargo data (for #CFT_CARGO). } cargo; ///< Cargo data (for #CFT_CARGO).
struct { 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). bool left_align; ///< Align all cargo texts to the left (else align to the right).
} cargo_label; ///< Label data (for #CFT_CARGO_LABEL). } cargo_label; ///< Label data (for #CFT_CARGO_LABEL).
StringID header; ///< Header text (for #CFT_HEADER). StringID header; ///< Header text (for #CFT_HEADER).
@ -2027,8 +2027,8 @@ struct CargoesField {
{ {
this->type = CFT_INDUSTRY; this->type = CFT_INDUSTRY;
this->u.industry.ind_type = ind_type; 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_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), CT_INVALID); 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. * 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 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 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. * @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; this->u.cargo.num_cargoes = (count < 0) ? static_cast<uint8_t>(insert - std::begin(this->u.cargo.vertical_cargoes)) : count;
CargoIDComparator comparator; CargoIDComparator comparator;
std::sort(std::begin(this->u.cargo.vertical_cargoes), insert, 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.top_end = top_end;
this->u.cargo.bottom_end = bottom_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.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), CT_INVALID); 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. * 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 length Number of cargoes in \a cargoes.
* @param left_align ALign texts to the left (else to the right). * @param left_align ALign texts to the left (else to the right).
*/ */
@ -2117,7 +2117,7 @@ struct CargoesField {
this->type = CFT_CARGO_LABEL; this->type = CFT_CARGO_LABEL;
uint i; uint i;
for (i = 0; i < MAX_CARGOES && i < length; i++) this->u.cargo_label.cargoes[i] = cargoes[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; 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 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 right Right industry neighbour if available (else \c nullptr should be supplied).
* @param pt Click position in the cargo field. * @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 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; int vpos = vert_inter_industry_space / 2 + CargoesField::cargo_border.width;
uint row; uint row;
for (row = 0; row < MAX_CARGOES; 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; if (pt.y < vpos + GetCharacterHeight(FS_NORMAL)) break;
vpos += GetCharacterHeight(FS_NORMAL) + CargoesField::cargo_space.width; 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. */ /* row = 0 -> at first horizontal row, row = 1 -> second horizontal row, 2 = 3rd horizontal row. */
if (col == 0) { 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_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]; 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 (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]]; 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_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]; 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) { if (row >= col) {
/* Clicked somewhere in-between vertical cargo connection. /* 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. * 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]]; 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. */ /* 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]]; 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. * Decide what cargo the user clicked in the cargo label field.
* @param pt Click position 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 CargoID CargoLabelClickedAt(Point pt) const
{ {
@ -2357,11 +2357,11 @@ struct CargoesField {
int vpos = vert_inter_industry_space / 2 + CargoesField::cargo_border.height; int vpos = vert_inter_industry_space / 2 + CargoesField::cargo_border.height;
uint row; uint row;
for (row = 0; row < MAX_CARGOES; 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; if (pt.y < vpos + GetCharacterHeight(FS_NORMAL)) break;
vpos += GetCharacterHeight(FS_NORMAL) + CargoesField::cargo_space.height; 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]; return this->u.cargo_label.cargoes[row];
} }
@ -2416,7 +2416,7 @@ struct CargoesRow {
CargoesField *cargo_fld = this->columns + column + 1; CargoesField *cargo_fld = this->columns + column + 1;
assert(ind_fld->type == CFT_INDUSTRY && cargo_fld->type == CFT_CARGO); 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) { if (ind_fld->u.industry.ind_type < NUM_INDUSTRYTYPES) {
CargoID others[MAX_CARGOES]; // Produced cargoes not carried in the cargo column. CargoID others[MAX_CARGOES]; // Produced cargoes not carried in the cargo column.
@ -2450,7 +2450,7 @@ struct CargoesRow {
void MakeCargoLabel(int column, bool accepting) void MakeCargoLabel(int column, bool accepting)
{ {
CargoID cargoes[MAX_CARGOES]; 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 *label_fld = this->columns + column;
CargoesField *cargo_fld = this->columns + (accepting ? column - 1 : column + 1); CargoesField *cargo_fld = this->columns + (accepting ? column - 1 : column + 1);
@ -2474,7 +2474,7 @@ struct CargoesRow {
CargoesField *cargo_fld = this->columns + column - 1; CargoesField *cargo_fld = this->columns + column - 1;
assert(ind_fld->type == CFT_INDUSTRY && cargo_fld->type == CFT_CARGO); 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) { if (ind_fld->u.industry.ind_type < NUM_INDUSTRYTYPES) {
CargoID others[MAX_CARGOES]; // Accepted cargoes not carried in the cargo column. CargoID others[MAX_CARGOES]; // Accepted cargoes not carried in the cargo column.
@ -3157,7 +3157,7 @@ struct IndustryCargoesWindow : public Window {
if (!CalculatePositionInWidget(pt, &fieldxy, &xy)) return false; if (!CalculatePositionInWidget(pt, &fieldxy, &xy)) return false;
const CargoesField *fld = this->fields[fieldxy.y].columns + fieldxy.x; const CargoesField *fld = this->fields[fieldxy.y].columns + fieldxy.x;
CargoID cid = CT_INVALID; CargoID cid = INVALID_CARGO;
switch (fld->type) { switch (fld->type) {
case CFT_CARGO: { case CFT_CARGO: {
CargoesField *lft = (fieldxy.x > 0) ? this->fields[fieldxy.y].columns + fieldxy.x - 1 : nullptr; CargoesField *lft = (fieldxy.x > 0) ? this->fields[fieldxy.y].columns + fieldxy.x - 1 : nullptr;

View File

@ -189,7 +189,7 @@ public:
} }
/** Bare constructor, only for save/load. */ /** Bare constructor, only for save/load. */
LinkGraph() : cargo(CT_INVALID), last_compression(0) {} LinkGraph() : cargo(INVALID_CARGO), last_compression(0) {}
/** /**
* Real constructor. * Real constructor.
* @param cargo Cargo the link graph is about. * @param cargo Cargo the link graph is about.

View File

@ -21,7 +21,7 @@
* Only the cargo type of the most saturated linkgraph is taken into account. * Only the cargo type of the most saturated linkgraph is taken into account.
*/ */
struct LinkProperties { 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. */ /** Return the usage of the link to display. */
uint Usage() const { return std::max(this->usage, this->planned); } uint Usage() const { return std::max(this->usage, this->planned); }

View File

@ -67,7 +67,7 @@ bool LinkRefresher::Hop::operator<(const Hop &other) const
* @param is_full_loading If the vehicle is full loading. * @param is_full_loading If the vehicle is full loading.
*/ */
LinkRefresher::LinkRefresher(Vehicle *vehicle, HopSet *seen_hops, bool allow_merge, bool 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) is_full_loading(is_full_loading)
{ {
memset(this->capacities, 0, sizeof(this->capacities)); memset(this->capacities, 0, sizeof(this->capacities));

View File

@ -56,7 +56,7 @@ protected:
struct Hop { struct Hop {
OrderID from; ///< Last order where vehicle could interact with cargo or absolute first order. OrderID from; ///< Last order where vehicle could interact with cargo or absolute first order.
OrderID to; ///< Next order to be processed. 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 * Default constructor should not be called but has to be visible for

View File

@ -1140,15 +1140,15 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop
if (ctype == 0xFF) { if (ctype == 0xFF) {
/* 0xFF is specified as 'use first refittable' */ /* 0xFF is specified as 'use first refittable' */
ei->cargo_type = CT_INVALID; ei->cargo_type = INVALID_CARGO;
} else if (_cur.grffile->grf_version >= 8) { } 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); ei->cargo_type = GetCargoTranslation(ctype, _cur.grffile);
} else if (ctype < NUM_CARGO) { } else if (ctype < NUM_CARGO) {
/* Use untranslated cargo. */ /* Use untranslated cargo. */
ei->cargo_type = ctype; ei->cargo_type = ctype;
} else { } else {
ei->cargo_type = CT_INVALID; ei->cargo_type = INVALID_CARGO;
GrfMsg(2, "RailVehicleChangeInfo: Invalid cargo type {}, using first refittable", ctype); GrfMsg(2, "RailVehicleChangeInfo: Invalid cargo type {}, using first refittable", ctype);
} }
break; break;
@ -1401,15 +1401,15 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop
if (ctype == 0xFF) { if (ctype == 0xFF) {
/* 0xFF is specified as 'use first refittable' */ /* 0xFF is specified as 'use first refittable' */
ei->cargo_type = CT_INVALID; ei->cargo_type = INVALID_CARGO;
} else if (_cur.grffile->grf_version >= 8) { } 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); ei->cargo_type = GetCargoTranslation(ctype, _cur.grffile);
} else if (ctype < NUM_CARGO) { } else if (ctype < NUM_CARGO) {
/* Use untranslated cargo. */ /* Use untranslated cargo. */
ei->cargo_type = ctype; ei->cargo_type = ctype;
} else { } else {
ei->cargo_type = CT_INVALID; ei->cargo_type = INVALID_CARGO;
GrfMsg(2, "RailVehicleChangeInfo: Invalid cargo type {}, using first refittable", ctype); GrfMsg(2, "RailVehicleChangeInfo: Invalid cargo type {}, using first refittable", ctype);
} }
break; break;
@ -1596,15 +1596,15 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop
if (ctype == 0xFF) { if (ctype == 0xFF) {
/* 0xFF is specified as 'use first refittable' */ /* 0xFF is specified as 'use first refittable' */
ei->cargo_type = CT_INVALID; ei->cargo_type = INVALID_CARGO;
} else if (_cur.grffile->grf_version >= 8) { } 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); ei->cargo_type = GetCargoTranslation(ctype, _cur.grffile);
} else if (ctype < NUM_CARGO) { } else if (ctype < NUM_CARGO) {
/* Use untranslated cargo. */ /* Use untranslated cargo. */
ei->cargo_type = ctype; ei->cargo_type = ctype;
} else { } else {
ei->cargo_type = CT_INVALID; ei->cargo_type = INVALID_CARGO;
GrfMsg(2, "ShipVehicleChangeInfo: Invalid cargo type {}, using first refittable", ctype); GrfMsg(2, "ShipVehicleChangeInfo: Invalid cargo type {}, using first refittable", ctype);
} }
break; break;
@ -2588,7 +2588,7 @@ static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, Byt
housespec->accepts_cargo[i] = GetCargoTranslation(buf->ReadByte(), _cur.grffile); housespec->accepts_cargo[i] = GetCargoTranslation(buf->ReadByte(), _cur.grffile);
housespec->cargo_acceptance[i] = buf->ReadByte(); housespec->cargo_acceptance[i] = buf->ReadByte();
} else { } else {
housespec->accepts_cargo[i] = CT_INVALID; housespec->accepts_cargo[i] = INVALID_CARGO;
housespec->cargo_acceptance[i] = 0; housespec->cargo_acceptance[i] = 0;
} }
} }
@ -3306,7 +3306,7 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint indtid, int numinfo, int pr
/* Tile acceptance can be negative to counteract the INDTILE_SPECIAL_ACCEPTS_ALL_CARGO flag */ /* Tile acceptance can be negative to counteract the INDTILE_SPECIAL_ACCEPTS_ALL_CARGO flag */
tsp->acceptance[i] = (int8_t)buf->ReadByte(); tsp->acceptance[i] = (int8_t)buf->ReadByte();
} else { } else {
tsp->accepts_cargo[i] = CT_INVALID; tsp->accepts_cargo[i] = INVALID_CARGO;
tsp->acceptance[i] = 0; tsp->acceptance[i] = 0;
} }
} }
@ -3753,7 +3753,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop,
CargoID cargo = GetCargoTranslation(buf->ReadByte(), _cur.grffile); CargoID cargo = GetCargoTranslation(buf->ReadByte(), _cur.grffile);
indsp->produced_cargo[i] = cargo; indsp->produced_cargo[i] = cargo;
} else { } else {
indsp->produced_cargo[i] = CT_INVALID; indsp->produced_cargo[i] = INVALID_CARGO;
} }
} }
break; break;
@ -3771,7 +3771,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop,
CargoID cargo = GetCargoTranslation(buf->ReadByte(), _cur.grffile); CargoID cargo = GetCargoTranslation(buf->ReadByte(), _cur.grffile);
indsp->accepts_cargo[i] = cargo; indsp->accepts_cargo[i] = cargo;
} else { } else {
indsp->accepts_cargo[i] = CT_INVALID; indsp->accepts_cargo[i] = INVALID_CARGO;
} }
} }
break; break;
@ -5515,7 +5515,7 @@ static CargoID TranslateCargo(uint8_t feature, uint8_t ctype)
/* No cargo table, so use bitnum values */ /* No cargo table, so use bitnum values */
if (ctype >= 32) { if (ctype >= 32) {
GrfMsg(1, "TranslateCargo: Cargo bitnum {} out of range (max 31), skipping.", ctype); GrfMsg(1, "TranslateCargo: Cargo bitnum {} out of range (max 31), skipping.", ctype);
return CT_INVALID; return INVALID_CARGO;
} }
for (const CargoSpec *cs : CargoSpec::Iterate()) { for (const CargoSpec *cs : CargoSpec::Iterate()) {
@ -5526,30 +5526,30 @@ static CargoID TranslateCargo(uint8_t feature, uint8_t ctype)
} }
GrfMsg(5, "TranslateCargo: Cargo bitnum {} not available in this climate, skipping.", ctype); 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 */ /* Check if the cargo type is out of bounds of the cargo translation table */
if (ctype >= _cur.grffile->cargo_list.size()) { 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); 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 */ /* Look up the cargo label from the translation table */
CargoLabel cl = _cur.grffile->cargo_list[ctype]; CargoLabel cl = _cur.grffile->cargo_list[ctype];
if (cl == 0) { if (cl == 0) {
GrfMsg(5, "TranslateCargo: Cargo type {} not available in this climate, skipping.", ctype); GrfMsg(5, "TranslateCargo: Cargo type {} not available in this climate, skipping.", ctype);
return CT_INVALID; return INVALID_CARGO;
} }
ctype = GetCargoIDByLabel(cl); CargoID cid = GetCargoIDByLabel(cl);
if (!IsValidCargoID(ctype)) { 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)); 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; 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), ctype); 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 ctype; return cid;
} }
@ -5612,8 +5612,8 @@ static void VehicleMapSpriteGroup(ByteReader *buf, byte feature, uint8_t idcount
GrfMsg(8, "VehicleMapSpriteGroup: * [{}] Cargo type 0x{:X}, group id 0x{:02X}", c, ctype, groupid); GrfMsg(8, "VehicleMapSpriteGroup: * [{}] Cargo type 0x{:X}, group id 0x{:02X}", c, ctype, groupid);
ctype = TranslateCargo(feature, ctype); CargoID cid = TranslateCargo(feature, ctype);
if (!IsValidCargoID(ctype)) continue; if (!IsValidCargoID(cid)) continue;
for (uint i = 0; i < idcount; i++) { for (uint i = 0; i < idcount; i++) {
EngineID engine = engines[i]; EngineID engine = engines[i];
@ -5621,9 +5621,9 @@ static void VehicleMapSpriteGroup(ByteReader *buf, byte feature, uint8_t idcount
GrfMsg(7, "VehicleMapSpriteGroup: [{}] Engine {}...", i, engine); GrfMsg(7, "VehicleMapSpriteGroup: [{}] Engine {}...", i, engine);
if (wagover) { 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 { } 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) */ /* 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. /* 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. */ * 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)) { 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 /* Check if this engine's cargo type is valid. If not, set to the first refittable

View File

@ -85,8 +85,8 @@ private:
}; };
void AnimateAirportTile(TileIndex tile); void AnimateAirportTile(TileIndex tile);
void AirportTileAnimationTrigger(Station *st, TileIndex tile, 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 = CT_INVALID); void AirportAnimationTrigger(Station *st, AirpAnimationTrigger trigger, CargoID cargo_type = INVALID_CARGO);
bool DrawNewAirportTile(TileInfo *ti, Station *st, const AirportTileSpec *airts); bool DrawNewAirportTile(TileInfo *ti, Station *st, const AirportTileSpec *airts);
#endif /* NEWGRF_AIRPORTTILES_H */ #endif /* NEWGRF_AIRPORTTILES_H */

View File

@ -74,13 +74,13 @@ uint16_t GetCargoCallback(CallbackID callback, uint32_t param1, uint32_t param2,
* @param usebit Defines the meaning of \a cargo for GRF version < 7. * @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. * 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. * 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) 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 */ /* 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 (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; return cargo;
} }
@ -94,5 +94,5 @@ CargoID GetCargoTranslation(uint8_t cargo, const GRFFile *grffile, bool usebit)
/* Else the cargo value is a 'climate independent' 'bitnum' */ /* Else the cargo value is a 'climate independent' 'bitnum' */
return GetCargoIDByBitnum(cargo); return GetCargoIDByBitnum(cargo);
} }
return CT_INVALID; return INVALID_CARGO;
} }

View File

@ -451,8 +451,8 @@ static uint32_t VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *objec
/* Pick the most common cargo type */ /* Pick the most common cargo type */
auto cargo_it = std::max_element(std::begin(common_cargoes), std::end(common_cargoes)); auto cargo_it = std::max_element(std::begin(common_cargoes), std::end(common_cargoes));
/* Return CT_INVALID if nothing is carried */ /* Return INVALID_CARGO 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)); 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 */ /* Count subcargo types of common_cargo_type */
std::array<uint8_t, UINT8_MAX + 1> common_subtypes{}; std::array<uint8_t, UINT8_MAX + 1> common_subtypes{};
@ -486,7 +486,7 @@ static uint32_t VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *objec
* And this is only done by CheckCaches(). * And this is only done by CheckCaches().
*/ */
const GRFFile *grffile = object->ro.grffile; 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]; (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; return (v->grf_cache.consist_cargo_information & 0xFFFF00FF) | common_bitnum << 8;

View File

@ -347,7 +347,7 @@ void TriggerRoadStopAnimation(BaseStation *st, TileIndex trigger_tile, StationAn
if (ss != nullptr && HasBit(ss->animation.triggers, trigger)) { if (ss != nullptr && HasBit(ss->animation.triggers, trigger)) {
CargoID cargo; CargoID cargo;
if (!IsValidCargoID(cargo_type)) { if (!IsValidCargoID(cargo_type)) {
cargo = CT_INVALID; cargo = INVALID_CARGO;
} else { } else {
cargo = ss->grf_prop.grffile->cargo_map[cargo_type]; cargo = ss->grf_prop.grffile->cargo_map[cargo_type];
} }

View File

@ -169,8 +169,8 @@ uint16_t GetRoadStopCallback(CallbackID callback, uint32_t param1, uint32_t para
void AnimateRoadStopTile(TileIndex tile); void AnimateRoadStopTile(TileIndex tile);
uint8_t GetRoadStopTileAnimationSpeed(TileIndex tile); uint8_t GetRoadStopTileAnimationSpeed(TileIndex tile);
void TriggerRoadStopAnimation(BaseStation *st, TileIndex tile, StationAnimationTrigger 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 = CT_INVALID); void TriggerRoadStopRandomisation(Station *st, TileIndex tile, RoadStopRandomTrigger trigger, CargoID cargo_type = INVALID_CARGO);
bool GetIfNewStopsByType(RoadStopType rs, RoadType roadtype); bool GetIfNewStopsByType(RoadStopType rs, RoadType roadtype);
bool GetIfClassHasNewStopsByType(RoadStopClass *roadstopclass, RoadStopType rs, RoadType roadtype); bool GetIfClassHasNewStopsByType(RoadStopClass *roadstopclass, RoadStopType rs, RoadType roadtype);

View File

@ -495,7 +495,7 @@ uint32_t Waypoint::GetNewGRFVariable(const ResolverObject &, byte variable, [[ma
const Station *st = Station::From(this->station_scope.st); const Station *st = Station::From(this->station_scope.st);
switch (this->station_scope.cargo_type) { switch (this->station_scope.cargo_type) {
case CT_INVALID: case INVALID_CARGO:
case CT_DEFAULT_NA: case CT_DEFAULT_NA:
case CT_PURCHASE: case CT_PURCHASE:
cargo = 0; cargo = 0;
@ -887,7 +887,7 @@ void TriggerStationAnimation(BaseStation *st, TileIndex trigger_tile, StationAni
if (ss != nullptr && HasBit(ss->animation.triggers, trigger)) { if (ss != nullptr && HasBit(ss->animation.triggers, trigger)) {
CargoID cargo; CargoID cargo;
if (!IsValidCargoID(cargo_type)) { if (!IsValidCargoID(cargo_type)) {
cargo = CT_INVALID; cargo = INVALID_CARGO;
} else { } else {
cargo = ss->grf_prop.grffile->cargo_map[cargo_type]; cargo = ss->grf_prop.grffile->cargo_map[cargo_type];
} }

View File

@ -36,7 +36,7 @@ struct StationScopeResolver : public ScopeResolver {
* @param tile %Tile of the station. * @param tile %Tile of the station.
*/ */
StationScopeResolver(ResolverObject &ro, const StationSpec *statspec, BaseStation *st, TileIndex tile) 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(BaseStation *st, byte specindex);
bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station); bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station);
void AnimateStationTile(TileIndex tile); void AnimateStationTile(TileIndex tile);
void TriggerStationAnimation(BaseStation *st, TileIndex tile, StationAnimationTrigger 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 = CT_INVALID); void TriggerStationRandomisation(Station *st, TileIndex tile, StationRandomTrigger trigger, CargoID cargo_type = INVALID_CARGO);
void StationUpdateCachedTriggers(BaseStation *st); void StationUpdateCachedTriggers(BaseStation *st);
#endif /* NEWGRF_STATION_H */ #endif /* NEWGRF_STATION_H */

View File

@ -3029,13 +3029,13 @@ bool AfterLoadGame()
/* Make sure added industry cargo slots are cleared */ /* Make sure added industry cargo slots are cleared */
for (Industry *i : Industry::Iterate()) { for (Industry *i : Industry::Iterate()) {
for (auto it = std::begin(i->produced) + 2; it != std::end(i->produced); ++it) { 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->waiting = 0;
it->rate = 0; it->rate = 0;
it->history = {}; it->history = {};
} }
for (auto it = std::begin(i->accepted) + 3; it != std::end(i->accepted); ++it) { 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; it->waiting = 0;
} }
/* Make sure last_cargo_accepted_at is copied to elements for every valid input cargo. /* Make sure last_cargo_accepted_at is copied to elements for every valid input cargo.

View File

@ -57,7 +57,7 @@ public:
/* Note: these values represent part of the in-game CargoTypes enum */ /* 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_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_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.
}; };
/** /**

View File

@ -52,12 +52,12 @@
/* static */ CargoID ScriptEngine::GetCargoType(EngineID engine_id) /* 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); CargoArray cap = ::GetCapacityOfArticulatedParts(engine_id);
auto it = std::max_element(std::cbegin(cap), std::cend(cap)); 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)); return CargoID(std::distance(std::cbegin(cap), it));
} }

View File

@ -39,11 +39,11 @@ std::optional<std::string> ScriptEventEnginePreview::GetName()
CargoID ScriptEventEnginePreview::GetCargoType() CargoID ScriptEventEnginePreview::GetCargoType()
{ {
if (!this->IsEngineValid()) return CT_INVALID; if (!this->IsEngineValid()) return INVALID_CARGO;
CargoArray cap = ::GetCapacityOfArticulatedParts(this->engine); CargoArray cap = ::GetCapacityOfArticulatedParts(this->engine);
auto it = std::max_element(std::cbegin(cap), std::cend(cap)); 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)); return CargoID(std::distance(std::cbegin(cap), it));
} }

View File

@ -257,9 +257,9 @@ public:
/** /**
* Get the last date this industry accepted any cargo delivery. * Get the last date this industry accepted any cargo delivery.
* @param industry_id The index of the industry. * @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 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. * @return Date the industry last received cargo from a delivery, or ScriptDate::DATE_INVALID on error.
* @api -ai * @api -ai
*/ */

View File

@ -67,7 +67,7 @@
/* static */ CargoID ScriptSubsidy::GetCargoType(SubsidyID subsidy_id) /* 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; return ::Subsidy::Get(subsidy_id)->cargo_type;
} }

View File

@ -89,7 +89,7 @@
/* static */ VehicleID ScriptVehicle::BuildVehicle(TileIndex depot, EngineID engine_id) /* 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) /* static */ VehicleID ScriptVehicle::BuildVehicleWithRefit(TileIndex depot, EngineID engine_id, CargoID cargo)

View File

@ -1750,7 +1750,7 @@ struct StationViewWindow : public Window {
* @param cargo Current cargo being drawn (if cargo column has been passed). * @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. * @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->sortings[column] == CargoSortType::AsGrouping) {
if (this->groupings[column] != GR_CARGO) { if (this->groupings[column] != GR_CARGO) {

View File

@ -20,7 +20,7 @@ extern SubsidyPool _subsidy_pool;
/** Struct about subsidies, offered and awarded */ /** Struct about subsidies, offered and awarded */
struct Subsidy : SubsidyPool::PoolItem<&_subsidy_pool> { 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 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 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) SourceType src_type; ///< Source of subsidised path (SourceType::Industry or SourceType::Town)

View File

@ -273,7 +273,7 @@ static void GetCargoSummaryOfArticulatedVehicle(const Train *v, CargoSummary &su
if (!v->GetEngine()->CanCarryCargo()) continue; if (!v->GetEngine()->CanCarryCargo()) continue;
CargoSummaryItem new_item; 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); new_item.subtype = GetCargoSubtypeText(v);
if (!IsValidCargoID(new_item.cargo) && new_item.subtype == STR_EMPTY) continue; if (!IsValidCargoID(new_item.cargo) && new_item.subtype == STR_EMPTY) continue;

View File

@ -1902,7 +1902,7 @@ bool CanBuildVehicleInfrastructure(VehicleType type, byte subtype)
*/ */
LiveryScheme GetEngineLiveryScheme(EngineID engine_type, EngineID parent_engine_type, const Vehicle *v) 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); const Engine *e = Engine::Get(engine_type);
switch (e->type) { switch (e->type) {
default: NOT_REACHED(); default: NOT_REACHED();

View File

@ -874,7 +874,7 @@ std::tuple<CommandCost, VehicleID> CmdCloneVehicle(DoCommandFlag flags, TileInde
if ((flags & DC_EXEC) && !v->IsPrimaryVehicle()) build_flags |= DC_AUTOREPLACE; if ((flags & DC_EXEC) && !v->IsPrimaryVehicle()) build_flags |= DC_AUTOREPLACE;
CommandCost cost; 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()) { if (cost.Failed()) {
/* Can't build a part, then sell the stuff we already made; clear up the mess */ /* Can't build a part, then sell the stuff we already made; clear up the mess */
@ -953,7 +953,7 @@ std::tuple<CommandCost, VehicleID> CmdCloneVehicle(DoCommandFlag flags, TileInde
} }
} else { } else {
const Engine *e = v->GetEngine(); 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)) { if (v->cargo_type != initial_cargo && IsValidCargoID(initial_cargo)) {
bool dummy; bool dummy;

View File

@ -779,7 +779,7 @@ struct RefitWindow : public Window {
{ {
size_t scroll_row = 0; size_t scroll_row = 0;
size_t rows = 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) { for (const auto &pair : this->refit_list) {
if (pair.first == cargo) { if (pair.first == cargo) {

View File

@ -75,7 +75,7 @@ struct BaseVehicleListWindow : public Window {
/** Special cargo filter criteria */ /** Special cargo filter criteria */
enum CargoFilterSpecialType { 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_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 CF_FREIGHT = CT_AUTO_REFIT, ///< Show only vehicles which carry any freight (non-passenger) cargo
}; };