23template <
class Tsource,
class Tdest>
26 if (this->max_move < cp->
Count()) {
41template <
class Tsource>
60template <
class Tsource>
63 if (remove == cp->
Count()) {
79bool CargoRemoval<StationCargoList>::operator()(
CargoPacket *cp)
82 this->
source->RemoveFromCache(cp, remove);
93bool CargoRemoval<VehicleCargoList>::operator()(
CargoPacket *cp)
97 uint remaining = remove;
98 for (
VehicleCargoList::MoveToAction action : {VehicleCargoList::MoveToAction::Keep, VehicleCargoList::MoveToAction::Transfer, VehicleCargoList::MoveToAction::Deliver, VehicleCargoList::MoveToAction::Load}) {
99 remaining -= this->
source->TryRemoveFromMeta(cp, action, remaining);
100 if (remaining == 0)
break;
102 assert(remaining == 0);
116 this->
source->RemoveFromMeta(cp, VehicleCargoList::MoveToAction::Deliver, remove);
129 if (cp_new ==
nullptr)
return false;
131 this->
source->RemoveFromCache(cp_new, cp_new->
Count());
132 this->
destination->Append(cp_new, VehicleCargoList::MoveToAction::Keep);
144 if (cp_new ==
nullptr)
return false;
147 this->
source->RemoveFromCache(cp_new, cp_new->
Count());
148 this->
destination->Append(cp_new, VehicleCargoList::MoveToAction::Load);
160 if (cp_new ==
nullptr) cp_new = cp;
161 assert(cp_new->
Count() <= this->destination->reserved_count);
163 this->
source->RemoveFromMeta(cp_new, VehicleCargoList::MoveToAction::Load, cp_new->
Count());
177 if (cp_new ==
nullptr)
return false;
179 this->
source->RemoveFromMeta(cp_new, VehicleCargoList::MoveToAction::Transfer, cp_new->
Count());
193 if (cp_new ==
nullptr) cp_new = cp;
194 this->
source->RemoveFromMeta(cp_new, VehicleCargoList::MoveToAction::Keep, cp_new->
Count());
195 this->
destination->Append(cp_new, VehicleCargoList::MoveToAction::Keep);
207 if (cp_new ==
nullptr) cp_new = cp;
208 StationID next = this->
ge->GetVia(cp_new->
GetFirstStation(), this->avoid, this->avoid2);
209 assert(next != this->
avoid && next != this->
avoid2);
211 this->
source->RemoveFromCache(cp_new, cp_new->
Count());
230 if (cp_new ==
nullptr) cp_new = cp;
235 this->
source->RemoveFromMeta(cp_new, VehicleCargoList::MoveToAction::Transfer, cp_new->
Count());
236 this->
destination->AddToMeta(cp_new, VehicleCargoList::MoveToAction::Transfer);
Actions to be applied to cargo packets.
CargoPayment * payment
Payment object where payments will be registered.
CargoType cargo
The cargo type of the cargo.
TileIndex current_tile
Current tile cargo delivery is happening.
bool operator()(CargoPacket *cp)
Delivers some cargo.
bool operator()(CargoPacket *cp)
Loads some cargo onto a vehicle.
TileIndex current_tile
Current tile cargo loading is happening.
StationCargoList * source
CargoPacket * Preprocess(CargoPacket *cp)
Decides if a packet needs to be split.
VehicleCargoList * destination
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.
VehicleCargoList * source
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.
bool operator()(CargoPacket *cp)
Reroutes some cargo from one Station sublist to another.
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.