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

Method Unload

src/cargopacket.cpp:626–640  ·  view source on GitHub ↗

* Unloads cargo at the given station. Deliver or transfer, depending on the * ranges defined by designation_counts. * @param dest StationCargoList to add transferred cargo to. * @param max_move Maximum amount of cargo to move. * @param cargo The cargo type of the cargo. * @param payment Payment object to register payments in. * @param current_tile Current tile the cargo handling is happening

Source from the content-addressed store, hash-verified

624 * @return Amount of cargo actually unloaded.
625 */
626uint VehicleCargoList::Unload(uint max_move, StationCargoList *dest, CargoType cargo, CargoPayment *payment, TileIndex current_tile)
627{
628 uint moved = 0;
629 if (this->action_counts[MTA_TRANSFER] > 0) {
630 uint move = std::min(this->action_counts[MTA_TRANSFER], max_move);
631 this->ShiftCargo(CargoTransfer(this, dest, move, current_tile));
632 moved += move;
633 }
634 if (this->action_counts[MTA_TRANSFER] == 0 && this->action_counts[MTA_DELIVER] > 0 && moved < max_move) {
635 uint move = std::min(this->action_counts[MTA_DELIVER], max_move - moved);
636 this->ShiftCargo(CargoDelivery(this, move, cargo, payment, current_tile));
637 moved += move;
638 }
639 return moved;
640}
641
642/**
643 * Truncates the cargo in this list to the given amount. It leaves the

Callers 2

LoadUnloadVehicleFunction · 0.80
StopMethod · 0.80

Calls 3

ShiftCargoMethod · 0.95
CargoTransferClass · 0.85
CargoDeliveryClass · 0.85

Tested by

no test coverage detected