23 template<
class Tsource,
class Tdest>
26 if (this->max_move < cp->
Count()) {
27 cp = cp->
Split(this->max_move);
30 this->max_move -= cp->
Count();
41 template<
class Tsource>
44 if (this->max_move >= cp->
Count()) {
45 this->max_move -= cp->
Count();
48 uint ret = this->max_move;
60 template<
class Tsource>
63 if (remove == cp->
Count()) {
81 uint remove = this->Preprocess(cp);
82 this->source->RemoveFromCache(cp, remove);
83 return this->Postprocess(cp, remove);
122 if (cp_new ==
nullptr)
return false;
137 if (cp_new ==
nullptr)
return false;
153 if (cp_new ==
nullptr) cp_new = cp;
154 assert(cp_new->
Count() <= this->destination->reserved_count);
170 if (cp_new ==
nullptr)
return false;
186 if (cp_new ==
nullptr) cp_new = cp;
200 if (cp_new ==
nullptr) cp_new = cp;
202 assert(next != this->avoid && next != this->avoid2);
204 this->
source->RemoveFromCache(cp_new, cp_new->
Count());
223 if (cp_new ==
nullptr) cp_new = cp;
Actions to be applied to cargo packets.
CargoPayment * payment
Payment object where payments will be registered.
TileIndex current_tile
Current tile cargo delivery is happening.
bool operator()(CargoPacket *cp)
Delivers some cargo.
CargoID cargo
The cargo type of the cargo.
@ MTA_KEEP
Keep the cargo in the vehicle.
@ MTA_DELIVER
Deliver the cargo to some town or industry.
@ MTA_LOAD
Load the cargo from the station.
@ MTA_TRANSFER
Transfer the cargo to the station.
Tcont packets
The cargo packets in this list.
void RemoveFromCache(const CargoPacket *cp, uint count)
Update the cached values to reflect the removal of this packet or part of it.
bool operator()(CargoPacket *cp)
Loads some cargo onto a vehicle.
TileIndex current_tile
Current tile cargo loading is happening.
StationCargoList * source
Source of the cargo.
CargoPacket * Preprocess(CargoPacket *cp)
Decides if a packet needs to be split.
VehicleCargoList * destination
Destination for the cargo.
Abstract action of removing cargo from a vehicle or a station.
uint Preprocess(CargoPacket *cp)
Determines the amount of cargo to be removed from a packet and removes that from the metadata of the ...
bool Postprocess(CargoPacket *cp, uint remove)
Finalize cargo removal.
Tsource * source
Source of the cargo.
bool operator()(CargoPacket *cp)
Reserves some cargo for loading.
TileIndex current_tile
Current tile cargo unloading is happening.
bool operator()(CargoPacket *cp)
Returns some reserved cargo.
bool operator()(CargoPacket *cp)
Shifts some cargo from a vehicle to another one.
bool operator()(CargoPacket *cp)
Transfers some cargo from a vehicle to a station.
TileIndex current_tile
Current tile cargo unloading is happening.
void Append(CargoPacket *cp, StationID next)
Appends the given cargo packet to the range of packets with the same next station.
uint reserved_count
Amount of cargo being reserved for loading.
bool operator()(CargoPacket *cp)
Reroutes some cargo from one Station sublist to another.
void AddToMeta(const CargoPacket *cp, MoveToAction action)
Adds a packet to the metadata.
void RemoveFromMeta(const CargoPacket *cp, MoveToAction action, uint count)
Removes a packet or part of it from the metadata.
void Append(CargoPacket *cp, MoveToAction action=MTA_KEEP)
Appends the given cargo packet.
bool operator()(CargoPacket *cp)
Reroutes some cargo in a VehicleCargoList.
Base classes related to the economy.
A number of safeguards to prevent using unsafe methods.
Base classes/functions for stations.
@ Count
by amount of cargo
Definition of base types and functions in a cross-platform compatible way.
Container for cargo from the same location and time.
void Reduce(uint count)
Reduce the packet by the given amount and remove the feeder share.
uint16_t Count() const
Gets the number of 'items' in this packet.
void SetNextHop(StationID next_hop)
Sets the station where the packet is supposed to go next.
CargoPacket * Split(uint new_size)
Split this packet in two and return the split off part.
void UpdateLoadingTile(TileIndex tile)
Update for the cargo being loaded on this tile.
StationID GetNextHop() const
Gets the ID of station the cargo wants to go next.
StationID GetFirstStation() const
Gets the ID of the station where the cargo was loaded for the first time.
void UpdateUnloadingTile(TileIndex tile)
Update for the cargo being unloaded on this tile.
void PayFinalDelivery(CargoID cargo, const CargoPacket *cp, uint count, TileIndex current_tile)
Handle payment for final delivery of the given cargo packet.
StationID GetVia(StationID source) const
Get the best next hop for a cargo packet from station source.