25 template<
class Tsource,
class Tdest>
28 if (this->max_move < cp->Count()) {
29 cp = cp->
Split(this->max_move);
32 this->max_move -= cp->
Count();
43 template<
class Tsource>
46 if (this->max_move >= cp->
Count()) {
47 this->max_move -= cp->
Count();
50 uint ret = this->max_move;
62 template<
class Tsource>
65 if (
remove == cp->
Count()) {
83 uint
remove = this->Preprocess(cp);
84 this->source->RemoveFromCache(cp,
remove);
85 return this->Postprocess(cp,
remove);
112 this->payment->PayFinalDelivery(cp,
remove);
124 if (cp_new == NULL)
return false;
126 this->
source->RemoveFromCache(cp_new, cp_new->
Count());
139 if (cp_new == NULL)
return false;
142 this->
source->RemoveFromCache(cp_new, cp_new->
Count());
155 if (cp_new == NULL) cp_new = cp;
156 assert(cp_new->
Count() <= this->destination->reserved_count);
158 this->destination->reserved_count -= cp_new->
Count();
159 this->destination->Append(cp_new, this->next);
171 if (cp_new == NULL)
return false;
174 this->destination->Append(cp_new, cp_new->
NextStation());
186 if (cp_new == NULL) cp_new = cp;
200 if (cp_new == NULL) cp_new = cp;
201 StationID next = this->ge->GetVia(cp_new->
SourceStation(), this->avoid, this->avoid2);
202 assert(next != this->avoid && next != this->avoid2);
203 if (this->
source != this->destination) {
204 this->
source->RemoveFromCache(cp_new, cp_new->
Count());
205 this->destination->AddToCache(cp_new);
211 this->destination->packets.Insert(next, cp_new);
223 if (cp_new == NULL) cp_new = cp;
227 if (this->
source != this->destination) {
233 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.