Codechange: rename cargo aging days to periods, as they are not really days (#11112)

This commit is contained in:
rubidium42 2023-07-12 19:20:02 +02:00 committed by GitHub
parent ab19882e94
commit 9f6fec01cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 82 additions and 76 deletions

View File

@ -44,7 +44,7 @@ CargoPacket::CargoPacket()
CargoPacket::CargoPacket(StationID source, TileIndex source_xy, uint16 count, SourceType source_type, SourceID source_id) :
feeder_share(0),
count(count),
days_in_transit(0),
periods_in_transit(0),
source_id(source_id),
source(source),
source_xy(source_xy),
@ -58,7 +58,7 @@ CargoPacket::CargoPacket(StationID source, TileIndex source_xy, uint16 count, So
* Creates a new cargo packet. Initializes the fields that cannot be changed later.
* Used when loading or splitting packets.
* @param count Number of cargo entities to put in this packet.
* @param days_in_transit Number of days the cargo has been in transit.
* @param periods_in_transit Number of cargo aging periods the cargo has been in transit.
* @param source Station the cargo was initially loaded.
* @param source_xy Station location the cargo was initially loaded.
* @param loaded_at_xy Location the cargo was loaded last.
@ -68,10 +68,10 @@ CargoPacket::CargoPacket(StationID source, TileIndex source_xy, uint16 count, So
* @note We have to zero memory ourselves here because we are using a 'new'
* that, in contrary to all other pools, does not memset to 0.
*/
CargoPacket::CargoPacket(uint16 count, uint16 days_in_transit, StationID source, TileIndex source_xy, TileIndex loaded_at_xy, Money feeder_share, SourceType source_type, SourceID source_id) :
CargoPacket::CargoPacket(uint16 count, uint16 periods_in_transit, StationID source, TileIndex source_xy, TileIndex loaded_at_xy, Money feeder_share, SourceType source_type, SourceID source_id) :
feeder_share(feeder_share),
count(count),
days_in_transit(days_in_transit),
periods_in_transit(periods_in_transit),
source_id(source_id),
source(source),
source_xy(source_xy),
@ -91,7 +91,7 @@ CargoPacket *CargoPacket::Split(uint new_size)
if (!CargoPacket::CanAllocateItem()) return nullptr;
Money fs = this->FeederShare(new_size);
CargoPacket *cp_new = new CargoPacket(new_size, this->days_in_transit, this->source, this->source_xy, this->loaded_at_xy, fs, this->source_type, this->source_id);
CargoPacket *cp_new = new CargoPacket(new_size, this->periods_in_transit, this->source, this->source_xy, this->loaded_at_xy, fs, this->source_type, this->source_id);
this->feeder_share -= fs;
this->count -= new_size;
return cp_new;
@ -171,7 +171,7 @@ void CargoList<Tinst, Tcont>::OnCleanPool()
/**
* Update the cached values to reflect the removal of this packet or part of it.
* Decreases count and days_in_transit.
* Decreases count and periods_in_transit.
* @param cp Packet to be removed from cache.
* @param count Amount of cargo from the given packet to be removed.
*/
@ -180,19 +180,19 @@ void CargoList<Tinst, Tcont>::RemoveFromCache(const CargoPacket *cp, uint count)
{
assert(count <= cp->count);
this->count -= count;
this->cargo_days_in_transit -= static_cast<uint64_t>(cp->days_in_transit) * count;
this->cargo_periods_in_transit -= static_cast<uint64_t>(cp->periods_in_transit) * count;
}
/**
* Update the cache to reflect adding of this packet.
* Increases count and days_in_transit.
* Increases count and periods_in_transit.
* @param cp New packet to be inserted.
*/
template <class Tinst, class Tcont>
void CargoList<Tinst, Tcont>::AddToCache(const CargoPacket *cp)
{
this->count += cp->count;
this->cargo_days_in_transit += static_cast<uint64_t>(cp->days_in_transit) * cp->count;
this->cargo_periods_in_transit += static_cast<uint64_t>(cp->periods_in_transit) * cp->count;
}
/** Invalidates the cached data and rebuilds it. */
@ -200,7 +200,7 @@ template <class Tinst, class Tcont>
void CargoList<Tinst, Tcont>::InvalidateCache()
{
this->count = 0;
this->cargo_days_in_transit = 0;
this->cargo_periods_in_transit = 0;
for (ConstIterator it(this->packets.begin()); it != this->packets.end(); it++) {
static_cast<Tinst *>(this)->AddToCache(*it);
@ -326,7 +326,7 @@ void VehicleCargoList::PopCargo(Taction action)
/**
* Update the cached values to reflect the removal of this packet or part of it.
* Decreases count, feeder share and days_in_transit.
* Decreases count, feeder share and periods_in_transit.
* @param cp Packet to be removed from cache.
* @param count Amount of cargo from the given packet to be removed.
*/
@ -338,7 +338,7 @@ void VehicleCargoList::RemoveFromCache(const CargoPacket *cp, uint count)
/**
* Update the cache to reflect adding of this packet.
* Increases count, feeder share and days_in_transit.
* Increases count, feeder share and periods_in_transit.
* @param cp New packet to be inserted.
*/
void VehicleCargoList::AddToCache(const CargoPacket *cp)
@ -382,10 +382,10 @@ void VehicleCargoList::AgeCargo()
{
for (const auto &cp : this->packets) {
/* If we're at the maximum, then we can't increase no more. */
if (cp->days_in_transit == UINT16_MAX) continue;
if (cp->periods_in_transit == UINT16_MAX) continue;
cp->days_in_transit++;
this->cargo_days_in_transit += cp->count;
cp->periods_in_transit++;
this->cargo_periods_in_transit += cp->count;
}
}

View File

@ -43,7 +43,7 @@ struct CargoPacket : CargoPacketPool::PoolItem<&_cargopacket_pool> {
private:
Money feeder_share; ///< Value of feeder pickup to be paid for on delivery of cargo.
uint16 count; ///< The amount of cargo in this packet.
uint16 days_in_transit; ///< Amount of days this packet has been in transit.
uint16 periods_in_transit; ///< Amount of cargo aging periods this packet has been in transit.
SourceType source_type; ///< Type of \c source_id.
SourceID source_id; ///< Index of source, INVALID_SOURCE if unknown/invalid.
StationID source; ///< The station where the cargo came from first.
@ -65,7 +65,7 @@ public:
CargoPacket();
CargoPacket(StationID source, TileIndex source_xy, uint16 count, SourceType source_type, SourceID source_id);
CargoPacket(uint16 count, uint16 days_in_transit, StationID source, TileIndex source_xy, TileIndex loaded_at_xy, Money feeder_share = 0, SourceType source_type = SourceType::Industry, SourceID source_id = INVALID_SOURCE);
CargoPacket(uint16 count, uint16 periods_in_transit, StationID source, TileIndex source_xy, TileIndex loaded_at_xy, Money feeder_share = 0, SourceType source_type = SourceType::Industry, SourceID source_id = INVALID_SOURCE);
/** Destroy the packet. */
~CargoPacket() { }
@ -123,14 +123,15 @@ public:
}
/**
* Gets the number of days this cargo has been in transit.
* This number isn't really in days, but in 2.5 days (CARGO_AGING_TICKS = 185 ticks) and
* it is capped at UINT16_MAX.
* Gets the number of cargo aging periods this cargo has been in transit.
* By default a period is 2.5 days (CARGO_AGING_TICKS = 185 ticks), however
* vehicle NewGRFs can overide the length of the cargo aging period. The
* value is capped at UINT16_MAX.
* @return Length this cargo has been in transit.
*/
inline uint16 DaysInTransit() const
inline uint16 PeriodsInTransit() const
{
return this->days_in_transit;
return this->periods_in_transit;
}
/**
@ -221,7 +222,7 @@ public:
protected:
uint count; ///< Cache for the number of cargo entities.
uint64 cargo_days_in_transit; ///< Cache for the sum of number of days in transit of each entity; comparable to man-hours.
uint64 cargo_periods_in_transit; ///< Cache for the sum of number of cargo aging periods in transit of each entity; comparable to man-hours.
Tcont packets; ///< The cargo packets in this list.
@ -249,12 +250,12 @@ public:
}
/**
* Returns average number of days in transit for a cargo entity.
* Returns average number of cargo aging periods in transit for a cargo entity.
* @return The before mentioned number.
*/
inline uint DaysInTransit() const
inline uint PeriodsInTransit() const
{
return this->count == 0 ? 0 : this->cargo_days_in_transit / this->count;
return this->count == 0 ? 0 : this->cargo_periods_in_transit / this->count;
}
void InvalidateCache();
@ -431,11 +432,11 @@ public:
*/
static bool AreMergable(const CargoPacket *cp1, const CargoPacket *cp2)
{
return cp1->source_xy == cp2->source_xy &&
cp1->days_in_transit == cp2->days_in_transit &&
cp1->source_type == cp2->source_type &&
cp1->source_id == cp2->source_id &&
cp1->loaded_at_xy == cp2->loaded_at_xy;
return cp1->source_xy == cp2->source_xy &&
cp1->periods_in_transit == cp2->periods_in_transit &&
cp1->source_type == cp2->source_type &&
cp1->source_id == cp2->source_id &&
cp1->loaded_at_xy == cp2->loaded_at_xy;
}
};
@ -546,10 +547,10 @@ public:
*/
static bool AreMergable(const CargoPacket *cp1, const CargoPacket *cp2)
{
return cp1->source_xy == cp2->source_xy &&
cp1->days_in_transit == cp2->days_in_transit &&
cp1->source_type == cp2->source_type &&
cp1->source_id == cp2->source_id;
return cp1->source_xy == cp2->source_xy &&
cp1->periods_in_transit == cp2->periods_in_transit &&
cp1->source_type == cp2->source_type &&
cp1->source_id == cp2->source_id;
}
};

View File

@ -61,7 +61,7 @@ struct CargoSpec {
uint8 weight; ///< Weight of a single unit of this cargo type in 1/16 ton (62.5 kg).
uint16 multiplier; ///< Capacity multiplier for vehicles. (8 fractional bits)
int32 initial_payment; ///< Initial payment rate before inflation is applied.
uint8 transit_days[2];
uint8 transit_periods[2];
bool is_freight; ///< Cargo type is considered to be freight (affects train freight multiplier).
TownEffect town_effect; ///< The effect that delivering this cargo type has on towns. Also affects destination of subsidies.

View File

@ -975,7 +975,7 @@ Money GetPrice(Price index, uint cost_factor, const GRFFile *grf_file, int shift
return cost;
}
Money GetTransportedGoodsIncome(uint num_pieces, uint dist, uint16 transit_days, CargoID cargo_type)
Money GetTransportedGoodsIncome(uint num_pieces, uint dist, uint16 transit_periods, CargoID cargo_type)
{
const CargoSpec *cs = CargoSpec::Get(cargo_type);
if (!cs->IsValid()) {
@ -985,7 +985,7 @@ Money GetTransportedGoodsIncome(uint num_pieces, uint dist, uint16 transit_days,
/* Use callback to calculate cargo profit, if available */
if (HasBit(cs->callback_mask, CBM_CARGO_PROFIT_CALC)) {
uint32 var18 = ClampTo<uint16_t>(dist) | (ClampTo<uint8_t>(num_pieces) << 16) | (ClampTo<uint8_t>(transit_days) << 24);
uint32 var18 = ClampTo<uint16_t>(dist) | (ClampTo<uint8_t>(num_pieces) << 16) | (ClampTo<uint8_t>(transit_periods) << 24);
uint16 callback = GetCargoCallback(CBID_CARGO_PROFIT_CALC, 0, var18, cs);
if (callback != CALLBACK_FAILED) {
int result = GB(callback, 0, 14);
@ -1005,17 +1005,20 @@ Money GetTransportedGoodsIncome(uint num_pieces, uint dist, uint16 transit_days,
static const int TIME_FACTOR_FRAC_BITS = 4;
static const int TIME_FACTOR_FRAC = 1 << TIME_FACTOR_FRAC_BITS;
const int days1 = cs->transit_days[0];
const int days2 = cs->transit_days[1];
const int days_over_days1 = std::max( transit_days - days1, 0);
const int days_over_days2 = std::max(days_over_days1 - days2, 0);
int days_over_max = MIN_TIME_FACTOR - MAX_TIME_FACTOR;
if (days2 > -days_over_max) days_over_max += transit_days - days1;
else days_over_max += 2 * (transit_days - days1) - days2;
const int periods1 = cs->transit_periods[0];
const int periods2 = cs->transit_periods[1];
const int periods_over_periods1 = std::max(transit_periods - periods1, 0);
const int periods_over_periods2 = std::max(periods_over_periods1 - periods2, 0);
int periods_over_max = MIN_TIME_FACTOR - MAX_TIME_FACTOR;
if (periods2 > -periods_over_max) {
periods_over_max += transit_periods - periods1;
} else {
periods_over_max += 2 * (transit_periods - periods1) - periods2;
}
/*
* The time factor is calculated based on the time it took
* (transit_days) compared two cargo-depending values. The
* (transit_periods) compared two cargo-depending values. The
* range is divided into four parts:
*
* - constant for fast transits
@ -1024,11 +1027,11 @@ Money GetTransportedGoodsIncome(uint num_pieces, uint dist, uint16 transit_days,
* - after hitting MIN_TIME_FACTOR, the time factor will be asymptotically decreased to a limit of 1 with a scaled 1/(x+1) function.
*
*/
if (days_over_max > 0) {
const int time_factor = std::max(2 * MIN_TIME_FACTOR * TIME_FACTOR_FRAC * TIME_FACTOR_FRAC / (days_over_max + 2 * TIME_FACTOR_FRAC), 1); // MIN_TIME_FACTOR / (x/(2 * TIME_FACTOR_FRAC) + 1) + 1, expressed as fixed point with TIME_FACTOR_FRAC_BITS.
if (periods_over_max > 0) {
const int time_factor = std::max(2 * MIN_TIME_FACTOR * TIME_FACTOR_FRAC * TIME_FACTOR_FRAC / (periods_over_max + 2 * TIME_FACTOR_FRAC), 1); // MIN_TIME_FACTOR / (x/(2 * TIME_FACTOR_FRAC) + 1) + 1, expressed as fixed point with TIME_FACTOR_FRAC_BITS.
return BigMulS(dist * time_factor * num_pieces, cs->current_payment, 21 + TIME_FACTOR_FRAC_BITS);
} else {
const int time_factor = std::max(MAX_TIME_FACTOR - days_over_days1 - days_over_days2, MIN_TIME_FACTOR);
const int time_factor = std::max(MAX_TIME_FACTOR - periods_over_periods1 - periods_over_periods2, MIN_TIME_FACTOR);
return BigMulS(dist * time_factor * num_pieces, cs->current_payment, 21);
}
}
@ -1094,14 +1097,14 @@ static uint DeliverGoodsToIndustry(const Station *st, CargoID cargo_type, uint n
* @param cargo_type the type of cargo that is delivered
* @param dest Station the cargo has been unloaded
* @param source_tile The origin of the cargo for distance calculation
* @param days_in_transit Travel time
* @param periods_in_transit Travel time in cargo aging periods
* @param company The company delivering the cargo
* @param src_type Type of source of cargo (industry, town, headquarters)
* @param src Index of source of cargo
* @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, TileIndex source_tile, uint16 days_in_transit, Company *company, SourceType src_type, SourceID src)
static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, TileIndex source_tile, uint16 periods_in_transit, Company *company, SourceType src_type, SourceID src)
{
assert(num_pieces > 0);
@ -1128,7 +1131,7 @@ static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, Ti
st->town->received[cs->town_effect].new_act += accepted_total;
/* Determine profit */
Money profit = GetTransportedGoodsIncome(accepted_total, DistanceManhattan(source_tile, st->xy), days_in_transit, cargo_type);
Money profit = GetTransportedGoodsIncome(accepted_total, DistanceManhattan(source_tile, st->xy), periods_in_transit, cargo_type);
/* Update the cargo monitor. */
AddCargoDelivery(cargo_type, company->index, accepted_total - accepted_ind, src_type, src, st);
@ -1230,7 +1233,7 @@ void CargoPayment::PayFinalDelivery(const CargoPacket *cp, uint count)
}
/* Handle end of route payment */
Money profit = DeliverGoods(count, this->ct, this->current_station, cp->SourceStationXY(), cp->DaysInTransit(), this->owner, cp->SourceSubsidyType(), cp->SourceSubsidyID());
Money profit = DeliverGoods(count, this->ct, this->current_station, cp->SourceStationXY(), cp->PeriodsInTransit(), this->owner, cp->SourceSubsidyType(), cp->SourceSubsidyID());
this->route_profit += profit;
/* The vehicle's profit is whatever route profit there is minus feeder shares. */
@ -1250,7 +1253,7 @@ Money CargoPayment::PayTransfer(const CargoPacket *cp, uint count)
/* 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 */
DistanceManhattan(cp->SourceStationXY(), Station::Get(this->current_station)->xy),
cp->DaysInTransit(),
cp->PeriodsInTransit(),
this->ct);
profit = profit * _settings_game.economy.feeder_payment_share / 100;

View File

@ -28,7 +28,7 @@ extern Prices _price;
int UpdateCompanyRatingAndValue(Company *c, bool update);
void StartupIndustryDailyChanges(bool init_counter);
Money GetTransportedGoodsIncome(uint num_pieces, uint dist, uint16 transit_days, CargoID cargo_type);
Money GetTransportedGoodsIncome(uint num_pieces, uint dist, uint16 transit_periods, CargoID cargo_type);
uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, SourceID source_id, const StationList *all_stations, Owner exclusivity = INVALID_OWNER);
void PrepareUnload(Vehicle *front_v);

View File

@ -3021,11 +3021,11 @@ static ChangeInfoResult CargoChangeInfo(uint cid, int numinfo, int prop, ByteRea
break;
case 0x10: // Used for payment calculation
cs->transit_days[0] = buf->ReadByte();
cs->transit_periods[0] = buf->ReadByte();
break;
case 0x11: // Used for payment calculation
cs->transit_days[1] = buf->ReadByte();
cs->transit_periods[1] = buf->ReadByte();
break;
case 0x12: // Base cargo price

View File

@ -824,7 +824,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
case 0x3C: return ClampTo<uint16_t>(v->cargo.StoredCount());
case 0x3D: return GB(ClampTo<uint16_t>(v->cargo.StoredCount()), 8, 8);
case 0x3E: return v->cargo.Source();
case 0x3F: return ClampTo<uint8_t>(v->cargo.DaysInTransit());
case 0x3F: return ClampTo<uint8_t>(v->cargo.PeriodsInTransit());
case 0x40: return ClampTo<uint16_t>(v->age);
case 0x41: return GB(ClampTo<uint16_t>(v->age), 8, 8);
case 0x42: return ClampTo<uint16_t>(v->max_age);

View File

@ -425,7 +425,7 @@ uint32 Station::GetNewGRFVariable(const ResolverObject &object, byte variable, b
case 0x60: return std::min(ge->cargo.TotalCount(), 4095u);
case 0x61: return ge->HasVehicleEverTriedLoading() ? ge->time_since_pickup : 0;
case 0x62: return ge->HasRating() ? ge->rating : 0xFFFFFFFF;
case 0x63: return ge->cargo.DaysInTransit();
case 0x63: return ge->cargo.PeriodsInTransit();
case 0x64: return ge->HasVehicleEverTriedLoading() ? ge->last_speed | (ge->last_age << 8) : 0xFF00;
case 0x65: return GB(ge->status, GoodsEntry::GES_ACCEPTANCE, 1) << 3;
case 0x69: {
@ -446,7 +446,7 @@ uint32 Station::GetNewGRFVariable(const ResolverObject &object, byte variable, b
case 2: return g->time_since_pickup;
case 3: return g->rating;
case 4: return g->cargo.Source();
case 5: return g->cargo.DaysInTransit();
case 5: return g->cargo.PeriodsInTransit();
case 6: return g->last_speed;
case 7: return g->last_age;
}

View File

@ -92,8 +92,9 @@ SaveLoadTable GetCargoPacketDesc()
SLE_VAR(CargoPacket, source_xy, SLE_UINT32),
SLE_VAR(CargoPacket, loaded_at_xy, SLE_UINT32),
SLE_VAR(CargoPacket, count, SLE_UINT16),
SLE_CONDVAR(CargoPacket, days_in_transit, SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SLV_MORE_CARGO_AGE),
SLE_CONDVAR(CargoPacket, days_in_transit, SLE_UINT16, SLV_MORE_CARGO_AGE, SL_MAX_VERSION),
SLE_CONDVARNAME(CargoPacket, periods_in_transit, "days_in_transit", SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SLV_MORE_CARGO_AGE),
SLE_CONDVARNAME(CargoPacket, periods_in_transit, "days_in_transit", SLE_UINT16, SLV_MORE_CARGO_AGE, SLV_PERIODS_IN_TRANSIT_RENAME),
SLE_CONDVAR(CargoPacket, periods_in_transit, SLE_UINT16, SLV_PERIODS_IN_TRANSIT_RENAME, SL_MAX_VERSION),
SLE_VAR(CargoPacket, feeder_share, SLE_INT64),
SLE_CONDVAR(CargoPacket, source_type, SLE_UINT8, SLV_125, SL_MAX_VERSION),
SLE_CONDVAR(CargoPacket, source_id, SLE_UINT16, SLV_125, SL_MAX_VERSION),

View File

@ -683,14 +683,14 @@ static bool LoadOldDepot(LoadgameState *ls, int num)
static StationID _current_station_id;
static uint16 _waiting_acceptance;
static uint8 _cargo_source;
static uint8 _cargo_days;
static uint8 _cargo_periods;
static const OldChunks goods_chunk[] = {
OCL_VAR ( OC_UINT16, 1, &_waiting_acceptance ),
OCL_SVAR( OC_UINT8, GoodsEntry, time_since_pickup ),
OCL_SVAR( OC_UINT8, GoodsEntry, rating ),
OCL_VAR ( OC_UINT8, 1, &_cargo_source ),
OCL_VAR ( OC_UINT8, 1, &_cargo_days ),
OCL_VAR ( OC_UINT8, 1, &_cargo_periods ),
OCL_SVAR( OC_UINT8, GoodsEntry, last_speed ),
OCL_SVAR( OC_UINT8, GoodsEntry, last_age ),
@ -710,7 +710,7 @@ static bool LoadOldGood(LoadgameState *ls, int num)
SB(ge->status, GoodsEntry::GES_ACCEPTANCE, 1, HasBit(_waiting_acceptance, 15));
SB(ge->status, GoodsEntry::GES_RATING, 1, _cargo_source != 0xFF);
if (GB(_waiting_acceptance, 0, 12) != 0 && CargoPacket::CanAllocateItem()) {
ge->cargo.Append(new CargoPacket(GB(_waiting_acceptance, 0, 12), _cargo_days, (_cargo_source == 0xFF) ? INVALID_STATION : _cargo_source, 0, 0),
ge->cargo.Append(new CargoPacket(GB(_waiting_acceptance, 0, 12), _cargo_periods, (_cargo_source == 0xFF) ? INVALID_STATION : _cargo_source, 0, 0),
INVALID_STATION);
}
@ -1175,7 +1175,7 @@ static const OldChunks vehicle_chunk[] = {
OCL_VAR ( OC_TTD | OC_UINT16, 1, &_cargo_count ),
OCL_VAR ( OC_TTO | OC_FILE_U8 | OC_VAR_U16, 1, &_cargo_count ),
OCL_VAR ( OC_UINT8, 1, &_cargo_source ),
OCL_VAR ( OC_UINT8, 1, &_cargo_days ),
OCL_VAR ( OC_UINT8, 1, &_cargo_periods ),
OCL_SVAR( OC_TTO | OC_UINT8, Vehicle, tick_counter ),
@ -1353,7 +1353,7 @@ bool LoadOldVehicle(LoadgameState *ls, int num)
if (_cargo_count != 0 && CargoPacket::CanAllocateItem()) {
StationID source = (_cargo_source == 0xFF) ? INVALID_STATION : _cargo_source;
TileIndex source_xy = (source != INVALID_STATION) ? Station::Get(source)->xy : (TileIndex)0;
v->cargo.Append(new CargoPacket(_cargo_count, _cargo_days, source, source_xy, source_xy));
v->cargo.Append(new CargoPacket(_cargo_count, _cargo_periods, source, source_xy, source_xy));
}
}

View File

@ -357,6 +357,7 @@ enum SaveLoadVersion : uint16 {
SLV_STRING_GAMELOG, ///< 314 PR#10801 Use std::string in gamelog.
SLV_INDUSTRY_CARGO_REORGANISE, ///< 315 PR#10853 Industry accepts/produced data reorganised.
SLV_PERIODS_IN_TRANSIT_RENAME, ///< 316 PR#11112 Rename days in transit to (cargo) periods in transit.
SL_MAX_VERSION, ///< Highest possible saveload version
};

View File

@ -162,7 +162,7 @@ static uint16 _waiting_acceptance;
static uint32 _old_num_flows;
static uint16 _cargo_source;
static uint32 _cargo_source_xy;
static uint8 _cargo_days;
static uint8 _cargo_periods;
static Money _cargo_feeder_share;
std::list<CargoPacket *> _packets;
@ -371,7 +371,7 @@ public:
SLEG_CONDVAR("cargo_source", _cargo_source, SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SLV_7),
SLEG_CONDVAR("cargo_source", _cargo_source, SLE_UINT16, SLV_7, SLV_68),
SLEG_CONDVAR("cargo_source_xy", _cargo_source_xy, SLE_UINT32, SLV_44, SLV_68),
SLEG_CONDVAR("cargo_days", _cargo_days, SLE_UINT8, SL_MIN_VERSION, SLV_68),
SLEG_CONDVAR("cargo_days", _cargo_periods, SLE_UINT8, SL_MIN_VERSION, SLV_68),
SLE_VAR(GoodsEntry, last_speed, SLE_UINT8),
SLE_VAR(GoodsEntry, last_age, SLE_UINT8),
SLEG_CONDVAR("cargo_feeder_share", _cargo_feeder_share, SLE_FILE_U32 | SLE_VAR_I64, SLV_14, SLV_65),
@ -449,7 +449,7 @@ public:
assert(CargoPacket::CanAllocateItem());
/* Don't construct the packet with station here, because that'll fail with old savegames */
CargoPacket *cp = new CargoPacket(GB(_waiting_acceptance, 0, 12), _cargo_days, source, _cargo_source_xy, _cargo_source_xy, _cargo_feeder_share);
CargoPacket *cp = new CargoPacket(GB(_waiting_acceptance, 0, 12), _cargo_periods, source, _cargo_source_xy, _cargo_source_xy, _cargo_feeder_share);
ge->cargo.Append(cp, INVALID_STATION);
SB(ge->status, GoodsEntry::GES_RATING, 1, 1);
}
@ -529,7 +529,7 @@ struct STNSChunkHandler : ChunkHandler {
const std::vector<SaveLoad> slt = SlCompatTableHeader(_old_station_desc, _old_station_sl_compat);
_cargo_source_xy = 0;
_cargo_days = 0;
_cargo_periods = 0;
_cargo_feeder_share = 0;
int index;

View File

@ -571,7 +571,7 @@ void FixupTrainLengths()
}
}
static uint8 _cargo_days;
static uint8 _cargo_periods;
static uint16 _cargo_source;
static uint32 _cargo_source_xy;
static uint16 _cargo_count;
@ -628,7 +628,7 @@ public:
SLE_VAR(Vehicle, cargo_type, SLE_UINT8),
SLE_CONDVAR(Vehicle, cargo_subtype, SLE_UINT8, SLV_35, SL_MAX_VERSION),
SLEG_CONDVAR("cargo_days", _cargo_days, SLE_UINT8, SL_MIN_VERSION, SLV_68),
SLEG_CONDVAR("cargo_days", _cargo_periods, SLE_UINT8, SL_MIN_VERSION, SLV_68),
SLEG_CONDVAR("cargo_source", _cargo_source, SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SLV_7),
SLEG_CONDVAR("cargo_source", _cargo_source, SLE_UINT16, SLV_7, SLV_68),
SLEG_CONDVAR("cargo_source_xy", _cargo_source_xy, SLE_UINT32, SLV_44, SLV_68),
@ -1042,7 +1042,7 @@ struct VEHSChunkHandler : ChunkHandler {
if (_cargo_count != 0 && IsCompanyBuildableVehicleType(v) && CargoPacket::CanAllocateItem()) {
/* Don't construct the packet with station here, because that'll fail with old savegames */
CargoPacket *cp = new CargoPacket(_cargo_count, _cargo_days, _cargo_source, _cargo_source_xy, _cargo_loaded_at_xy, _cargo_feeder_share);
CargoPacket *cp = new CargoPacket(_cargo_count, _cargo_periods, _cargo_source, _cargo_source_xy, _cargo_loaded_at_xy, _cargo_feeder_share);
v->cargo.Append(cp);
}

View File

@ -33,8 +33,8 @@
* @param weight Weight of a single unit of this cargo type in 1/16 ton (62.5 kg).
* @param mult Capacity multiplier for vehicles. (8 fractional bits).
* @param ip CargoSpec->initial_payment.
* @param td1 CargoSpec->transit_days[0].
* @param td2 CargoSpec->transit_days[1].
* @param td1 CargoSpec->transit_periods[0].
* @param td2 CargoSpec->transit_periods[1].
* @param freight Cargo type is considered to be freight (affects train freight multiplier).
* @param te The effect that delivering this cargo type has on towns. Also affects destination of subsidies.
* @param str_plural The name suffix used to populate CargoSpec->name, CargoSpec->quantifier,