OpenTTD Source
20240919-master-gdf0233f4c2
|
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);
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);
223 if (cp_new ==
nullptr) cp_new = cp;
bool operator()(CargoPacket *cp)
Shifts some cargo from a vehicle to another one.
StationID GetNextHop() const
Gets the ID of station the cargo wants to go next.
@ Count
by amount of cargo
bool operator()(CargoPacket *cp)
Reserves some cargo for loading.
uint reserved_count
Amount of cargo being reserved for loading.
TileIndex current_tile
Current tile cargo delivery is happening.
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 ...
TileIndex current_tile
Current tile cargo loading is happening.
bool operator()(CargoPacket *cp)
Reroutes some cargo in a VehicleCargoList.
StationID GetFirstStation() const
Gets the ID of the station where the cargo was loaded for the first time.
void PayFinalDelivery(const CargoPacket *cp, uint count, TileIndex current_tile)
Handle payment for final delivery of the given cargo packet.
void UpdateLoadingTile(TileIndex tile)
Update for the cargo being loaded on this tile.
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 SetNextHop(StationID next_hop)
Sets the station where the packet is supposed to go next.
bool operator()(CargoPacket *cp)
Loads some cargo onto a vehicle.
@ 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.
TileIndex current_tile
Current tile cargo unloading is happening.
Abstract action of removing cargo from a vehicle or a station.
@ MTA_LOAD
Load the cargo from the station.
void UpdateUnloadingTile(TileIndex tile)
Update for the cargo being unloaded on this tile.
Tsource * source
Source of the cargo.
bool operator()(CargoPacket *cp)
Returns some reserved cargo.
bool operator()(CargoPacket *cp)
Transfers some cargo from a vehicle to a station.
Container for cargo from the same location and time.
@ MTA_KEEP
Keep the cargo in the vehicle.
TileIndex current_tile
Current tile cargo unloading is happening.
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.
uint16_t Count() const
Gets the number of 'items' in this packet.
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.