Codechange: rename CargoID to CargoType and amend related variables/comments

This commit is contained in:
Rubidium
2025-01-22 18:08:59 +01:00
committed by rubidium42
parent d05cc2ef92
commit e894a5880c
129 changed files with 1009 additions and 1009 deletions

View File

@@ -979,7 +979,7 @@ Money GetPrice(Price index, uint cost_factor, const GRFFile *grf_file, int shift
return cost;
}
Money GetTransportedGoodsIncome(uint num_pieces, uint dist, uint16_t transit_periods, CargoID cargo_type)
Money GetTransportedGoodsIncome(uint num_pieces, uint dist, uint16_t transit_periods, CargoType cargo_type)
{
const CargoSpec *cs = CargoSpec::Get(cargo_type);
if (!cs->IsValid()) {
@@ -1053,7 +1053,7 @@ static SmallIndustryList _cargo_delivery_destinations;
* @param company The company delivering the cargo
* @return actually accepted pieces of cargo
*/
static uint DeliverGoodsToIndustry(const Station *st, CargoID cargo_type, uint num_pieces, IndustryID source, CompanyID company)
static uint DeliverGoodsToIndustry(const Station *st, CargoType cargo_type, uint num_pieces, IndustryID source, CompanyID company)
{
/* Find the nearest industrytile to the station sign inside the catchment area, whose industry accepts the cargo.
* This fails in three cases:
@@ -1108,7 +1108,7 @@ static uint DeliverGoodsToIndustry(const Station *st, CargoID cargo_type, uint n
* @return Revenue for delivering cargo
* @note The cargo is just added to the stockpile of the industry. It is due to the caller to trigger the industry's production machinery
*/
static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, uint distance, uint16_t periods_in_transit, Company *company, SourceType src_type, SourceID src)
static Money DeliverGoods(int num_pieces, CargoType cargo_type, StationID dest, uint distance, uint16_t periods_in_transit, Company *company, SourceType src_type, SourceID src)
{
assert(num_pieces > 0);
@@ -1173,10 +1173,10 @@ static void TriggerIndustryProduction(Industry *i)
}
} else {
for (auto ita = std::begin(i->accepted); ita != std::end(i->accepted); ++ita) {
if (ita->waiting == 0 || !IsValidCargoID(ita->cargo)) continue;
if (ita->waiting == 0 || !IsValidCargoType(ita->cargo)) continue;
for (auto itp = std::begin(i->produced); itp != std::end(i->produced); ++itp) {
if (!IsValidCargoID(itp->cargo)) continue;
if (!IsValidCargoType(itp->cargo)) continue;
itp->waiting = ClampTo<uint16_t>(itp->waiting + (ita->waiting * indspec->input_cargo_multiplier[ita - std::begin(i->accepted)][itp - std::begin(i->produced)] / 256));
}
@@ -1233,7 +1233,7 @@ CargoPayment::~CargoPayment()
* @param count The number of packets to pay for.
* @param current_tile Current tile the payment is happening on.
*/
void CargoPayment::PayFinalDelivery(CargoID cargo, const CargoPacket *cp, uint count, TileIndex current_tile)
void CargoPayment::PayFinalDelivery(CargoType cargo, const CargoPacket *cp, uint count, TileIndex current_tile)
{
if (this->owner == nullptr) {
this->owner = Company::Get(this->front->owner);
@@ -1255,7 +1255,7 @@ void CargoPayment::PayFinalDelivery(CargoID cargo, const CargoPacket *cp, uint c
* @param current_tile Current tile the payment is happening on.
* @return The amount of money paid for the transfer.
*/
Money CargoPayment::PayTransfer(CargoID cargo, const CargoPacket *cp, uint count, TileIndex current_tile)
Money CargoPayment::PayTransfer(CargoType cargo, const CargoPacket *cp, uint count, TileIndex current_tile)
{
/* Pay transfer vehicle the difference between the payment for the journey from
* the source to the current point, and the sum of the previous transfer payments */
@@ -1492,9 +1492,9 @@ struct FinalizeRefitAction
* @param consist_capleft Added cargo capacities in the consist.
* @param st Station the vehicle is loading at.
* @param next_station Possible next stations the vehicle can travel to.
* @param new_cid Target cargo for refit.
* @param new_cargo_type Target cargo for refit.
*/
static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station *st, StationIDStack next_station, CargoID new_cid)
static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station *st, StationIDStack next_station, CargoType new_cargo_type)
{
Vehicle *v_start = v->GetFirstEnginePart();
if (!IterateVehicleParts(v_start, IsEmptyAction())) return;
@@ -1506,38 +1506,38 @@ static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station
/* Remove old capacity from consist capacity and collect refit mask. */
IterateVehicleParts(v_start, PrepareRefitAction(consist_capleft, refit_mask));
bool is_auto_refit = new_cid == CARGO_AUTO_REFIT;
bool is_auto_refit = new_cargo_type == CARGO_AUTO_REFIT;
if (is_auto_refit) {
/* Get a refittable cargo type with waiting cargo for next_station or INVALID_STATION. */
new_cid = v_start->cargo_type;
for (CargoID cid : SetCargoBitIterator(refit_mask)) {
if (st->goods[cid].HasData() && st->goods[cid].GetData().cargo.HasCargoFor(next_station)) {
new_cargo_type = v_start->cargo_type;
for (CargoType cargo_type : SetCargoBitIterator(refit_mask)) {
if (st->goods[cargo_type].HasData() && st->goods[cargo_type].GetData().cargo.HasCargoFor(next_station)) {
/* Try to find out if auto-refitting would succeed. In case the refit is allowed,
* the returned refit capacity will be greater than zero. */
auto [cc, refit_capacity, mail_capacity, cargo_capacities] = Command<CMD_REFIT_VEHICLE>::Do(DC_QUERY_COST, v_start->index, cid, 0xFF, true, false, 1); // Auto-refit and only this vehicle including artic parts.
auto [cc, refit_capacity, mail_capacity, cargo_capacities] = Command<CMD_REFIT_VEHICLE>::Do(DC_QUERY_COST, v_start->index, cargo_type, 0xFF, true, false, 1); // Auto-refit and only this vehicle including artic parts.
/* Try to balance different loadable cargoes between parts of the consist, so that
* all of them can be loaded. Avoid a situation where all vehicles suddenly switch
* to the first loadable cargo for which there is only one packet. If the capacities
* are equal refit to the cargo of which most is available. This is important for
* consists of only a single vehicle as those will generally have a consist_capleft
* of 0 for all cargoes. */
if (refit_capacity > 0 && (consist_capleft[cid] < consist_capleft[new_cid] ||
(consist_capleft[cid] == consist_capleft[new_cid] &&
st->goods[cid].GetData().cargo.AvailableCount() > st->goods[new_cid].GetData().cargo.AvailableCount()))) {
new_cid = cid;
if (refit_capacity > 0 && (consist_capleft[cargo_type] < consist_capleft[new_cargo_type] ||
(consist_capleft[cargo_type] == consist_capleft[new_cargo_type] &&
st->goods[cargo_type].GetData().cargo.AvailableCount() > st->goods[new_cargo_type].GetData().cargo.AvailableCount()))) {
new_cargo_type = cargo_type;
}
}
}
}
/* Refit if given a valid cargo. */
if (new_cid < NUM_CARGO && new_cid != v_start->cargo_type) {
if (new_cargo_type < NUM_CARGO && new_cargo_type != v_start->cargo_type) {
/* INVALID_STATION because in the DT_MANUAL case that's correct and in the DT_(A)SYMMETRIC
* cases the next hop of the vehicle doesn't really tell us anything if the cargo had been
* "via any station" before reserving. We rather produce some more "any station" cargo than
* misrouting it. */
IterateVehicleParts(v_start, ReturnCargoAction(st, INVALID_STATION));
CommandCost cost = std::get<0>(Command<CMD_REFIT_VEHICLE>::Do(DC_EXEC, v_start->index, new_cid, 0xFF, true, false, 1)); // Auto-refit and only this vehicle including artic parts.
CommandCost cost = std::get<0>(Command<CMD_REFIT_VEHICLE>::Do(DC_EXEC, v_start->index, new_cargo_type, 0xFF, true, false, 1)); // Auto-refit and only this vehicle including artic parts.
if (cost.Succeeded()) v->First()->profit_this_year -= cost.GetCost() << 8;
}