Codechange: remove loaded_at_xy from CargoPacket as it was unused (#11276)
(cherry picked from commit b0e73277d6
)
This commit is contained in:

committed by
Jonathan G Rennison

parent
186a082613
commit
2890127675
@@ -120,7 +120,6 @@ bool CargoLoad::operator()(CargoPacket *cp)
|
|||||||
{
|
{
|
||||||
CargoPacket *cp_new = this->Preprocess(cp);
|
CargoPacket *cp_new = this->Preprocess(cp);
|
||||||
if (cp_new == nullptr) return false;
|
if (cp_new == nullptr) return false;
|
||||||
cp_new->SetLoadPlace(this->load_place);
|
|
||||||
this->source->RemoveFromCache(cp_new, cp_new->Count());
|
this->source->RemoveFromCache(cp_new, cp_new->Count());
|
||||||
this->destination->Append(cp_new, VehicleCargoList::MTA_KEEP);
|
this->destination->Append(cp_new, VehicleCargoList::MTA_KEEP);
|
||||||
return cp_new == cp;
|
return cp_new == cp;
|
||||||
@@ -135,7 +134,6 @@ bool CargoReservation::operator()(CargoPacket *cp)
|
|||||||
{
|
{
|
||||||
CargoPacket *cp_new = this->Preprocess(cp);
|
CargoPacket *cp_new = this->Preprocess(cp);
|
||||||
if (cp_new == nullptr) return false;
|
if (cp_new == nullptr) return false;
|
||||||
cp_new->SetLoadPlace(this->load_place);
|
|
||||||
this->source->reserved_count += cp_new->Count();
|
this->source->reserved_count += cp_new->Count();
|
||||||
this->source->RemoveFromCache(cp_new, cp_new->Count());
|
this->source->RemoveFromCache(cp_new, cp_new->Count());
|
||||||
this->destination->Append(cp_new, VehicleCargoList::MTA_LOAD);
|
this->destination->Append(cp_new, VehicleCargoList::MTA_LOAD);
|
||||||
|
@@ -78,19 +78,17 @@ public:
|
|||||||
|
|
||||||
/** Action of loading cargo from a station onto a vehicle. */
|
/** Action of loading cargo from a station onto a vehicle. */
|
||||||
class CargoLoad : public CargoMovement<StationCargoList, VehicleCargoList> {
|
class CargoLoad : public CargoMovement<StationCargoList, VehicleCargoList> {
|
||||||
protected:
|
|
||||||
TileIndex load_place; ///< TileIndex to be saved in the packets' loaded_at_xy.
|
|
||||||
public:
|
public:
|
||||||
CargoLoad(StationCargoList *source, VehicleCargoList *destination, uint max_move, TileIndex load_place) :
|
CargoLoad(StationCargoList *source, VehicleCargoList *destination, uint max_move) :
|
||||||
CargoMovement<StationCargoList, VehicleCargoList>(source, destination, max_move), load_place(load_place) {}
|
CargoMovement<StationCargoList, VehicleCargoList>(source, destination, max_move) {}
|
||||||
bool operator()(CargoPacket *cp);
|
bool operator()(CargoPacket *cp);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Action of reserving cargo from a station to be loaded onto a vehicle. */
|
/** Action of reserving cargo from a station to be loaded onto a vehicle. */
|
||||||
class CargoReservation : public CargoLoad {
|
class CargoReservation : public CargoLoad {
|
||||||
public:
|
public:
|
||||||
CargoReservation(StationCargoList *source, VehicleCargoList *destination, uint max_move, TileIndex load_place) :
|
CargoReservation(StationCargoList *source, VehicleCargoList *destination, uint max_move) :
|
||||||
CargoLoad(source, destination, max_move, load_place) {}
|
CargoLoad(source, destination, max_move) {}
|
||||||
bool operator()(CargoPacket *cp);
|
bool operator()(CargoPacket *cp);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -122,7 +122,6 @@ CargoPacket::CargoPacket(StationID source, TileIndex source_xy, uint16 count, So
|
|||||||
days_in_transit(0),
|
days_in_transit(0),
|
||||||
feeder_share(0),
|
feeder_share(0),
|
||||||
source_xy(source_xy),
|
source_xy(source_xy),
|
||||||
loaded_at_xy(0),
|
|
||||||
source_id(source_id),
|
source_id(source_id),
|
||||||
source(source),
|
source(source),
|
||||||
source_type(source_type)
|
source_type(source_type)
|
||||||
@@ -137,19 +136,17 @@ CargoPacket::CargoPacket(StationID source, TileIndex source_xy, uint16 count, So
|
|||||||
* @param days_in_transit Number of days the cargo has been in transit.
|
* @param days_in_transit Number of days the cargo has been in transit.
|
||||||
* @param source Station the cargo was initially loaded.
|
* @param source Station the cargo was initially loaded.
|
||||||
* @param source_xy Station location 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.
|
|
||||||
* @param feeder_share Feeder share the packet has already accumulated.
|
* @param feeder_share Feeder share the packet has already accumulated.
|
||||||
* @param source_type 'Type' of source the packet comes from (for subsidies).
|
* @param source_type 'Type' of source the packet comes from (for subsidies).
|
||||||
* @param source_id Actual source of the packet (for subsidies).
|
* @param source_id Actual source of the packet (for subsidies).
|
||||||
* @note We have to zero memory ourselves here because we are using a 'new'
|
* @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.
|
* 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 days_in_transit, StationID source, TileIndex source_xy, Money feeder_share, SourceType source_type, SourceID source_id) :
|
||||||
count(count),
|
count(count),
|
||||||
days_in_transit(days_in_transit),
|
days_in_transit(days_in_transit),
|
||||||
feeder_share(feeder_share),
|
feeder_share(feeder_share),
|
||||||
source_xy(source_xy),
|
source_xy(source_xy),
|
||||||
loaded_at_xy(loaded_at_xy),
|
|
||||||
source_id(source_id),
|
source_id(source_id),
|
||||||
source(source),
|
source(source),
|
||||||
source_type(source_type)
|
source_type(source_type)
|
||||||
@@ -177,7 +174,7 @@ CargoPacket *CargoPacket::Split(uint new_size)
|
|||||||
if (!CargoPacket::CanAllocateItem()) return nullptr;
|
if (!CargoPacket::CanAllocateItem()) return nullptr;
|
||||||
|
|
||||||
Money fs = this->FeederShare(new_size);
|
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->days_in_transit, this->source, this->source_xy, fs, this->source_type, this->source_id);
|
||||||
this->feeder_share -= fs;
|
this->feeder_share -= fs;
|
||||||
|
|
||||||
if (this->flags & CPF_HAS_DEFERRED_PAYMENT) {
|
if (this->flags & CPF_HAS_DEFERRED_PAYMENT) {
|
||||||
@@ -576,23 +573,6 @@ void VehicleCargoList::AgeCargo()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets loaded_at_xy to the current station for all cargo to be transferred.
|
|
||||||
* This is done when stopping or skipping while the vehicle is unloading. In
|
|
||||||
* that case the vehicle will get part of its transfer credits early and it may
|
|
||||||
* get more transfer credits than it's entitled to.
|
|
||||||
* @param xy New loaded_at_xy for the cargo.
|
|
||||||
*/
|
|
||||||
void VehicleCargoList::SetTransferLoadPlace(TileIndex xy)
|
|
||||||
{
|
|
||||||
uint sum = 0;
|
|
||||||
for (Iterator it = this->packets.begin(); sum < this->action_counts[MTA_TRANSFER]; ++it) {
|
|
||||||
CargoPacket *cp = *it;
|
|
||||||
cp->loaded_at_xy = xy;
|
|
||||||
sum += cp->count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Choose action to be performed with the given cargo packet.
|
* Choose action to be performed with the given cargo packet.
|
||||||
* @param cp The packet.
|
* @param cp The packet.
|
||||||
@@ -1097,13 +1077,12 @@ uint StationCargoList::Truncate(uint max_move, StationCargoAmountMap *cargo_per_
|
|||||||
* Reserves cargo for loading onto the vehicle.
|
* Reserves cargo for loading onto the vehicle.
|
||||||
* @param max_move Maximum amount of cargo to reserve.
|
* @param max_move Maximum amount of cargo to reserve.
|
||||||
* @param dest VehicleCargoList to reserve for.
|
* @param dest VehicleCargoList to reserve for.
|
||||||
* @param load_place Tile index of the current station.
|
|
||||||
* @param next_station Next station(s) the loading vehicle will visit.
|
* @param next_station Next station(s) the loading vehicle will visit.
|
||||||
* @return Amount of cargo actually reserved.
|
* @return Amount of cargo actually reserved.
|
||||||
*/
|
*/
|
||||||
uint StationCargoList::Reserve(uint max_move, VehicleCargoList *dest, TileIndex load_place, StationIDStack next_station)
|
uint StationCargoList::Reserve(uint max_move, VehicleCargoList *dest, StationIDStack next_station)
|
||||||
{
|
{
|
||||||
return this->ShiftCargo(CargoReservation(this, dest, max_move, load_place), next_station, true);
|
return this->ShiftCargo(CargoReservation(this, dest, max_move), next_station, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1111,14 +1090,13 @@ uint StationCargoList::Reserve(uint max_move, VehicleCargoList *dest, TileIndex
|
|||||||
* Otherwise load cargo from the station.
|
* Otherwise load cargo from the station.
|
||||||
* @param max_move Amount of cargo to load.
|
* @param max_move Amount of cargo to load.
|
||||||
* @param dest Vehicle cargo list where the cargo resides.
|
* @param dest Vehicle cargo list where the cargo resides.
|
||||||
* @param load_place The new loaded_at_xy to be assigned to packets being moved.
|
|
||||||
* @param next_station Next station(s) the loading vehicle will visit.
|
* @param next_station Next station(s) the loading vehicle will visit.
|
||||||
* @return Amount of cargo actually loaded.
|
* @return Amount of cargo actually loaded.
|
||||||
* @note Vehicles may or may not reserve, depending on their orders. The two
|
* @note Vehicles may or may not reserve, depending on their orders. The two
|
||||||
* modes of loading are exclusive, though. If cargo is reserved we don't
|
* modes of loading are exclusive, though. If cargo is reserved we don't
|
||||||
* need to load unreserved cargo.
|
* need to load unreserved cargo.
|
||||||
*/
|
*/
|
||||||
uint StationCargoList::Load(uint max_move, VehicleCargoList *dest, TileIndex load_place, StationIDStack next_station)
|
uint StationCargoList::Load(uint max_move, VehicleCargoList *dest, StationIDStack next_station)
|
||||||
{
|
{
|
||||||
uint move = std::min(dest->ActionCount(VehicleCargoList::MTA_LOAD), max_move);
|
uint move = std::min(dest->ActionCount(VehicleCargoList::MTA_LOAD), max_move);
|
||||||
if (move > 0) {
|
if (move > 0) {
|
||||||
@@ -1126,7 +1104,7 @@ uint StationCargoList::Load(uint max_move, VehicleCargoList *dest, TileIndex loa
|
|||||||
dest->Reassign<VehicleCargoList::MTA_LOAD, VehicleCargoList::MTA_KEEP>(move);
|
dest->Reassign<VehicleCargoList::MTA_LOAD, VehicleCargoList::MTA_KEEP>(move);
|
||||||
return move;
|
return move;
|
||||||
} else {
|
} else {
|
||||||
return this->ShiftCargo(CargoLoad(this, dest, max_move, load_place), next_station, true);
|
return this->ShiftCargo(CargoLoad(this, dest, max_move), next_station, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -46,13 +46,6 @@ namespace upstream_sl {
|
|||||||
void ClearCargoPacketDeferredPayments();
|
void ClearCargoPacketDeferredPayments();
|
||||||
void ChangeOwnershipOfCargoPacketDeferredPayments(Owner old_owner, Owner new_owner);
|
void ChangeOwnershipOfCargoPacketDeferredPayments(Owner old_owner, Owner new_owner);
|
||||||
|
|
||||||
/**
|
|
||||||
* To make alignment in the union in CargoPacket a bit easier, create a new type
|
|
||||||
* that is a StationID, but stored as 32bit.
|
|
||||||
*/
|
|
||||||
typedef uint32_t StationID_32bit;
|
|
||||||
static_assert(sizeof(TileIndex) == sizeof(StationID_32bit));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Container for cargo from the same location and time.
|
* Container for cargo from the same location and time.
|
||||||
*/
|
*/
|
||||||
@@ -62,10 +55,7 @@ private:
|
|||||||
uint16 days_in_transit; ///< Amount of days this packet has been in transit.
|
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.
|
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).
|
TileIndex source_xy; ///< The origin of the cargo (first station in feeder chain).
|
||||||
union {
|
StationID next_station; ///< Station where the cargo wants to go next.
|
||||||
TileIndex loaded_at_xy; ///< Location where this cargo has been loaded into the vehicle.
|
|
||||||
StationID_32bit next_station; ///< Station where the cargo wants to go next.
|
|
||||||
};
|
|
||||||
SourceID source_id; ///< Index of source, INVALID_SOURCE if unknown/invalid.
|
SourceID source_id; ///< Index of source, INVALID_SOURCE if unknown/invalid.
|
||||||
StationID source; ///< The station where the cargo came from first.
|
StationID source; ///< The station where the cargo came from first.
|
||||||
SourceType source_type; ///< Type of \c source_id.
|
SourceType source_type; ///< Type of \c source_id.
|
||||||
@@ -90,19 +80,13 @@ public:
|
|||||||
|
|
||||||
CargoPacket();
|
CargoPacket();
|
||||||
CargoPacket(StationID source, TileIndex source_xy, uint16 count, SourceType source_type, SourceID source_id);
|
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 days_in_transit, StationID source, TileIndex source_xy, Money feeder_share = 0, SourceType source_type = SourceType::Industry, SourceID source_id = INVALID_SOURCE);
|
||||||
~CargoPacket();
|
~CargoPacket();
|
||||||
|
|
||||||
CargoPacket *Split(uint new_size);
|
CargoPacket *Split(uint new_size);
|
||||||
void Merge(CargoPacket *cp);
|
void Merge(CargoPacket *cp);
|
||||||
void Reduce(uint count);
|
void Reduce(uint count);
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the tile where the packet was loaded last.
|
|
||||||
* @param load_place Tile where the packet was loaded last.
|
|
||||||
*/
|
|
||||||
void SetLoadPlace(TileIndex load_place) { this->loaded_at_xy = load_place; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the station where the packet is supposed to go next.
|
* Sets the station where the packet is supposed to go next.
|
||||||
* @param next_station Next station the packet should go to.
|
* @param next_station Next station the packet should go to.
|
||||||
@@ -195,15 +179,6 @@ public:
|
|||||||
return this->source_xy;
|
return this->source_xy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the coordinates of the cargo's last loading station.
|
|
||||||
* @return Last loading station's coordinates.
|
|
||||||
*/
|
|
||||||
inline TileIndex LoadedAtXY() const
|
|
||||||
{
|
|
||||||
return this->loaded_at_xy;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ID of station the cargo wants to go next.
|
* Gets the ID of station the cargo wants to go next.
|
||||||
* @return Next station for this packets.
|
* @return Next station for this packets.
|
||||||
@@ -452,8 +427,6 @@ public:
|
|||||||
|
|
||||||
void InvalidateCache();
|
void InvalidateCache();
|
||||||
|
|
||||||
void SetTransferLoadPlace(TileIndex xy);
|
|
||||||
|
|
||||||
bool Stage(bool accepted, StationID current_station, StationIDStack next_station, uint8 order_flags, const GoodsEntry *ge, CargoPayment *payment);
|
bool Stage(bool accepted, StationID current_station, StationIDStack next_station, uint8 order_flags, const GoodsEntry *ge, CargoPayment *payment);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -489,11 +462,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
static bool AreMergable(const CargoPacket *cp1, const CargoPacket *cp2)
|
static bool AreMergable(const CargoPacket *cp1, const CargoPacket *cp2)
|
||||||
{
|
{
|
||||||
return cp1->source_xy == cp2->source_xy &&
|
return cp1->source_xy == cp2->source_xy &&
|
||||||
cp1->days_in_transit == cp2->days_in_transit &&
|
cp1->days_in_transit == cp2->days_in_transit &&
|
||||||
cp1->source_type == cp2->source_type &&
|
cp1->source_type == cp2->source_type &&
|
||||||
cp1->source_id == cp2->source_id &&
|
cp1->source_id == cp2->source_id;
|
||||||
cp1->loaded_at_xy == cp2->loaded_at_xy;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -599,8 +571,8 @@ public:
|
|||||||
* amount of cargo to be moved. Second parameter is destination (if
|
* amount of cargo to be moved. Second parameter is destination (if
|
||||||
* applicable), return value is amount of cargo actually moved. */
|
* applicable), return value is amount of cargo actually moved. */
|
||||||
|
|
||||||
uint Reserve(uint max_move, VehicleCargoList *dest, TileIndex load_place, StationIDStack next);
|
uint Reserve(uint max_move, VehicleCargoList *dest, StationIDStack next);
|
||||||
uint Load(uint max_move, VehicleCargoList *dest, TileIndex load_place, StationIDStack next);
|
uint Load(uint max_move, VehicleCargoList *dest, StationIDStack next);
|
||||||
uint Truncate(uint max_move = UINT_MAX, StationCargoAmountMap *cargo_per_source = nullptr);
|
uint Truncate(uint max_move = UINT_MAX, StationCargoAmountMap *cargo_per_source = nullptr);
|
||||||
uint Reroute(uint max_move, StationCargoList *dest, StationID avoid, StationID avoid2, const GoodsEntry *ge);
|
uint Reroute(uint max_move, StationCargoList *dest, StationID avoid, StationID avoid2, const GoodsEntry *ge);
|
||||||
uint RerouteFromSource(uint max_move, StationCargoList *dest, StationID source, StationID avoid, StationID avoid2, const GoodsEntry *ge);
|
uint RerouteFromSource(uint max_move, StationCargoList *dest, StationID source, StationID avoid, StationID avoid2, const GoodsEntry *ge);
|
||||||
|
@@ -1751,7 +1751,7 @@ struct FinalizeRefitAction
|
|||||||
{
|
{
|
||||||
if (this->do_reserve || (cargo_type_loading == nullptr || (cargo_type_loading->current_order.GetCargoLoadTypeRaw(v->cargo_type) & OLFB_FULL_LOAD))) {
|
if (this->do_reserve || (cargo_type_loading == nullptr || (cargo_type_loading->current_order.GetCargoLoadTypeRaw(v->cargo_type) & OLFB_FULL_LOAD))) {
|
||||||
this->st->goods[v->cargo_type].CreateData().cargo.Reserve(v->cargo_cap - v->cargo.RemainingCount(),
|
this->st->goods[v->cargo_type].CreateData().cargo.Reserve(v->cargo_cap - v->cargo.RemainingCount(),
|
||||||
&v->cargo, st->xy, this->next_station.Get(v->cargo_type));
|
&v->cargo, this->next_station.Get(v->cargo_type));
|
||||||
}
|
}
|
||||||
this->consist_capleft[v->cargo_type] += v->cargo_cap - v->cargo.RemainingCount();
|
this->consist_capleft[v->cargo_type] += v->cargo_cap - v->cargo.RemainingCount();
|
||||||
return true;
|
return true;
|
||||||
@@ -1856,7 +1856,7 @@ struct ReserveCargoAction {
|
|||||||
}
|
}
|
||||||
if (v->cargo_cap > v->cargo.RemainingCount() && MayLoadUnderExclusiveRights(st, v)) {
|
if (v->cargo_cap > v->cargo.RemainingCount() && MayLoadUnderExclusiveRights(st, v)) {
|
||||||
st->goods[v->cargo_type].CreateData().cargo.Reserve(v->cargo_cap - v->cargo.RemainingCount(),
|
st->goods[v->cargo_type].CreateData().cargo.Reserve(v->cargo_cap - v->cargo.RemainingCount(),
|
||||||
&v->cargo, st->xy, next_station.Get(v->cargo_type));
|
&v->cargo, next_station.Get(v->cargo_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -2196,7 +2196,7 @@ static void LoadUnloadVehicle(Vehicle *front)
|
|||||||
if (v->cargo.StoredCount() == 0) TriggerVehicle(v, VEHICLE_TRIGGER_NEW_CARGO);
|
if (v->cargo.StoredCount() == 0) TriggerVehicle(v, VEHICLE_TRIGGER_NEW_CARGO);
|
||||||
if (_settings_game.order.gradual_loading) cap_left = std::min(cap_left, GetLoadAmount(v));
|
if (_settings_game.order.gradual_loading) cap_left = std::min(cap_left, GetLoadAmount(v));
|
||||||
|
|
||||||
uint loaded = ged->cargo.Load(cap_left, &v->cargo, st->xy, next_station.Get(v->cargo_type));
|
uint loaded = ged->cargo.Load(cap_left, &v->cargo, next_station.Get(v->cargo_type));
|
||||||
if (v->cargo.ActionCount(VehicleCargoList::MTA_LOAD) > 0) {
|
if (v->cargo.ActionCount(VehicleCargoList::MTA_LOAD) > 0) {
|
||||||
/* Remember if there are reservations left so that we don't stop
|
/* Remember if there are reservations left so that we don't stop
|
||||||
* loading before they're loaded. */
|
* loading before they're loaded. */
|
||||||
|
@@ -29,7 +29,6 @@ SaveLoadTable GetCargoPacketDesc()
|
|||||||
static const SaveLoad _cargopacket_desc[] = {
|
static const SaveLoad _cargopacket_desc[] = {
|
||||||
SLE_VAR(CargoPacket, source, SLE_UINT16),
|
SLE_VAR(CargoPacket, source, SLE_UINT16),
|
||||||
SLE_VAR(CargoPacket, source_xy, SLE_UINT32),
|
SLE_VAR(CargoPacket, source_xy, SLE_UINT32),
|
||||||
SLE_VAR(CargoPacket, loaded_at_xy, SLE_UINT32),
|
|
||||||
SLE_VAR(CargoPacket, count, SLE_UINT16),
|
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_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_CONDVAR(CargoPacket, days_in_transit, SLE_UINT16, SLV_MORE_CARGO_AGE, SLV_PERIODS_IN_TRANSIT_RENAME),
|
||||||
|
@@ -18,7 +18,7 @@ namespace upstream_sl {
|
|||||||
const SaveLoadCompat _cargopacket_sl_compat[] = {
|
const SaveLoadCompat _cargopacket_sl_compat[] = {
|
||||||
SLC_VAR("source"),
|
SLC_VAR("source"),
|
||||||
SLC_VAR("source_xy"),
|
SLC_VAR("source_xy"),
|
||||||
SLC_VAR("loaded_at_xy"),
|
SLC_NULL(4, SL_MIN_VERSION, SLV_REMOVE_LOADED_AT_XY),
|
||||||
SLC_VAR("count"),
|
SLC_VAR("count"),
|
||||||
SLC_VAR("days_in_transit"),
|
SLC_VAR("days_in_transit"),
|
||||||
SLC_VAR("feeder_share"),
|
SLC_VAR("feeder_share"),
|
||||||
|
@@ -84,7 +84,7 @@ const SaveLoadCompat _vehicle_common_sl_compat[] = {
|
|||||||
SLC_VAR("profit_this_year"),
|
SLC_VAR("profit_this_year"),
|
||||||
SLC_VAR("profit_last_year"),
|
SLC_VAR("profit_last_year"),
|
||||||
SLC_VAR("cargo_feeder_share"),
|
SLC_VAR("cargo_feeder_share"),
|
||||||
SLC_VAR("cargo_loaded_at_xy"),
|
SLC_NULL(4, SLV_51, SLV_68),
|
||||||
SLC_VAR("value"),
|
SLC_VAR("value"),
|
||||||
SLC_VAR("random_bits"),
|
SLC_VAR("random_bits"),
|
||||||
SLC_VAR("waiting_triggers"),
|
SLC_VAR("waiting_triggers"),
|
||||||
|
@@ -305,7 +305,7 @@ public:
|
|||||||
assert(CargoPacket::CanAllocateItem());
|
assert(CargoPacket::CanAllocateItem());
|
||||||
|
|
||||||
/* Don't construct the packet with station here, because that'll fail with old savegames */
|
/* 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_days, source, _cargo_source_xy, _cargo_feeder_share);
|
||||||
ge->data->cargo.Append(cp, INVALID_STATION);
|
ge->data->cargo.Append(cp, INVALID_STATION);
|
||||||
SB(ge->status, GoodsEntry::GES_RATING, 1, 1);
|
SB(ge->status, GoodsEntry::GES_RATING, 1, 1);
|
||||||
}
|
}
|
||||||
|
@@ -44,7 +44,6 @@ static uint32 _cargo_source_xy;
|
|||||||
static uint16 _cargo_count;
|
static uint16 _cargo_count;
|
||||||
static uint16 _cargo_paid_for;
|
static uint16 _cargo_paid_for;
|
||||||
static Money _cargo_feeder_share;
|
static Money _cargo_feeder_share;
|
||||||
static uint32 _cargo_loaded_at_xy;
|
|
||||||
|
|
||||||
class SlVehicleCommon : public DefaultSaveLoadHandler<SlVehicleCommon, Vehicle> {
|
class SlVehicleCommon : public DefaultSaveLoadHandler<SlVehicleCommon, Vehicle> {
|
||||||
public:
|
public:
|
||||||
@@ -166,7 +165,6 @@ public:
|
|||||||
SLE_CONDVAR(Vehicle, profit_last_year, SLE_INT64, SLV_65, SL_MAX_VERSION),
|
SLE_CONDVAR(Vehicle, profit_last_year, SLE_INT64, SLV_65, SL_MAX_VERSION),
|
||||||
SLEG_CONDVAR("cargo_feeder_share", _cargo_feeder_share, SLE_FILE_I32 | SLE_VAR_I64, SLV_51, SLV_65),
|
SLEG_CONDVAR("cargo_feeder_share", _cargo_feeder_share, SLE_FILE_I32 | SLE_VAR_I64, SLV_51, SLV_65),
|
||||||
SLEG_CONDVAR("cargo_feeder_share", _cargo_feeder_share, SLE_INT64, SLV_65, SLV_68),
|
SLEG_CONDVAR("cargo_feeder_share", _cargo_feeder_share, SLE_INT64, SLV_65, SLV_68),
|
||||||
SLEG_CONDVAR("cargo_loaded_at_xy", _cargo_loaded_at_xy, SLE_UINT32, SLV_51, SLV_68),
|
|
||||||
SLE_CONDVAR(Vehicle, value, SLE_FILE_I32 | SLE_VAR_I64, SL_MIN_VERSION, SLV_65),
|
SLE_CONDVAR(Vehicle, value, SLE_FILE_I32 | SLE_VAR_I64, SL_MIN_VERSION, SLV_65),
|
||||||
SLE_CONDVAR(Vehicle, value, SLE_INT64, SLV_65, SL_MAX_VERSION),
|
SLE_CONDVAR(Vehicle, value, SLE_INT64, SLV_65, SL_MAX_VERSION),
|
||||||
|
|
||||||
@@ -535,7 +533,7 @@ struct VEHSChunkHandler : ChunkHandler {
|
|||||||
|
|
||||||
if (_cargo_count != 0 && IsCompanyBuildableVehicleType(v) && CargoPacket::CanAllocateItem()) {
|
if (_cargo_count != 0 && IsCompanyBuildableVehicleType(v) && CargoPacket::CanAllocateItem()) {
|
||||||
/* Don't construct the packet with station here, because that'll fail with old savegames */
|
/* 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_days, _cargo_source, _cargo_source_xy, _cargo_feeder_share);
|
||||||
v->cargo.Append(cp);
|
v->cargo.Append(cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -36,7 +36,6 @@ extern btree::btree_map<uint64, Money> _cargo_packet_deferred_payments;
|
|||||||
for (VehicleCargoList::ConstIterator it(packets->begin()); it != packets->end(); it++) {
|
for (VehicleCargoList::ConstIterator it(packets->begin()); it != packets->end(); it++) {
|
||||||
CargoPacket *cp = *it;
|
CargoPacket *cp = *it;
|
||||||
cp->source_xy = Station::IsValidID(cp->source) ? Station::Get(cp->source)->xy : v->tile;
|
cp->source_xy = Station::IsValidID(cp->source) ? Station::Get(cp->source)->xy : v->tile;
|
||||||
cp->loaded_at_xy = cp->source_xy;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +53,6 @@ extern btree::btree_map<uint64, Money> _cargo_packet_deferred_payments;
|
|||||||
for (StationCargoList::ConstIterator it(packets->begin()); it != packets->end(); it++) {
|
for (StationCargoList::ConstIterator it(packets->begin()); it != packets->end(); it++) {
|
||||||
CargoPacket *cp = *it;
|
CargoPacket *cp = *it;
|
||||||
cp->source_xy = Station::IsValidID(cp->source) ? Station::Get(cp->source)->xy : st->xy;
|
cp->source_xy = Station::IsValidID(cp->source) ? Station::Get(cp->source)->xy : st->xy;
|
||||||
cp->loaded_at_xy = cp->source_xy;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,7 +114,7 @@ SaveLoadTable GetCargoPacketDesc()
|
|||||||
static const SaveLoad _cargopacket_desc[] = {
|
static const SaveLoad _cargopacket_desc[] = {
|
||||||
SLE_VAR(CargoPacket, source, SLE_UINT16),
|
SLE_VAR(CargoPacket, source, SLE_UINT16),
|
||||||
SLE_VAR(CargoPacket, source_xy, SLE_UINT32),
|
SLE_VAR(CargoPacket, source_xy, SLE_UINT32),
|
||||||
SLE_VAR(CargoPacket, loaded_at_xy, SLE_UINT32),
|
SLE_VAR(CargoPacket, next_station, SLE_FILE_U32 | SLE_VAR_U16),
|
||||||
SLE_VAR(CargoPacket, count, SLE_UINT16),
|
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_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, days_in_transit, SLE_UINT16, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_MORE_CARGO_AGE)),
|
||||||
|
@@ -1353,7 +1353,7 @@ bool LoadOldVehicle(LoadgameState *ls, int num)
|
|||||||
if (_cargo_count != 0 && CargoPacket::CanAllocateItem()) {
|
if (_cargo_count != 0 && CargoPacket::CanAllocateItem()) {
|
||||||
StationID source = (_cargo_source == 0xFF) ? INVALID_STATION : _cargo_source;
|
StationID source = (_cargo_source == 0xFF) ? INVALID_STATION : _cargo_source;
|
||||||
TileIndex source_xy = (source != INVALID_STATION) ? Station::Get(source)->xy : 0;
|
TileIndex source_xy = (source != INVALID_STATION) ? Station::Get(source)->xy : 0;
|
||||||
v->cargo.Append(new CargoPacket(_cargo_count, _cargo_days, source, source_xy, source_xy));
|
v->cargo.Append(new CargoPacket(_cargo_count, _cargo_days, source, source_xy));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -371,6 +371,7 @@ enum SaveLoadVersion : uint16 {
|
|||||||
SLV_INDUSTRY_CARGO_REORGANISE, ///< 315 PR#10853 Industry accepts/produced data reorganised.
|
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.
|
SLV_PERIODS_IN_TRANSIT_RENAME, ///< 316 PR#11112 Rename days in transit to (cargo) periods in transit.
|
||||||
SLV_NEWGRF_LAST_SERVICE, ///< 317 PR#11124 Added stable date_of_last_service to avoid NewGRF trouble.
|
SLV_NEWGRF_LAST_SERVICE, ///< 317 PR#11124 Added stable date_of_last_service to avoid NewGRF trouble.
|
||||||
|
SLV_REMOVE_LOADED_AT_XY, ///< 318 PR#11276 Remove loaded_at_xy variable from CargoPacket.
|
||||||
|
|
||||||
SL_MAX_VERSION, ///< Highest possible saveload version
|
SL_MAX_VERSION, ///< Highest possible saveload version
|
||||||
|
|
||||||
|
@@ -374,7 +374,7 @@ static void Load_STNS()
|
|||||||
assert(CargoPacket::CanAllocateItem());
|
assert(CargoPacket::CanAllocateItem());
|
||||||
|
|
||||||
/* Don't construct the packet with station here, because that'll fail with old savegames */
|
/* 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_days, source, _cargo_source_xy, _cargo_feeder_share);
|
||||||
ge->CreateData().cargo.Append(cp, INVALID_STATION);
|
ge->CreateData().cargo.Append(cp, INVALID_STATION);
|
||||||
SB(ge->status, GoodsEntry::GES_RATING, 1, 1);
|
SB(ge->status, GoodsEntry::GES_RATING, 1, 1);
|
||||||
}
|
}
|
||||||
|
@@ -641,7 +641,6 @@ static uint32 _cargo_source_xy;
|
|||||||
static uint16 _cargo_count;
|
static uint16 _cargo_count;
|
||||||
static uint16 _cargo_paid_for;
|
static uint16 _cargo_paid_for;
|
||||||
static Money _cargo_feeder_share;
|
static Money _cargo_feeder_share;
|
||||||
static uint32 _cargo_loaded_at_xy;
|
|
||||||
CargoPacketList _cpp_packets;
|
CargoPacketList _cpp_packets;
|
||||||
std::map<VehicleID, CargoPacketList> _veh_cpp_packets;
|
std::map<VehicleID, CargoPacketList> _veh_cpp_packets;
|
||||||
static std::vector<Trackdir> _path_td;
|
static std::vector<Trackdir> _path_td;
|
||||||
@@ -789,7 +788,7 @@ SaveLoadTable GetVehicleDescription(VehicleType vt)
|
|||||||
SLE_CONDVAR_X(Vehicle,profit_lifetime, SLE_INT64, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_VEH_LIFETIME_PROFIT)),
|
SLE_CONDVAR_X(Vehicle,profit_lifetime, SLE_INT64, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_VEH_LIFETIME_PROFIT)),
|
||||||
SLEG_CONDVAR( _cargo_feeder_share, SLE_FILE_I32 | SLE_VAR_I64, SLV_51, SLV_65),
|
SLEG_CONDVAR( _cargo_feeder_share, SLE_FILE_I32 | SLE_VAR_I64, SLV_51, SLV_65),
|
||||||
SLEG_CONDVAR( _cargo_feeder_share, SLE_INT64, SLV_65, SLV_68),
|
SLEG_CONDVAR( _cargo_feeder_share, SLE_INT64, SLV_65, SLV_68),
|
||||||
SLEG_CONDVAR( _cargo_loaded_at_xy, SLE_UINT32, SLV_51, SLV_68),
|
SLE_CONDNULL(4 , SLV_51, SLV_68), // _cargo_loaded_at_xy
|
||||||
SLE_CONDVAR(Vehicle, value, SLE_FILE_I32 | SLE_VAR_I64, SL_MIN_VERSION, SLV_65),
|
SLE_CONDVAR(Vehicle, value, SLE_FILE_I32 | SLE_VAR_I64, SL_MIN_VERSION, SLV_65),
|
||||||
SLE_CONDVAR(Vehicle, value, SLE_INT64, SLV_65, SL_MAX_VERSION),
|
SLE_CONDVAR(Vehicle, value, SLE_INT64, SLV_65, SL_MAX_VERSION),
|
||||||
SLE_CONDNULL_X(8, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_VEHICLE_REPAIR_COST, 1, 1)),
|
SLE_CONDNULL_X(8, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_VEHICLE_REPAIR_COST, 1, 1)),
|
||||||
@@ -1096,7 +1095,7 @@ void Load_VEHS()
|
|||||||
|
|
||||||
if (_cargo_count != 0 && IsCompanyBuildableVehicleType(v) && CargoPacket::CanAllocateItem()) {
|
if (_cargo_count != 0 && IsCompanyBuildableVehicleType(v) && CargoPacket::CanAllocateItem()) {
|
||||||
/* Don't construct the packet with station here, because that'll fail with old savegames */
|
/* 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_days, _cargo_source, _cargo_source_xy, _cargo_feeder_share);
|
||||||
v->cargo.Append(cp);
|
v->cargo.Append(cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3386,7 +3386,6 @@ void Vehicle::CancelReservation(StationID next, Station *st)
|
|||||||
if (cargo.ActionCount(VehicleCargoList::MTA_LOAD) > 0) {
|
if (cargo.ActionCount(VehicleCargoList::MTA_LOAD) > 0) {
|
||||||
DEBUG(misc, 1, "cancelling cargo reservation");
|
DEBUG(misc, 1, "cancelling cargo reservation");
|
||||||
cargo.Return(UINT_MAX, &st->goods[v->cargo_type].CreateData().cargo, next);
|
cargo.Return(UINT_MAX, &st->goods[v->cargo_type].CreateData().cargo, next);
|
||||||
cargo.SetTransferLoadPlace(st->xy);
|
|
||||||
}
|
}
|
||||||
cargo.KeepAll();
|
cargo.KeepAll();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user