MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / Load

Method Load

src/cargopacket.cpp:834–844  ·  view source on GitHub ↗

* Loads cargo onto a vehicle. If the vehicle has reserved cargo load that. * Otherwise load cargo from the station. * @param max_move Amount of cargo to load. * @param dest Vehicle cargo list where the cargo resides. * @param next_station Next station(s) the loading vehicle will visit. * @param current_tile Current tile the cargo handling is happening on. * @return Amount of cargo actually l

Source from the content-addressed store, hash-verified

832 * need to load unreserved cargo.
833 */
834uint StationCargoList::Load(uint max_move, VehicleCargoList *dest, std::span<const StationID> next_station, TileIndex current_tile)
835{
836 uint move = std::min(dest->ActionCount(VehicleCargoList::MTA_LOAD), max_move);
837 if (move > 0) {
838 this->reserved_count -= move;
839 dest->Reassign<VehicleCargoList::MTA_LOAD, VehicleCargoList::MTA_KEEP>(move);
840 return move;
841 } else {
842 return this->ShiftCargo(CargoLoad{this, dest, max_move, current_tile}, next_station, true);
843 }
844}
845
846/**
847 * Routes packets with station "avoid" as next hop to a different place.

Callers

nothing calls this directly

Calls 2

ActionCountMethod · 0.80
ShiftCargoMethod · 0.80

Tested by

no test coverage detected