summaryrefslogtreecommitdiff
path: root/src/cargopacket.cpp
diff options
context:
space:
mode:
authorfonsinchen <fonsinchen@openttd.org>2013-08-10 14:19:58 +0000
committerfonsinchen <fonsinchen@openttd.org>2013-08-10 14:19:58 +0000
commit6ce4c1808b8efabdfcdbe3e053198ea3c01561c3 (patch)
tree36d0678f1ba1b182636fba9aa39bc388a228b52e /src/cargopacket.cpp
parent0baa72aff9737e17741b83c8a6d87891fb03bc0f (diff)
downloadopenttd-6ce4c1808b8efabdfcdbe3e053198ea3c01561c3.tar.xz
(svn r25715) -Fix: return correct value from StationCargoList::Reserve, fix some documentation and simplify StationCargoList::Load a bit
Diffstat (limited to 'src/cargopacket.cpp')
-rw-r--r--src/cargopacket.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/cargopacket.cpp b/src/cargopacket.cpp
index 22be361e3..6a37cb488 100644
--- a/src/cargopacket.cpp
+++ b/src/cargopacket.cpp
@@ -732,24 +732,28 @@ uint StationCargoList::Truncate(uint max_move, StationCargoAmountMap *cargo_per_
/**
* Reserves cargo for loading onto the vehicle.
- * @param dest VehicleCargoList to reserve for.
* @param max_move Maximum amount of cargo to reserve.
+ * @param dest VehicleCargoList to reserve for.
* @param load_place Tile index of the current station.
+ * @param next_station Next station the loading vehicle will visit.
* @return Amount of cargo actually reserved.
*/
-uint StationCargoList::Reserve(uint max_move, VehicleCargoList *dest, TileIndex load_place, StationID next)
+uint StationCargoList::Reserve(uint max_move, VehicleCargoList *dest, TileIndex load_place, StationID next_station)
{
- max_move = min(this->count, max_move);
- this->ShiftCargo(CargoReservation(this, dest, max_move, load_place), next, true);
- return max_move;
+ return this->ShiftCargo(CargoReservation(this, dest, max_move, load_place), next_station, true);
}
/**
* Loads cargo onto a vehicle. If the vehicle has reserved cargo load that.
* Otherwise load cargo from the station.
- * @param dest Vehicle cargo list where the cargo resides.
* @param max_move Amount of cargo to load.
+ * @param dest Vehicle cargo list where the cargo resides.
+ * @param load_place The new loaded_at_xy to be assigned to packets being moved.
+ * @param next_station Next station the loading vehicle will visit.
* @return Amount of cargo actually loaded.
+ * @note Vehicles may or may not reserve, depending on their orders. The two
+ * modes of loading are exclusive, though. If cargo is reserved we don't
+ * need to load unreserved cargo.
*/
uint StationCargoList::Load(uint max_move, VehicleCargoList *dest, TileIndex load_place, StationID next_station)
{
@@ -759,8 +763,7 @@ uint StationCargoList::Load(uint max_move, VehicleCargoList *dest, TileIndex loa
dest->Reassign(move, VehicleCargoList::MTA_LOAD, VehicleCargoList::MTA_KEEP);
return move;
} else {
- move = min(this->count, max_move);
- return this->ShiftCargo(CargoLoad(this, dest, move, load_place), next_station, true);
+ return this->ShiftCargo(CargoLoad(this, dest, max_move, load_place), next_station, true);
}
}