Changeset - r20677:02a48342be8e
[Not reviewed]
master
0 1 0
fonsinchen - 11 years ago 2013-08-10 14:19:58
fonsinchen@openttd.org
(svn r25715) -Fix: return correct value from StationCargoList::Reserve, fix some documentation and simplify StationCargoList::Load a bit
1 file changed with 11 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/cargopacket.cpp
Show inline comments
 
@@ -732,24 +732,28 @@ uint StationCargoList::Truncate(uint max
 

	
 
/**
 
 * Reserves cargo for loading onto the vehicle.
 
 * @param max_move Maximum amount of cargo to reserve.
 
 * @param dest VehicleCargoList to reserve for.
 
 * @param max_move Maximum amount of cargo to reserve.
 
 * @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 max_move Amount of cargo to load.
 
 * @param dest Vehicle cargo list where the cargo resides.
 
 * @param max_move Amount of cargo to load.
 
 * @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_mov
 
		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);
 
	}
 
}
 

	
0 comments (0 inline, 0 general)