OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
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);
169 if (cp_new ==
nullptr)
return false;
184 if (cp_new ==
nullptr) cp_new = cp;
198 if (cp_new ==
nullptr) cp_new = cp;
200 assert(next != this->avoid && next != this->avoid2);
221 if (cp_new ==
nullptr) cp_new = cp;
bool operator()(CargoPacket *cp)
Shifts some cargo from a vehicle to another one.
bool operator()(CargoPacket *cp)
Reserves some cargo for loading.
uint reserved_count
Amount of cargo being reserved for loading.
bool operator()(CargoPacket *cp)
Delivers some cargo.
void RemoveFromMeta(const CargoPacket *cp, MoveToAction action, uint count)
Removes a packet or part of it from the metadata.
VehicleCargoList * destination
Destination for the cargo.
CargoPacket * Preprocess(CargoPacket *cp)
Decides if a packet needs to be split.
uint Preprocess(CargoPacket *cp)
Determines the amount of cargo to be removed from a packet and removes that from the metadata of the ...
bool operator()(CargoPacket *cp)
Reroutes some cargo in a VehicleCargoList.
StationID SourceStation() const
Gets the ID of the station where the cargo was loaded for the first time.
void AddToMeta(const CargoPacket *cp, MoveToAction action)
Adds a packet to the metadata.
StationID GetVia(StationID source) const
Get the best next hop for a cargo packet from station source.
void Append(CargoPacket *cp, MoveToAction action=MTA_KEEP)
Appends the given cargo packet.
CargoPacket * Split(uint new_size)
Split this packet in two and return the split off part.
void PayFinalDelivery(const CargoPacket *cp, uint count)
Handle payment for final delivery of the given cargo packet.
bool operator()(CargoPacket *cp)
Loads some cargo onto a vehicle.
uint16 Count() const
Gets the number of 'items' in this packet.
@ MTA_TRANSFER
Transfer the cargo to the station.
void Reduce(uint count)
Reduce the packet by the given amount and remove the feeder share.
void RemoveFromCache(const CargoPacket *cp, uint count)
Update the cached values to reflect the removal of this packet or part of it.
Tcont packets
The cargo packets in this list.
Abstract action of removing cargo from a vehicle or a station.
@ MTA_LOAD
Load the cargo from the station.
void SetNextStation(StationID next_station)
Sets the station where the packet is supposed to go next.
Tsource * source
Source of the cargo.
bool operator()(CargoPacket *cp)
Returns some reserved cargo.
void SetLoadPlace(TileIndex load_place)
Sets the tile where the packet was loaded last.
TileIndex load_place
TileIndex to be saved in the packets' loaded_at_xy.
bool operator()(CargoPacket *cp)
Transfers some cargo from a vehicle to a station.
StationID NextStation() const
Gets the ID of station the cargo wants to go next.
Container for cargo from the same location and time.
@ MTA_KEEP
Keep the cargo in the vehicle.
bool Postprocess(CargoPacket *cp, uint remove)
Finalize cargo removal.
@ MTA_DELIVER
Deliver the cargo to some town or industry.
void Append(CargoPacket *cp, StationID next)
Appends the given cargo packet to the range of packets with the same next station.
StationCargoList * source
Source of the cargo.
CargoPayment * payment
Payment object where payments will be registered.
void Insert(const Tkey &key, const Tvalue &val)
Insert a value at the end of the range with the specified key.
bool operator()(CargoPacket *cp)
Reroutes some cargo from one Station sublist to another.
void AddToCache(const CargoPacket *cp)
Update the cache to reflect adding of this packet.