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);
110 this->payment->PayFinalDelivery(cp,
remove);
122 if (cp_new ==
nullptr)
return false;
124 this->
source->RemoveFromCache(cp_new, cp_new->
Count());
137 if (cp_new ==
nullptr)
return false;
140 this->
source->RemoveFromCache(cp_new, cp_new->
Count());
153 if (cp_new ==
nullptr) cp_new = cp;
154 assert(cp_new->
Count() <= this->destination->reserved_count);
156 this->destination->reserved_count -= cp_new->
Count();
157 this->destination->Append(cp_new, this->next);
169 if (cp_new ==
nullptr)
return false;
172 this->destination->Append(cp_new, cp_new->
NextStation());
184 if (cp_new ==
nullptr) cp_new = cp;
198 if (cp_new ==
nullptr) cp_new = cp;
199 StationID next = this->ge->GetVia(cp_new->
SourceStation(), this->avoid, this->avoid2);
200 assert(next != this->avoid && next != this->avoid2);
201 if (this->
source != this->destination) {
202 this->
source->RemoveFromCache(cp_new, cp_new->
Count());
203 this->destination->AddToCache(cp_new);
209 this->destination->packets.Insert(next, cp_new);
221 if (cp_new ==
nullptr) cp_new = cp;
225 if (this->
source != this->destination) {
231 this->destination->packets.push_front(cp_new);
bool operator()(CargoPacket *cp)
Reroutes some cargo from one Station sublist to another.
StationID NextStation() const
Gets the ID of station the cargo wants to go next.
void SetLoadPlace(TileIndex load_place)
Sets the tile where the packet was loaded last.
CargoPacket * Preprocess(CargoPacket *cp)
Decides if a packet needs to be split.
bool Postprocess(CargoPacket *cp, uint remove)
Finalize cargo removal.
Tsource * source
Source of the cargo.
bool operator()(CargoPacket *cp)
Shifts some cargo from a vehicle to another one.
Transfer the cargo to the station.
Actions to be applied to cargo packets.
Container for cargo from the same location and time.
Definition of base types and functions in a cross-platform compatible way.
StationID SourceStation() const
Gets the ID of the station where the cargo was loaded for the first time.
A number of safeguards to prevent using unsafe methods.
CargoPacket * Split(uint new_size)
Split this packet in two and return the split off part.
Deliver the cargo to some town or industry.
bool operator()(CargoPacket *cp)
Reroutes some cargo in a VehicleCargoList.
Keep the cargo in the vehicle.
bool operator()(CargoPacket *cp)
Transfers some cargo from a vehicle to a station.
bool operator()(CargoPacket *cp)
Loads some cargo onto a vehicle.
Abstract action of removing cargo from a vehicle or a station.
bool operator()(CargoPacket *cp)
Reserves some cargo for loading.
void Reduce(uint count)
Reduce the packet by the given amount and remove the feeder share.
Base classes related to the economy.
Load the cargo from the station.
bool operator()(CargoPacket *cp)
Delivers some cargo.
uint Preprocess(CargoPacket *cp)
Determines the amount of cargo to be removed from a packet and removes that from the metadata of the ...
uint16 Count() const
Gets the number of 'items' in this packet.
void SetNextStation(StationID next_station)
Sets the station where the packet is supposed to go next.
bool operator()(CargoPacket *cp)
Returns some reserved cargo.
Base classes/functions for stations.