Codechange: cleanup CargoPacket in terms of variable/function names (#11278)
Over the years, things got reused and changed, making the current
names somewhat unclear in what they actually mean and do.
(cherry picked from commit 30172fc037
)
This commit is contained in:

committed by
Jonathan G Rennison

parent
2890127675
commit
e5673a1756
@@ -56,10 +56,10 @@ void DrawAircraftDetails(const Aircraft *v, const Rect &r)
|
||||
/* Cargo names (fix pluralness) */
|
||||
SetDParam(0, u->cargo_type);
|
||||
SetDParam(1, cargo_count);
|
||||
SetDParam(2, u->cargo.Source());
|
||||
SetDParam(2, u->cargo.GetFirstStation());
|
||||
DrawString(r.left, r.right, y, STR_VEHICLE_DETAILS_CARGO_FROM);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
feeder_share += u->cargo.FeederShare();
|
||||
feeder_share += u->cargo.GetFeederShare();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -167,7 +167,7 @@ bool CargoTransfer::operator()(CargoPacket *cp)
|
||||
if (cp_new == nullptr) return false;
|
||||
this->source->RemoveFromMeta(cp_new, VehicleCargoList::MTA_TRANSFER, cp_new->Count());
|
||||
/* No transfer credits here as they were already granted during Stage(). */
|
||||
this->destination->Append(cp_new, cp_new->NextStation());
|
||||
this->destination->Append(cp_new, cp_new->GetNextStation());
|
||||
return cp_new == cp;
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ bool StationCargoReroute::operator()(CargoPacket *cp)
|
||||
{
|
||||
CargoPacket *cp_new = this->Preprocess(cp);
|
||||
if (cp_new == nullptr) cp_new = cp;
|
||||
StationID next = this->ge->GetVia(cp_new->SourceStation(), this->avoid, this->avoid2);
|
||||
StationID next = this->ge->GetVia(cp_new->GetFirstStation(), this->avoid, this->avoid2);
|
||||
assert(next != this->avoid && next != this->avoid2);
|
||||
if (this->source != this->destination) {
|
||||
this->source->RemoveFromCache(cp_new, cp_new->Count());
|
||||
@@ -218,8 +218,8 @@ bool VehicleCargoReroute::operator()(CargoPacket *cp, std::vector<CargoPacket *>
|
||||
{
|
||||
CargoPacket *cp_new = this->Preprocess(cp);
|
||||
if (cp_new == nullptr) cp_new = cp;
|
||||
if (cp_new->NextStation() == this->avoid || cp_new->NextStation() == this->avoid2) {
|
||||
cp->SetNextStation(this->ge->GetVia(cp_new->SourceStation(), this->avoid, this->avoid2));
|
||||
if (cp_new->GetNextStation() == this->avoid || cp_new->GetNextStation() == this->avoid2) {
|
||||
cp->SetNextStation(this->ge->GetVia(cp_new->GetFirstStation(), this->avoid, this->avoid2));
|
||||
}
|
||||
if (unlikely(this->source != this->destination)) {
|
||||
this->source->RemoveFromMeta(cp_new, VehicleCargoList::MTA_TRANSFER, cp_new->Count());
|
||||
|
@@ -108,7 +108,7 @@ CargoPacket::CargoPacket()
|
||||
|
||||
/**
|
||||
* Creates a new cargo packet.
|
||||
* @param source Source station of the packet.
|
||||
* @param first_station Source station of the packet.
|
||||
* @param source_xy Source location of the packet.
|
||||
* @param count Number of cargo entities to put in this packet.
|
||||
* @param source_type 'Type' of source the packet comes from (for subsidies).
|
||||
@@ -117,14 +117,12 @@ CargoPacket::CargoPacket()
|
||||
* @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(StationID source, TileIndex source_xy, uint16 count, SourceType source_type, SourceID source_id) :
|
||||
CargoPacket::CargoPacket(StationID first_station, TileIndex source_xy, uint16 count, SourceType source_type, SourceID source_id) :
|
||||
count(count),
|
||||
days_in_transit(0),
|
||||
feeder_share(0),
|
||||
source_xy(source_xy),
|
||||
source_id(source_id),
|
||||
source(source),
|
||||
source_type(source_type)
|
||||
source_type(source_type),
|
||||
first_station(first_station)
|
||||
{
|
||||
dbg_assert(count != 0);
|
||||
}
|
||||
@@ -133,8 +131,8 @@ 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 source Station the cargo was initially loaded.
|
||||
* @param periods_in_transit Number of cargo aging periods the cargo has been in transit.
|
||||
* @param first_station Station the cargo was initially loaded.
|
||||
* @param source_xy Station location the cargo was initially loaded.
|
||||
* @param feeder_share Feeder share the packet has already accumulated.
|
||||
* @param source_type 'Type' of source the packet comes from (for subsidies).
|
||||
@@ -142,14 +140,14 @@ 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, Money feeder_share, SourceType source_type, SourceID source_id) :
|
||||
CargoPacket::CargoPacket(uint16 count, uint16 periods_in_transit, StationID first_station, TileIndex source_xy, Money feeder_share, SourceType source_type, SourceID source_id) :
|
||||
count(count),
|
||||
days_in_transit(days_in_transit),
|
||||
periods_in_transit(periods_in_transit),
|
||||
feeder_share(feeder_share),
|
||||
source_xy(source_xy),
|
||||
source_id(source_id),
|
||||
source(source),
|
||||
source_type(source_type)
|
||||
source_type(source_type),
|
||||
first_station(first_station)
|
||||
{
|
||||
dbg_assert(count != 0);
|
||||
}
|
||||
@@ -173,8 +171,8 @@ 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, fs, this->source_type, this->source_id);
|
||||
Money fs = this->GetFeederShare(new_size);
|
||||
CargoPacket *cp_new = new CargoPacket(new_size, this->periods_in_transit, this->first_station, this->source_xy, fs, this->source_type, this->source_id);
|
||||
this->feeder_share -= fs;
|
||||
|
||||
if (this->flags & CPF_HAS_DEFERRED_PAYMENT) {
|
||||
@@ -226,7 +224,7 @@ void CargoPacket::Merge(CargoPacket *cp)
|
||||
void CargoPacket::Reduce(uint count)
|
||||
{
|
||||
dbg_assert(count < this->count);
|
||||
this->feeder_share -= this->FeederShare(count);
|
||||
this->feeder_share -= this->GetFeederShare(count);
|
||||
if (this->flags & CPF_HAS_DEFERRED_PAYMENT) {
|
||||
IterateCargoPacketDeferredPayments(this->index, false, [&](Money &payment, CompanyID cid, VehicleType type) {
|
||||
payment -= payment * count / static_cast<uint>(this->count);
|
||||
@@ -282,7 +280,7 @@ void CargoPacket::PayDeferredPayments()
|
||||
/* static */ void CargoPacket::InvalidateAllFrom(StationID sid)
|
||||
{
|
||||
for (CargoPacket *cp : CargoPacket::Iterate()) {
|
||||
if (cp->source == sid) cp->source = INVALID_STATION;
|
||||
if (cp->first_station == sid) cp->first_station = INVALID_STATION;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,7 +324,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.
|
||||
*/
|
||||
@@ -335,19 +333,19 @@ void CargoList<Tinst, Tcont>::RemoveFromCache(const CargoPacket *cp, uint count)
|
||||
{
|
||||
dbg_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. */
|
||||
@@ -355,7 +353,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);
|
||||
@@ -510,19 +508,19 @@ 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.
|
||||
*/
|
||||
void VehicleCargoList::RemoveFromCache(const CargoPacket *cp, uint count)
|
||||
{
|
||||
this->feeder_share -= cp->FeederShare(count);
|
||||
this->feeder_share -= cp->GetFeederShare(count);
|
||||
this->Parent::RemoveFromCache(cp, 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)
|
||||
@@ -566,10 +564,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,7 +584,7 @@ void VehicleCargoList::AgeCargo()
|
||||
StationID current_station, bool accepted, StationIDStack next_station)
|
||||
{
|
||||
if (cargo_next == INVALID_STATION) {
|
||||
return (accepted && cp->source != current_station) ? MTA_DELIVER : MTA_KEEP;
|
||||
return (accepted && cp->first_station != current_station) ? MTA_DELIVER : MTA_KEEP;
|
||||
} else if (cargo_next == current_station) {
|
||||
return MTA_DELIVER;
|
||||
} else if (next_station.Contains(cargo_next)) {
|
||||
@@ -633,13 +631,13 @@ bool VehicleCargoList::Stage(bool accepted, StationID current_station, StationID
|
||||
MoveToAction action = MTA_LOAD;
|
||||
if (force_keep) {
|
||||
action = MTA_KEEP;
|
||||
} else if (force_unload && accepted && cp->source != current_station) {
|
||||
} else if (force_unload && accepted && cp->first_station != current_station) {
|
||||
action = MTA_DELIVER;
|
||||
} else if (force_transfer) {
|
||||
action = MTA_TRANSFER;
|
||||
/* We cannot send the cargo to any of the possible next hops and
|
||||
* also not to the current station. */
|
||||
FlowStatMap::const_iterator flow_it(flows.find(cp->source));
|
||||
FlowStatMap::const_iterator flow_it(flows.find(cp->first_station));
|
||||
if (flow_it == flows.end()) {
|
||||
cargo_next = INVALID_STATION;
|
||||
} else {
|
||||
@@ -658,11 +656,11 @@ bool VehicleCargoList::Stage(bool accepted, StationID current_station, StationID
|
||||
} else {
|
||||
/* Rewrite an invalid source station to some random other one to
|
||||
* avoid keeping the cargo in the vehicle forever. */
|
||||
if (cp->source == INVALID_STATION && !flows.empty()) {
|
||||
cp->source = flows.FirstStationID();
|
||||
if (cp->first_station == INVALID_STATION && !flows.empty()) {
|
||||
cp->first_station = flows.FirstStationID();
|
||||
}
|
||||
bool restricted = false;
|
||||
FlowStatMap::const_iterator flow_it(flows.find(cp->source));
|
||||
FlowStatMap::const_iterator flow_it(flows.find(cp->first_station));
|
||||
if (flow_it == flows.end()) {
|
||||
cargo_next = INVALID_STATION;
|
||||
} else {
|
||||
@@ -861,7 +859,7 @@ uint VehicleCargoList::Reroute(uint max_move, VehicleCargoList *dest, StationID
|
||||
uint VehicleCargoList::RerouteFromSource(uint max_move, VehicleCargoList *dest, StationID source, StationID avoid, StationID avoid2, const GoodsEntry *ge)
|
||||
{
|
||||
max_move = std::min(this->action_counts[MTA_TRANSFER], max_move);
|
||||
this->ShiftCargoWithFrontInsert(VehicleCargoReroute(this, dest, max_move, avoid, avoid2, ge), [source](CargoPacket *cp) { return cp->SourceStation() == source; });
|
||||
this->ShiftCargoWithFrontInsert(VehicleCargoReroute(this, dest, max_move, avoid, avoid2, ge), [source](CargoPacket *cp) { return cp->GetFirstStation() == source; });
|
||||
return max_move;
|
||||
}
|
||||
|
||||
@@ -968,7 +966,7 @@ bool StationCargoList::ShiftCargoFromSource(Taction &action, StationID source, S
|
||||
for (Iterator it = this->packets.lower_bound(next); it != this->packets.end() && it.GetKey() == next;) {
|
||||
if (action.MaxMove() == 0) return false;
|
||||
CargoPacket *cp = *it;
|
||||
if (cp->SourceStation() != source) {
|
||||
if (cp->GetFirstStation() != source) {
|
||||
++it;
|
||||
continue;
|
||||
}
|
||||
@@ -1039,7 +1037,7 @@ uint StationCargoList::Truncate(uint max_move, StationCargoAmountMap *cargo_per_
|
||||
CargoPacket *cp = *it;
|
||||
if (prev_count > max_move && RandomRange(prev_count) < prev_count - max_move) {
|
||||
if (do_count && loop == 0) {
|
||||
(*cargo_per_source)[cp->source] += cp->count;
|
||||
(*cargo_per_source)[cp->first_station] += cp->count;
|
||||
}
|
||||
++it;
|
||||
continue;
|
||||
@@ -1052,16 +1050,16 @@ uint StationCargoList::Truncate(uint max_move, StationCargoAmountMap *cargo_per_
|
||||
moved += diff;
|
||||
}
|
||||
if (loop > 0) {
|
||||
if (do_count) (*cargo_per_source)[cp->source] -= diff;
|
||||
if (do_count) (*cargo_per_source)[cp->first_station] -= diff;
|
||||
return moved;
|
||||
} else {
|
||||
if (do_count) (*cargo_per_source)[cp->source] += cp->count;
|
||||
if (do_count) (*cargo_per_source)[cp->first_station] += cp->count;
|
||||
++it;
|
||||
}
|
||||
} else {
|
||||
it = this->packets.erase(it);
|
||||
if (do_count && loop > 0) {
|
||||
(*cargo_per_source)[cp->source] -= cp->count;
|
||||
(*cargo_per_source)[cp->first_station] -= cp->count;
|
||||
}
|
||||
moved += cp->count;
|
||||
this->RemoveFromCache(cp, cp->count);
|
||||
|
@@ -51,15 +51,15 @@ void ChangeOwnershipOfCargoPacketDeferredPayments(Owner old_owner, Owner new_own
|
||||
*/
|
||||
struct CargoPacket : CargoPacketPool::PoolItem<&_cargopacket_pool> {
|
||||
private:
|
||||
uint16 count; ///< The amount of cargo in this packet.
|
||||
uint16 days_in_transit; ///< Amount of days this packet has been in transit.
|
||||
Money feeder_share; ///< Value of feeder pickup to be paid for on delivery of cargo.
|
||||
TileIndex source_xy; ///< The origin of the cargo (first station in feeder chain).
|
||||
StationID next_station; ///< Station where the cargo wants to go next.
|
||||
SourceID source_id; ///< Index of source, INVALID_SOURCE if unknown/invalid.
|
||||
StationID source; ///< The station where the cargo came from first.
|
||||
SourceType source_type; ///< Type of \c source_id.
|
||||
uint16 count = 0; ///< The amount of cargo in this packet.
|
||||
uint16 periods_in_transit = 0; ///< Amount of cargo aging periods this packet has been in transit.
|
||||
Money feeder_share = 0; ///< Value of feeder pickup to be paid for on delivery of cargo.
|
||||
TileIndex source_xy = 0; ///< The origin of the cargo.
|
||||
SourceID source_id = INVALID_SOURCE; ///< Index of industry/town/HQ, INVALID_SOURCE if unknown/invalid.
|
||||
SourceType source_type = SourceType::Industry; ///< Type of \c source_id.
|
||||
uint8 flags = 0; ///< NOSAVE: temporary flags
|
||||
StationID first_station = INVALID_STATION; ///< The station where the cargo came from first.
|
||||
StationID next_station = INVALID_STATION; ///< Station where the cargo wants to go next.
|
||||
|
||||
/** Cargo packet flag bits in CargoPacket::flags. */
|
||||
enum CargoPacketFlags {
|
||||
@@ -79,8 +79,8 @@ public:
|
||||
static const uint16 MAX_COUNT = UINT16_MAX;
|
||||
|
||||
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, Money feeder_share = 0, SourceType source_type = SourceType::Industry, SourceID source_id = INVALID_SOURCE);
|
||||
CargoPacket(StationID first_station, TileIndex source_xy, uint16 count, SourceType source_type, SourceID source_id);
|
||||
CargoPacket(uint16 count, uint16 periods_in_transit, StationID source, TileIndex source_xy, Money feeder_share = 0, SourceType source_type = SourceType::Industry, SourceID source_id = INVALID_SOURCE);
|
||||
~CargoPacket();
|
||||
|
||||
CargoPacket *Split(uint new_size);
|
||||
@@ -91,13 +91,19 @@ public:
|
||||
* Sets the station where the packet is supposed to go next.
|
||||
* @param next_station Next station the packet should go to.
|
||||
*/
|
||||
void SetNextStation(StationID next_station) { this->next_station = next_station; }
|
||||
void SetNextStation(StationID next_station)
|
||||
{
|
||||
this->next_station = next_station;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds some feeder share to the packet.
|
||||
* @param new_share Feeder share to be added.
|
||||
*/
|
||||
void AddFeederShare(Money new_share) { this->feeder_share += new_share; }
|
||||
void AddFeederShare(Money new_share)
|
||||
{
|
||||
this->feeder_share += new_share;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of 'items' in this packet.
|
||||
@@ -113,7 +119,7 @@ public:
|
||||
* the feeder chain.
|
||||
* @return Feeder share.
|
||||
*/
|
||||
inline Money FeederShare() const
|
||||
inline Money GetFeederShare() const
|
||||
{
|
||||
return this->feeder_share;
|
||||
}
|
||||
@@ -124,7 +130,7 @@ public:
|
||||
* @param part Amount of cargo to get the share for.
|
||||
* @return Feeder share for the given amount of cargo.
|
||||
*/
|
||||
inline Money FeederShare(uint part) const
|
||||
inline Money GetFeederShare(uint part) const
|
||||
{
|
||||
return this->feeder_share * part / static_cast<uint>(this->count);
|
||||
}
|
||||
@@ -138,16 +144,16 @@ public:
|
||||
* it is capped at UINT16_MAX.
|
||||
* @return Length this cargo has been in transit.
|
||||
*/
|
||||
inline uint16 DaysInTransit() const
|
||||
inline uint16 GetPeriodsInTransit() const
|
||||
{
|
||||
return this->days_in_transit;
|
||||
return this->periods_in_transit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type of the cargo's source. industry, town or head quarter.
|
||||
* @return Source type.
|
||||
*/
|
||||
inline SourceType SourceSubsidyType() const
|
||||
inline SourceType GetSourceType() const
|
||||
{
|
||||
return this->source_type;
|
||||
}
|
||||
@@ -156,7 +162,7 @@ public:
|
||||
* Gets the ID of the cargo's source. An IndustryID, TownID or CompanyID.
|
||||
* @return Source ID.
|
||||
*/
|
||||
inline SourceID SourceSubsidyID() const
|
||||
inline SourceID GetSourceID() const
|
||||
{
|
||||
return this->source_id;
|
||||
}
|
||||
@@ -165,16 +171,16 @@ public:
|
||||
* Gets the ID of the station where the cargo was loaded for the first time.
|
||||
* @return StationID.
|
||||
*/
|
||||
inline StationID SourceStation() const
|
||||
inline StationID GetFirstStation() const
|
||||
{
|
||||
return this->source;
|
||||
return this->first_station;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the coordinates of the cargo's source station.
|
||||
* @return Source station's coordinates.
|
||||
* Gets the coordinates of the cargo's source.
|
||||
* @return Source coordinates of cargo.
|
||||
*/
|
||||
inline TileIndex SourceStationXY() const
|
||||
inline TileIndex GetSourceXY() const
|
||||
{
|
||||
return this->source_xy;
|
||||
}
|
||||
@@ -183,7 +189,7 @@ public:
|
||||
* Gets the ID of station the cargo wants to go next.
|
||||
* @return Next station for this packets.
|
||||
*/
|
||||
inline StationID NextStation() const
|
||||
inline StationID GetNextStation() const
|
||||
{
|
||||
return this->next_station;
|
||||
}
|
||||
@@ -224,7 +230,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.
|
||||
|
||||
@@ -252,12 +258,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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -269,9 +275,9 @@ public:
|
||||
return this->count;
|
||||
}
|
||||
|
||||
inline uint64 CargoDaysInTransit() const
|
||||
inline uint64 CargoPeriodsInTransit() const
|
||||
{
|
||||
return this->cargo_days_in_transit;
|
||||
return this->cargo_periods_in_transit;
|
||||
}
|
||||
|
||||
void InvalidateCache();
|
||||
@@ -357,19 +363,19 @@ public:
|
||||
friend class VehicleCargoReroute;
|
||||
|
||||
/**
|
||||
* Returns source of the first cargo packet in this list.
|
||||
* @return The before mentioned source.
|
||||
* Returns the first station of the first cargo packet in this list.
|
||||
* @return The before mentioned station.
|
||||
*/
|
||||
inline StationID Source() const
|
||||
inline StationID GetFirstStation() const
|
||||
{
|
||||
return this->count == 0 ? INVALID_STATION : this->packets.front()->source;
|
||||
return this->count == 0 ? INVALID_STATION : this->packets.front()->first_station;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns total sum of the feeder share for all packets.
|
||||
* @return The before mentioned number.
|
||||
*/
|
||||
inline Money FeederShare() const
|
||||
inline Money GetFeederShare() const
|
||||
{
|
||||
return this->feeder_share;
|
||||
}
|
||||
@@ -463,7 +469,7 @@ 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->periods_in_transit == cp2->periods_in_transit &&
|
||||
cp1->source_type == cp2->source_type &&
|
||||
cp1->source_id == cp2->source_id;
|
||||
}
|
||||
@@ -528,12 +534,12 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns source of the first cargo packet in this list.
|
||||
* @return The before mentioned source.
|
||||
* Returns first station of the first cargo packet in this list.
|
||||
* @return The before mentioned station.
|
||||
*/
|
||||
inline StationID Source() const
|
||||
inline StationID GetFirstStation() const
|
||||
{
|
||||
return this->count == 0 ? INVALID_STATION : this->packets.begin()->second.front()->source;
|
||||
return this->count == 0 ? INVALID_STATION : this->packets.begin()->second.front()->first_station;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -597,7 +603,7 @@ 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->periods_in_transit == cp2->periods_in_transit &&
|
||||
cp1->source_type == cp2->source_type &&
|
||||
cp1->source_id == cp2->source_id;
|
||||
}
|
||||
|
@@ -62,7 +62,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.
|
||||
|
@@ -1088,7 +1088,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()) {
|
||||
@@ -1098,7 +1098,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);
|
||||
@@ -1118,22 +1118,22 @@ 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;
|
||||
|
||||
if (_settings_game.economy.payment_algorithm == CPA_TRADITIONAL) transit_days = std::min<uint16>(transit_days, 0xFFu);
|
||||
if (_settings_game.economy.payment_algorithm == CPA_TRADITIONAL) transit_periods = std::min<uint16>(transit_periods, 0xFFu);
|
||||
|
||||
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 = 0;
|
||||
if (_settings_game.economy.payment_algorithm == CPA_MODERN) {
|
||||
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
|
||||
@@ -1142,11 +1142,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);
|
||||
}
|
||||
}
|
||||
@@ -1323,14 +1323,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 ravel 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);
|
||||
|
||||
@@ -1357,7 +1357,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);
|
||||
@@ -1462,9 +1462,9 @@ void CargoPayment::PayFinalDelivery(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->GetSourceXY(), cp->GetPeriodsInTransit(), this->owner, cp->GetSourceType(), cp->GetSourceID());
|
||||
|
||||
profit -= cp->FeederShare(count);
|
||||
profit -= cp->GetFeederShare(count);
|
||||
|
||||
/* For Infrastructure patch. Handling transfers between other companies */
|
||||
this->route_profit += profit;
|
||||
@@ -1482,12 +1482,12 @@ void CargoPayment::PayFinalDelivery(CargoPacket *cp, uint count)
|
||||
*/
|
||||
Money CargoPayment::PayTransfer(CargoPacket *cp, uint count)
|
||||
{
|
||||
Money profit = -cp->FeederShare(count) + GetTransportedGoodsIncome(
|
||||
Money profit = -cp->GetFeederShare(count) + GetTransportedGoodsIncome(
|
||||
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(),
|
||||
DistanceManhattan(cp->GetSourceXY(), Station::Get(this->current_station)->xy),
|
||||
cp->GetPeriodsInTransit(),
|
||||
this->ct);
|
||||
|
||||
profit = profit * _settings_game.economy.feeder_payment_share / 100;
|
||||
|
@@ -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);
|
||||
|
@@ -3062,11 +3062,11 @@ static ChangeInfoResult CargoChangeInfo(uint cid, int numinfo, int prop, const G
|
||||
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
|
||||
|
@@ -983,8 +983,8 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
|
||||
case 0x3B: return GB(v->cargo_cap, 8, 8);
|
||||
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 0x3E: return v->cargo.GetFirstStation();
|
||||
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);
|
||||
|
@@ -452,7 +452,7 @@ uint32 Station::GetNewGRFVariable(const ResolverObject &object, uint16 variable,
|
||||
case 0x60: return std::min<uint32>(ge->CargoTotalCount(), 4095);
|
||||
case 0x61: return ge->HasVehicleEverTriedLoading() && ge->IsSupplyAllowed() ? ge->time_since_pickup : 0;
|
||||
case 0x62: return ge->HasRating() ? ge->rating : 0xFFFFFFFF;
|
||||
case 0x63: return ge->data != nullptr ? ge->data->cargo.DaysInTransit() : 0;
|
||||
case 0x63: return ge->data != nullptr ? ge->data->cargo.PeriodsInTransit() : 0;
|
||||
case 0x64: return ge->HasVehicleEverTriedLoading() && ge->IsSupplyAllowed() ? ge->last_speed | (ge->last_age << 8) : 0xFF00;
|
||||
case 0x65: return GB(ge->status, GoodsEntry::GES_ACCEPTANCE, 1) << 3;
|
||||
case 0x69: {
|
||||
@@ -472,8 +472,8 @@ uint32 Station::GetNewGRFVariable(const ResolverObject &object, uint16 variable,
|
||||
case 1: return GB(std::min(g->CargoTotalCount(), 4095u), 0, 4) | (GB(g->status, GoodsEntry::GES_ACCEPTANCE, 1) << 7);
|
||||
case 2: return g->time_since_pickup;
|
||||
case 3: return g->rating;
|
||||
case 4: return g->data != nullptr ? g->data->cargo.Source() : INVALID_STATION;
|
||||
case 5: return g->data != nullptr ? g->data->cargo.DaysInTransit() : 0;
|
||||
case 4: return g->data != nullptr ? g->data->cargo.GetFirstStation() : INVALID_STATION;
|
||||
case 5: return g->data != nullptr ? g->data->cargo.PeriodsInTransit() : 0;
|
||||
case 6: return g->last_speed;
|
||||
case 7: return g->last_age;
|
||||
}
|
||||
|
@@ -1898,21 +1898,21 @@ void CheckCaches(bool force_check, std::function<void(const char *)> log, CheckC
|
||||
|
||||
/* Check whether the caches are still valid */
|
||||
for (Vehicle *v : Vehicle::Iterate()) {
|
||||
Money old_feeder_share = v->cargo.FeederShare();
|
||||
Money old_feeder_share = v->cargo.GetFeederShare();
|
||||
uint old_count = v->cargo.TotalCount();
|
||||
uint64 old_cargo_days_in_transit = v->cargo.CargoDaysInTransit();
|
||||
uint64 old_cargo_periods_in_transit = v->cargo.CargoPeriodsInTransit();
|
||||
|
||||
v->cargo.InvalidateCache();
|
||||
|
||||
uint changed = 0;
|
||||
if (v->cargo.FeederShare() != old_feeder_share) SetBit(changed, 0);
|
||||
if (v->cargo.GetFeederShare() != old_feeder_share) SetBit(changed, 0);
|
||||
if (v->cargo.TotalCount() != old_count) SetBit(changed, 1);
|
||||
if (v->cargo.CargoDaysInTransit() != old_cargo_days_in_transit) SetBit(changed, 2);
|
||||
if (v->cargo.CargoPeriodsInTransit() != old_cargo_periods_in_transit) SetBit(changed, 2);
|
||||
if (changed != 0) {
|
||||
CCLOGV1("vehicle cargo cache mismatch: %c%c%c",
|
||||
HasBit(changed, 0) ? 'f' : '-',
|
||||
HasBit(changed, 1) ? 't' : '-',
|
||||
HasBit(changed, 2) ? 'd' : '-');
|
||||
HasBit(changed, 2) ? 'p' : '-');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1921,13 +1921,13 @@ void CheckCaches(bool force_check, std::function<void(const char *)> log, CheckC
|
||||
if (st->goods[c].data == nullptr) continue;
|
||||
|
||||
uint old_count = st->goods[c].data->cargo.TotalCount();
|
||||
uint64 old_cargo_days_in_transit = st->goods[c].data->cargo.CargoDaysInTransit();
|
||||
uint64 old_cargo_periods_in_transit = st->goods[c].data->cargo.CargoPeriodsInTransit();
|
||||
|
||||
st->goods[c].data->cargo.InvalidateCache();
|
||||
|
||||
uint changed = 0;
|
||||
if (st->goods[c].data->cargo.TotalCount() != old_count) SetBit(changed, 0);
|
||||
if (st->goods[c].data->cargo.CargoDaysInTransit() != old_cargo_days_in_transit) SetBit(changed, 1);
|
||||
if (st->goods[c].data->cargo.CargoPeriodsInTransit() != old_cargo_periods_in_transit) SetBit(changed, 1);
|
||||
if (changed != 0) {
|
||||
CCLOG("station cargo cache mismatch: station %i, company %i, cargo %u: %c%c",
|
||||
st->index, (int)st->owner, c,
|
||||
|
@@ -81,9 +81,9 @@ void DrawRoadVehDetails(const Vehicle *v, const Rect &r)
|
||||
if (u->cargo.StoredCount() > 0) {
|
||||
SetDParam(0, u->cargo_type);
|
||||
SetDParam(1, u->cargo.StoredCount());
|
||||
SetDParam(2, u->cargo.Source());
|
||||
SetDParam(2, u->cargo.GetFirstStation());
|
||||
str = STR_VEHICLE_DETAILS_CARGO_FROM;
|
||||
feeder_share += u->cargo.FeederShare();
|
||||
feeder_share += u->cargo.GetFeederShare();
|
||||
}
|
||||
DrawString(r.left, r.right, y, str);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
@@ -100,9 +100,9 @@ void DrawRoadVehDetails(const Vehicle *v, const Rect &r)
|
||||
if (v->cargo.StoredCount() > 0) {
|
||||
SetDParam(0, v->cargo_type);
|
||||
SetDParam(1, v->cargo.StoredCount());
|
||||
SetDParam(2, v->cargo.Source());
|
||||
SetDParam(2, v->cargo.GetFirstStation());
|
||||
str = STR_VEHICLE_DETAILS_CARGO_FROM;
|
||||
feeder_share += v->cargo.FeederShare();
|
||||
feeder_share += v->cargo.GetFeederShare();
|
||||
}
|
||||
DrawString(r.left, r.right, y, str);
|
||||
y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
|
||||
|
@@ -27,12 +27,12 @@ namespace upstream_sl {
|
||||
SaveLoadTable GetCargoPacketDesc()
|
||||
{
|
||||
static const SaveLoad _cargopacket_desc[] = {
|
||||
SLE_VAR(CargoPacket, source, SLE_UINT16),
|
||||
SLE_VARNAME(CargoPacket, first_station, "source", SLE_UINT16),
|
||||
SLE_VAR(CargoPacket, source_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, SLV_PERIODS_IN_TRANSIT_RENAME),
|
||||
SLE_CONDVARNAME(CargoPacket, days_in_transit, "periods_in_transit", SLE_UINT16, SLV_PERIODS_IN_TRANSIT_RENAME, 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),
|
||||
|
@@ -455,6 +455,15 @@ struct SaveLoadCompat {
|
||||
#define SLE_VAR(base, variable, type) SLE_CONDVAR(base, variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
|
||||
#define SLE_VAR2(base, name, variable, type) SLE_CONDVARNAME(base, variable, name, type, SL_MIN_VERSION, SL_MAX_VERSION)
|
||||
|
||||
/**
|
||||
* Storage of a variable in every version of a savegame.
|
||||
* @param base Name of the class or struct containing the variable.
|
||||
* @param variable Name of the variable in the class or struct referenced by \a base.
|
||||
* @param name Field name for table chunks.
|
||||
* @param type Storage of the data in memory and in the savegame.
|
||||
*/
|
||||
#define SLE_VARNAME(base, variable, name, type) SLE_CONDVARNAME(base, variable, name, type, SL_MIN_VERSION, SL_MAX_VERSION)
|
||||
|
||||
/**
|
||||
* Storage of a reference in every version of a savegame.
|
||||
* @param base Name of the class or struct containing the variable.
|
||||
|
@@ -35,7 +35,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;
|
||||
|
||||
CargoPacketList _packets;
|
||||
@@ -223,7 +223,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),
|
||||
@@ -305,7 +305,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_feeder_share);
|
||||
CargoPacket *cp = new CargoPacket(GB(_waiting_acceptance, 0, 12), _cargo_periods, source, _cargo_source_xy, _cargo_feeder_share);
|
||||
ge->data->cargo.Append(cp, INVALID_STATION);
|
||||
SB(ge->status, GoodsEntry::GES_RATING, 1, 1);
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ static std::vector<TileIndex> _path_tile;
|
||||
|
||||
namespace upstream_sl {
|
||||
|
||||
static uint8 _cargo_days;
|
||||
static uint8 _cargo_periods;
|
||||
static uint16 _cargo_source;
|
||||
static uint32 _cargo_source_xy;
|
||||
static uint16 _cargo_count;
|
||||
@@ -94,7 +94,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),
|
||||
@@ -533,7 +533,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_feeder_share);
|
||||
CargoPacket *cp = new CargoPacket(_cargo_count, _cargo_periods, _cargo_source, _cargo_source_xy, _cargo_feeder_share);
|
||||
v->cargo.Append(cp);
|
||||
}
|
||||
|
||||
|
@@ -71,7 +71,7 @@ template<bool Tfrom, bool Tvia>
|
||||
StationCargoList::ConstIterator(cargo_list.Packets()->end()));
|
||||
for (StationCargoList::ConstIterator it = range.first; it != range.second; it++) {
|
||||
const CargoPacket *cp = *it;
|
||||
if (!Tfrom || cp->SourceStation() == from_station_id) cargo_count += cp->Count();
|
||||
if (!Tfrom || cp->GetFirstStation() == from_station_id) cargo_count += cp->Count();
|
||||
}
|
||||
|
||||
return cargo_count;
|
||||
|
@@ -177,7 +177,7 @@ void ScriptStationList_CargoWaiting::Add(StationID station_id, CargoID cargo, St
|
||||
StationCargoList::ConstIterator iter = ge->data->cargo.Packets()->begin();
|
||||
StationCargoList::ConstIterator end = ge->data->cargo.Packets()->end();
|
||||
for (; iter != end; ++iter) {
|
||||
collector.Update<Tselector>((*iter)->SourceStation(), iter.GetKey(), (*iter)->Count());
|
||||
collector.Update<Tselector>((*iter)->GetFirstStation(), iter.GetKey(), (*iter)->Count());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ ScriptStationList_CargoWaitingViaByFrom::ScriptStationList_CargoWaitingViaByFrom
|
||||
std::pair<StationCargoList::ConstIterator, StationCargoList::ConstIterator> range =
|
||||
ge->data->cargo.Packets()->equal_range(via);
|
||||
for (StationCargoList::ConstIterator iter = range.first; iter != range.second; ++iter) {
|
||||
collector.Update<CS_VIA_BY_FROM>((*iter)->SourceStation(), iter.GetKey(), (*iter)->Count());
|
||||
collector.Update<CS_VIA_BY_FROM>((*iter)->GetFirstStation(), iter.GetKey(), (*iter)->Count());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -119,9 +119,9 @@ void DrawShipDetails(const Vehicle *v, const Rect &r)
|
||||
if (u->cargo.StoredCount() > 0) {
|
||||
SetDParam(0, u->cargo_type);
|
||||
SetDParam(1, u->cargo.StoredCount());
|
||||
SetDParam(2, u->cargo.Source());
|
||||
SetDParam(2, u->cargo.GetFirstStation());
|
||||
str = STR_VEHICLE_DETAILS_CARGO_FROM;
|
||||
feeder_share += u->cargo.FeederShare();
|
||||
feeder_share += u->cargo.GetFeederShare();
|
||||
}
|
||||
DrawString(r.left, r.right, y, str);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
@@ -138,9 +138,9 @@ void DrawShipDetails(const Vehicle *v, const Rect &r)
|
||||
if (v->cargo.StoredCount() > 0) {
|
||||
SetDParam(0, v->cargo_type);
|
||||
SetDParam(1, v->cargo.StoredCount());
|
||||
SetDParam(2, v->cargo.Source());
|
||||
SetDParam(2, v->cargo.GetFirstStation());
|
||||
str = STR_VEHICLE_DETAILS_CARGO_FROM;
|
||||
feeder_share += v->cargo.FeederShare();
|
||||
feeder_share += v->cargo.GetFeederShare();
|
||||
}
|
||||
DrawString(r.left, r.right, y, str);
|
||||
y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
|
||||
|
@@ -26,22 +26,22 @@ extern btree::btree_map<uint64, Money> _cargo_packet_deferred_payments;
|
||||
{
|
||||
if (IsSavegameVersionBefore(SLV_44)) {
|
||||
/* If we remove a station while cargo from it is still en route, payment calculation will assume
|
||||
* 0, 0 to be the source of the cargo, resulting in very high payments usually. v->source_xy
|
||||
* 0, 0 to be the first_station of the cargo, resulting in very high payments usually. v->source_xy
|
||||
* stores the coordinates, preserving them even if the station is removed. However, if a game is loaded
|
||||
* where this situation exists, the cargo-source information is lost. in this case, we set the source
|
||||
* where this situation exists, the cargo-first_station information is lost. in this case, we set the first_station
|
||||
* to the current tile of the vehicle to prevent excessive profits
|
||||
*/
|
||||
for (const Vehicle *v : Vehicle::Iterate()) {
|
||||
const CargoPacketList *packets = v->cargo.Packets();
|
||||
for (VehicleCargoList::ConstIterator it(packets->begin()); it != packets->end(); it++) {
|
||||
CargoPacket *cp = *it;
|
||||
cp->source_xy = Station::IsValidID(cp->source) ? Station::Get(cp->source)->xy : v->tile;
|
||||
cp->source_xy = Station::IsValidID(cp->first_station) ? Station::Get(cp->first_station)->xy : v->tile;
|
||||
}
|
||||
}
|
||||
|
||||
/* Store position of the station where the goods come from, so there
|
||||
* are no very high payments when stations get removed. However, if the
|
||||
* station where the goods came from is already removed, the source
|
||||
* station where the goods came from is already removed, the first_station
|
||||
* information is lost. In that case we set it to the position of this
|
||||
* station */
|
||||
for (Station *st : Station::Iterate()) {
|
||||
@@ -52,16 +52,16 @@ extern btree::btree_map<uint64, Money> _cargo_packet_deferred_payments;
|
||||
const StationCargoPacketMap *packets = ge->data->cargo.Packets();
|
||||
for (StationCargoList::ConstIterator it(packets->begin()); it != packets->end(); it++) {
|
||||
CargoPacket *cp = *it;
|
||||
cp->source_xy = Station::IsValidID(cp->source) ? Station::Get(cp->source)->xy : st->xy;
|
||||
cp->source_xy = Station::IsValidID(cp->first_station) ? Station::Get(cp->first_station)->xy : st->xy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (IsSavegameVersionBefore(SLV_120)) {
|
||||
/* CargoPacket's source should be either INVALID_STATION or a valid station */
|
||||
/* CargoPacket's first_station should be either INVALID_STATION or a valid station */
|
||||
for (CargoPacket *cp : CargoPacket::Iterate()) {
|
||||
if (!Station::IsValidID(cp->source)) cp->source = INVALID_STATION;
|
||||
if (!Station::IsValidID(cp->first_station)) cp->first_station = INVALID_STATION;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,12 +112,12 @@ extern btree::btree_map<uint64, Money> _cargo_packet_deferred_payments;
|
||||
SaveLoadTable GetCargoPacketDesc()
|
||||
{
|
||||
static const SaveLoad _cargopacket_desc[] = {
|
||||
SLE_VAR(CargoPacket, source, SLE_UINT16),
|
||||
SLE_VAR(CargoPacket, first_station, SLE_UINT16),
|
||||
SLE_VAR(CargoPacket, source_xy, SLE_UINT32),
|
||||
SLE_VAR(CargoPacket, next_station, SLE_FILE_U32 | SLE_VAR_U16),
|
||||
SLE_VAR(CargoPacket, count, SLE_UINT16),
|
||||
SLE_CONDVAR_X(CargoPacket, days_in_transit, SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_MORE_CARGO_AGE, 0, 0)),
|
||||
SLE_CONDVAR_X(CargoPacket, days_in_transit, SLE_UINT16, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_MORE_CARGO_AGE)),
|
||||
SLE_CONDVAR_X(CargoPacket, periods_in_transit, SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_MORE_CARGO_AGE, 0, 0)),
|
||||
SLE_CONDVAR_X(CargoPacket, periods_in_transit, SLE_UINT16, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_MORE_CARGO_AGE)),
|
||||
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),
|
||||
|
@@ -679,14 +679,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 ),
|
||||
|
||||
@@ -706,7 +706,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->CreateData().cargo.Append(new CargoPacket(GB(_waiting_acceptance, 0, 12), _cargo_days, (_cargo_source == 0xFF) ? INVALID_STATION : _cargo_source, 0, 0),
|
||||
ge->CreateData().cargo.Append(new CargoPacket(GB(_waiting_acceptance, 0, 12), _cargo_periods, (_cargo_source == 0xFF) ? INVALID_STATION : _cargo_source, 0, 0),
|
||||
INVALID_STATION);
|
||||
}
|
||||
|
||||
@@ -1172,7 +1172,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 : 0;
|
||||
v->cargo.Append(new CargoPacket(_cargo_count, _cargo_days, source, source_xy));
|
||||
v->cargo.Append(new CargoPacket(_cargo_count, _cargo_periods, source, source_xy));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -235,7 +235,7 @@ static uint16 _waiting_acceptance;
|
||||
static uint32 _num_flows;
|
||||
static uint16 _cargo_source;
|
||||
static uint32 _cargo_source_xy;
|
||||
static uint8 _cargo_days;
|
||||
static uint8 _cargo_periods;
|
||||
static Money _cargo_feeder_share;
|
||||
static uint _cargo_reserved_count;
|
||||
|
||||
@@ -288,7 +288,7 @@ SaveLoadTable GetGoodsDesc()
|
||||
SLEG_CONDVAR( _cargo_source, SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SLV_7),
|
||||
SLEG_CONDVAR( _cargo_source, SLE_UINT16, SLV_7, SLV_68),
|
||||
SLEG_CONDVAR( _cargo_source_xy, SLE_UINT32, SLV_44, SLV_68),
|
||||
SLEG_CONDVAR( _cargo_days, SLE_UINT8, SL_MIN_VERSION, SLV_68),
|
||||
SLEG_CONDVAR( _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, SLE_FILE_U32 | SLE_VAR_I64, SLV_14, SLV_65),
|
||||
@@ -342,7 +342,7 @@ static void SwapPackets(GoodsEntry *ge)
|
||||
static void Load_STNS()
|
||||
{
|
||||
_cargo_source_xy = 0;
|
||||
_cargo_days = 0;
|
||||
_cargo_periods = 0;
|
||||
_cargo_feeder_share = 0;
|
||||
_num_specs = 0;
|
||||
_cargo_reserved_count = 0;
|
||||
@@ -374,7 +374,7 @@ static void Load_STNS()
|
||||
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_feeder_share);
|
||||
CargoPacket *cp = new CargoPacket(GB(_waiting_acceptance, 0, 12), _cargo_periods, source, _cargo_source_xy, _cargo_feeder_share);
|
||||
ge->CreateData().cargo.Append(cp, INVALID_STATION);
|
||||
SB(ge->status, GoodsEntry::GES_RATING, 1, 1);
|
||||
}
|
||||
|
@@ -635,7 +635,7 @@ void FixupTrainLengths()
|
||||
}
|
||||
}
|
||||
|
||||
static uint8 _cargo_days;
|
||||
static uint8 _cargo_periods;
|
||||
static uint16 _cargo_source;
|
||||
static uint32 _cargo_source_xy;
|
||||
static uint16 _cargo_count;
|
||||
@@ -698,7 +698,7 @@ SaveLoadTable GetVehicleDescription(VehicleType vt)
|
||||
|
||||
SLE_VAR(Vehicle, cargo_type, SLE_UINT8),
|
||||
SLE_CONDVAR(Vehicle, cargo_subtype, SLE_UINT8, SLV_35, SL_MAX_VERSION),
|
||||
SLEG_CONDVAR( _cargo_days, SLE_UINT8, SL_MIN_VERSION, SLV_68),
|
||||
SLEG_CONDVAR( _cargo_periods, SLE_UINT8, SL_MIN_VERSION, SLV_68),
|
||||
SLEG_CONDVAR( _cargo_source, SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SLV_7),
|
||||
SLEG_CONDVAR( _cargo_source, SLE_UINT16, SLV_7, SLV_68),
|
||||
SLEG_CONDVAR( _cargo_source_xy, SLE_UINT32, SLV_44, SLV_68),
|
||||
@@ -1095,7 +1095,7 @@ void Load_VEHS()
|
||||
|
||||
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_feeder_share);
|
||||
CargoPacket *cp = new CargoPacket(_cargo_count, _cargo_periods, _cargo_source, _cargo_source_xy, _cargo_feeder_share);
|
||||
v->cargo.Append(cp);
|
||||
}
|
||||
|
||||
|
@@ -1766,15 +1766,15 @@ struct StationViewWindow : public Window {
|
||||
const CargoPacket *cp = *it;
|
||||
StationID next = it.GetKey();
|
||||
|
||||
const CargoDataEntry *source_entry = source_dest->Retrieve(cp->SourceStation());
|
||||
const CargoDataEntry *source_entry = source_dest->Retrieve(cp->GetFirstStation());
|
||||
if (source_entry == nullptr) {
|
||||
this->ShowCargo(cargo, i, cp->SourceStation(), next, INVALID_STATION, cp->Count());
|
||||
this->ShowCargo(cargo, i, cp->GetFirstStation(), next, INVALID_STATION, cp->Count());
|
||||
continue;
|
||||
}
|
||||
|
||||
const CargoDataEntry *via_entry = source_entry->Retrieve(next);
|
||||
if (via_entry == nullptr) {
|
||||
this->ShowCargo(cargo, i, cp->SourceStation(), next, INVALID_STATION, cp->Count());
|
||||
this->ShowCargo(cargo, i, cp->GetFirstStation(), next, INVALID_STATION, cp->Count());
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1795,7 +1795,7 @@ struct StationViewWindow : public Window {
|
||||
val = std::min<uint>(remaining, DivideApprox(cp->Count() * dest_entry->GetCount(), via_entry->GetCount()));
|
||||
remaining -= val;
|
||||
}
|
||||
this->ShowCargo(cargo, i, cp->SourceStation(), next, dest_entry->GetStation(), val);
|
||||
this->ShowCargo(cargo, i, cp->GetFirstStation(), next, dest_entry->GetStation(), val);
|
||||
}
|
||||
}
|
||||
this->ShowCargo(cargo, i, NEW_STATION, NEW_STATION, NEW_STATION, packets.ReservedCount());
|
||||
|
@@ -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,
|
||||
|
@@ -1286,8 +1286,8 @@ class NIHCargo : public NIHelper {
|
||||
|
||||
seprintf(buffer, lastof(buffer), " Weight: %u, Capacity multiplier: %u", spec->weight, spec->multiplier);
|
||||
output.print(buffer);
|
||||
seprintf(buffer, lastof(buffer), " Initial payment: %d, Current payment: " OTTD_PRINTF64 ", Transit days: (%u, %u)",
|
||||
spec->initial_payment, (int64)spec->current_payment, spec->transit_days[0], spec->transit_days[1]);
|
||||
seprintf(buffer, lastof(buffer), " Initial payment: %d, Current payment: " OTTD_PRINTF64 ", Transit periods: (%u, %u)",
|
||||
spec->initial_payment, (int64)spec->current_payment, spec->transit_periods[0], spec->transit_periods[1]);
|
||||
output.print(buffer);
|
||||
seprintf(buffer, lastof(buffer), " Freight: %s, Town effect: %u", spec->is_freight ? "yes" : "no", spec->town_effect);
|
||||
output.print(buffer);
|
||||
|
@@ -349,7 +349,7 @@ static void GetCargoSummaryOfArticulatedVehicle(const Train *v, CargoSummary *su
|
||||
|
||||
item->capacity += v->cargo_cap;
|
||||
item->amount += v->cargo.StoredCount();
|
||||
if (item->source == INVALID_STATION) item->source = v->cargo.Source();
|
||||
if (item->source == INVALID_STATION) item->source = v->cargo.GetFirstStation();
|
||||
} while ((v = v->Next()) != nullptr && v->IsArticulatedPart());
|
||||
}
|
||||
|
||||
@@ -515,7 +515,7 @@ void DrawTrainDetails(const Train *v, const Rect &r, int vscroll_pos, uint16 vsc
|
||||
const auto weight_without_cargo = train->GetWeightWithoutCargo();
|
||||
act_cargo[u->cargo_type] += u->cargo.StoredCount();
|
||||
max_cargo[u->cargo_type] += u->cargo_cap;
|
||||
feeder_share += u->cargo.FeederShare();
|
||||
feeder_share += u->cargo.GetFeederShare();
|
||||
empty_weight += weight_without_cargo;
|
||||
loaded_weight += weight_without_cargo + train->GetCargoWeight(train->cargo_cap);
|
||||
}
|
||||
@@ -565,7 +565,7 @@ void DrawTrainDetails(const Train *v, const Rect &r, int vscroll_pos, uint16 vsc
|
||||
for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
|
||||
act_cargo[u->cargo_type] += u->cargo.StoredCount();
|
||||
max_cargo[u->cargo_type] += u->cargo_cap;
|
||||
feeder_share += u->cargo.FeederShare();
|
||||
feeder_share += u->cargo.GetFeederShare();
|
||||
}
|
||||
|
||||
if (--vscroll_pos < 0 && vscroll_pos >= -vscroll_cap) {
|
||||
|
Reference in New Issue
Block a user