CargoList that is used for stations. More...
#include <cargopacket.h>
Public Member Functions | |
uint | TakeFrom (VehicleCargoList *source, uint max_unload, OrderUnloadFlags flags, StationID next_station, bool has_stopped, CargoPayment *payment) |
Moves the given amount of cargo from a vehicle to a station. | |
uint | MoveTo (VehicleCargoList *dest, uint cap, StationID next_station, bool reserve=false) |
Move suitable packets from this list to a vehicle. | |
void | Append (StationID next, CargoPacket *cp) |
Appends the given cargo packet to the range of packets with the same next station. | |
void | RerouteStalePackets (StationID to) |
Route all packets with station "to" as next hop to a different place. | |
void | CountAndTruncate (uint max_remaining, StationCargoAmountMap &cargo_per_source) |
Truncate where each destination loses roughly the same percentage of its cargo. | |
FORCEINLINE StationID | Source () const |
Returns source of the first cargo packet in this list. | |
void | AssignTo (Station *station, CargoID cargo) |
Assign the cargo list to a goods entry. | |
Static Public Member Functions | |
static bool | AreMergable (const CargoPacket *cp1, const CargoPacket *cp2) |
Are two the two CargoPackets mergeable in the context of a list of CargoPackets for a Vehicle? | |
static void | InvalidateAllFrom (SourceType src_type, SourceID src) |
Protected Member Functions | |
byte | GetUnloadFlags (OrderUnloadFlags order_flags) |
build unload flags from order flags and station acceptance. | |
UnloadType | WillUnloadOld (byte flags, StationID source) |
Determine what a cargo packet arriving at the station this list belongs to will do, using the "old", non-cargodist algorithm. | |
UnloadType | WillUnloadCargoDist (byte flags, StationID next_station, StationID via, StationID source) |
Determine what a cargo packet arriving at the station this list belongs to will do, using the Cargodist algorithm. | |
uint | MovePackets (VehicleCargoList *dest, uint cap, Iterator begin, Iterator end, bool reserve) |
Move packets from a specific range in this list to a vehicle. | |
Protected Attributes | |
Station * | station |
Station this cargo list belongs to. | |
CargoID | cargo |
Cargo type this list holds. | |
Friends | |
class | CargoList< StationCargoList, StationCargoPacketMap > |
The super class ought to know what it's doing. | |
struct SaveLoad * | GetGoodsDesc () |
The stations, via GoodsEntry, have a CargoList. |
CargoList that is used for stations.
Definition at line 382 of file cargopacket.h.
void StationCargoList::Append | ( | StationID | next, | |
CargoPacket * | cp | |||
) |
Appends the given cargo packet to the range of packets with the same next station.
next | the next hop | |
cp | the cargo packet to add |
Definition at line 739 of file cargopacket.cpp.
References CargoList< StationCargoList, StationCargoPacketMap >::AddToCache(), AreMergable(), CargoPacket::count, CargoPacket::MAX_COUNT, CargoPacket::Merge(), and CargoList< StationCargoList, StationCargoPacketMap >::packets.
Referenced by CargoList< Tinst, Tcont >::MovePacket(), VehicleCargoList::TransferPacket(), and VehicleCargoList::Unreserve().
static bool StationCargoList::AreMergable | ( | const CargoPacket * | cp1, | |
const CargoPacket * | cp2 | |||
) | [inline, static] |
Are two the two CargoPackets mergeable in the context of a list of CargoPackets for a Vehicle?
cp1 | First CargoPacket. | |
cp2 | Second CargoPacket. |
Definition at line 398 of file cargopacket.h.
References CargoPacket::days_in_transit, CargoPacket::source_id, CargoPacket::source_type, and CargoPacket::source_xy.
Referenced by Append().
Assign the cargo list to a goods entry.
station | the station the cargo list is assigned to | |
cargo | the cargo the list is assigned to |
Definition at line 876 of file cargopacket.cpp.
References INVALID_CARGO.
void StationCargoList::CountAndTruncate | ( | uint | max_remaining, | |
StationCargoAmountMap & | cargo_per_source | |||
) |
Truncate where each destination loses roughly the same percentage of its cargo.
This is done by randomizing the selection of packets to be removed. Also count the cargo by origin station.
max_remaining | Maximum amount of cargo to keep in the station. | |
cargo_per_source | Container for counting the cargo by origin list. |
Definition at line 823 of file cargopacket.cpp.
References CargoList< StationCargoList, StationCargoPacketMap >::cargo_days_in_transit, CargoPacket::count, CargoList< StationCargoList, StationCargoPacketMap >::count, CargoPacket::days_in_transit, MultiMap< Tkey, Tvalue, Tcompare >::erase(), CargoList< StationCargoList, StationCargoPacketMap >::packets, CargoList< StationCargoList, StationCargoPacketMap >::RemoveFromCache(), and CargoPacket::source.
FORCEINLINE byte StationCargoList::GetUnloadFlags | ( | OrderUnloadFlags | order_flags | ) | [protected] |
build unload flags from order flags and station acceptance.
order_flags | order flags to check for forced transfer/deliver |
Definition at line 716 of file cargopacket.cpp.
References GoodsEntry::acceptance_pickup, GoodsEntry::GES_ACCEPTANCE, Station::goods, HasBit(), OUFB_TRANSFER, OUFB_UNLOAD, and station.
Referenced by TakeFrom().
uint StationCargoList::MovePackets | ( | VehicleCargoList * | dest, | |
uint | cap, | |||
Iterator | begin, | |||
Iterator | end, | |||
bool | reserve | |||
) | [protected] |
Move packets from a specific range in this list to a vehicle.
dest | Cargo list the packets will be moved to. | |
cap | Maximum amount of cargo to move. | |
begin | Begin of the range to take packets from. | |
end | End of the range to take packets from. | |
reserve | If the packets should be loaded on or reserved for the vehicle. |
Definition at line 766 of file cargopacket.cpp.
References CargoList< StationCargoList, StationCargoPacketMap >::MovePacket(), station, and BaseStation::xy.
Referenced by MoveTo().
uint StationCargoList::MoveTo | ( | VehicleCargoList * | dest, | |
uint | cap, | |||
StationID | next, | |||
bool | reserve = false | |||
) |
Move suitable packets from this list to a vehicle.
dest | Vehicle cargo list to move packets to. | |
cap | Maximum amount of cargo to be moved. | |
next | Next station the vehicle will stop at. | |
reserve | If the packets should be loaded on or reserved for the vehicle. |
Definition at line 783 of file cargopacket.cpp.
References MultiMap< Tkey, Tvalue, Tcompare >::equal_range(), MovePackets(), and CargoList< StationCargoList, StationCargoPacketMap >::packets.
Referenced by LoadUnloadVehicle(), and ReserveConsist().
void StationCargoList::RerouteStalePackets | ( | StationID | to | ) |
Route all packets with station "to" as next hop to a different place.
to | station to exclude from routing. |
Definition at line 799 of file cargopacket.cpp.
References cargo, MultiMap< Tkey, Tvalue, Tcompare >::equal_range(), MultiMap< Tkey, Tvalue, Tcompare >::erase(), Station::goods, MultiMap< Tkey, Tvalue, Tcompare >::Insert(), CargoList< StationCargoList, StationCargoPacketMap >::packets, CargoPacket::source, and station.
Referenced by Station::RunAverages(), and Station::~Station().
FORCEINLINE StationID StationCargoList::Source | ( | ) | const [inline] |
Returns source of the first cargo packet in this list.
Definition at line 420 of file cargopacket.h.
References CargoList< StationCargoList, StationCargoPacketMap >::Empty(), and CargoList< StationCargoList, StationCargoPacketMap >::packets.
uint StationCargoList::TakeFrom | ( | VehicleCargoList * | source, | |
uint | max_unload, | |||
OrderUnloadFlags | order_flags, | |||
StationID | next, | |||
bool | has_stopped, | |||
CargoPayment * | payment | |||
) |
Moves the given amount of cargo from a vehicle to a station.
Depending on the value of flags the side effects of this function differ:
source | Vehicle cargo list to take the cargo from. | |
max_unload | Maximum amount of cargo entities to move. | |
flags | How to handle the moving (side effects). | |
next | Next unloading station in the vehicle's order list. | |
has_stopped | Vehicle has stopped at this station before, so don't update the flow stats for kept cargo. | |
payment | Payment object to be updated when delivering/transferring. |
Definition at line 594 of file cargopacket.cpp.
References cargo, VehicleCargoList::DeliverPacket(), GoodsEntry::flows, GetUnloadFlags(), Station::goods, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, VehicleCargoList::KeepPacket(), CargoList< Tinst, Tcont >::packets, station, VehicleCargoList::TransferPacket(), UL_DELIVER, UL_KEEP, UL_TRANSFER, WillUnloadCargoDist(), and WillUnloadOld().
Referenced by LoadUnloadVehicle().
UnloadType StationCargoList::WillUnloadCargoDist | ( | byte | flags, | |
StationID | next, | |||
StationID | via, | |||
StationID | source | |||
) | [protected] |
Determine what a cargo packet arriving at the station this list belongs to will do, using the Cargodist algorithm.
flags | Unload flags telling if the cargo is accepted and what order flags there are. | |
next | Station the vehicle the cargo is coming from will visit next (or INVALID_STATION if unknown). | |
via | Station the cargo wants to go to next. If that is this station the cargo wants to be delivered. | |
source | ID of the packets source station. |
Definition at line 519 of file cargopacket.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, station, UL_ACCEPTED, UL_DELIVER, and UL_TRANSFER.
Referenced by TakeFrom().
UnloadType StationCargoList::WillUnloadOld | ( | byte | flags, | |
StationID | source | |||
) | [protected] |
Determine what a cargo packet arriving at the station this list belongs to will do, using the "old", non-cargodist algorithm.
flags | Unload flags telling if the cargo is accepted and what order flags there are. | |
source | ID of the packets source station. |
Definition at line 482 of file cargopacket.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, station, UL_ACCEPTED, UL_DELIVER, and UL_TRANSFER.
Referenced by TakeFrom().
friend class CargoList< StationCargoList, StationCargoPacketMap > [friend] |
The super class ought to know what it's doing.
Definition at line 385 of file cargopacket.h.
struct SaveLoad* GetGoodsDesc | ( | ) | [friend] |
The stations, via GoodsEntry, have a CargoList.
Definition at line 285 of file station_sl.cpp.