CargoList that is used for stations. More...
#include <cargopacket.h>
Public Types | |
typedef std::map< OrderID, int > | OrderMap |
Public Member Functions | |
void | InvalidateCache () |
Invalidates the cached data and rebuild it. | |
void | UpdateCargoNextHop (Station *st, CargoID cid) |
Recompute the desired next hop of all cargo packets. | |
const OrderMap & | CountForNextHop () const |
Gets the cargo counts per next hop. | |
int | CountForNextHop (OrderID order) const |
Gets the cargo count for a next hop. | |
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 | InvalidateAllTo (OrderID order, StationID st_unload) |
Invalidates the next hop info of all cargo packets with a given next order or unload station. | |
static void | InvalidateAllTo (SourceType type, SourceID dest) |
Invalidates the next hop info of all cargo packets for a given destination. | |
Protected Types | |
typedef CargoList < StationCargoList > | Parent |
The (direct) parent of this class. | |
Protected Member Functions | |
void | AddToCache (const CargoPacket *cp) |
Update the cache to reflect adding of this packet. | |
void | RemoveFromCache (const CargoPacket *cp) |
Update the cached values to reflect the removal of this packet. | |
void | RemoveFromCacheLocal (const CargoPacket *cp, uint amount) |
Update the local next-hop count cache. | |
bool | UpdateCargoNextHop (CargoPacket *cp, Station *st, CargoID cid) |
Recompute the desired next hop of a cargo packet. | |
Protected Attributes | |
OrderMap | order_cache |
int32 | next_start |
Packet number to start the next hop update loop from. | |
Friends | |
class | CargoList< StationCargoList > |
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 390 of file cargopacket.h.
typedef CargoList<StationCargoList> StationCargoList::Parent [protected] |
The (direct) parent of this class.
Definition at line 396 of file cargopacket.h.
void StationCargoList::AddToCache | ( | const CargoPacket * | cp | ) | [protected] |
Update the cache to reflect adding of this packet.
Increases count and days_in_transit.
cp | New packet to be inserted. |
Reimplemented from CargoList< StationCargoList >.
Definition at line 550 of file cargopacket.cpp.
References CargoList< StationCargoList >::AddToCache(), CargoPacket::count, and CargoPacket::next_order.
Referenced by InvalidateAllTo(), and UpdateCargoNextHop().
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 444 of file cargopacket.h.
References CargoPacket::days_in_transit, CargoPacket::dest_id, CargoPacket::dest_type, CargoPacket::dest_xy, CargoPacket::flags, CargoPacket::next_order, CargoPacket::next_station, CargoPacket::source_id, CargoPacket::source_type, and CargoPacket::source_xy.
int StationCargoList::CountForNextHop | ( | OrderID | order | ) | const [inline] |
Gets the cargo count for a next hop.
order | The next hop. |
Definition at line 431 of file cargopacket.h.
const OrderMap& StationCargoList::CountForNextHop | ( | ) | const [inline] |
Gets the cargo counts per next hop.
Definition at line 421 of file cargopacket.h.
Referenced by SmallMapWindow::DrawRouteLinks(), LoadUnloadStation(), LoadUnloadVehicle(), and CYapfCostRouteLinkT< Types >::RouteLinkCost().
void StationCargoList::InvalidateAllTo | ( | SourceType | type, | |
SourceID | dest | |||
) | [static] |
Invalidates the next hop info of all cargo packets for a given destination.
order | Next order to invalidate. |
Definition at line 647 of file cargopacket.cpp.
References AddToCache(), GoodsEntry::cargo, CargoPacket::dest_id, CargoPacket::dest_type, Station::goods, INVALID_ORDER, CargoPacket::next_order, CargoPacket::next_station, NUM_CARGO, CargoList< Tinst >::packets, and RemoveFromCache().
void StationCargoList::InvalidateAllTo | ( | OrderID | order, | |
StationID | st_unload | |||
) | [static] |
Invalidates the next hop info of all cargo packets with a given next order or unload station.
order | Next order to invalidate. | |
st_unload | Unload station to invalidate. |
Definition at line 623 of file cargopacket.cpp.
References AddToCache(), GoodsEntry::cargo, Station::goods, INVALID_ORDER, CargoPacket::next_order, CargoPacket::next_station, NUM_CARGO, CargoList< Tinst >::packets, and RemoveFromCache().
Referenced by CargoPacket::InvalidateAllFrom(), and RouteLink::~RouteLink().
void StationCargoList::InvalidateCache | ( | ) |
Invalidates the cached data and rebuild it.
Reimplemented from CargoList< StationCargoList >.
Definition at line 557 of file cargopacket.cpp.
References CargoList< StationCargoList >::InvalidateCache().
Referenced by CargoPacket::AfterLoad(), and CheckCaches().
void StationCargoList::RemoveFromCache | ( | const CargoPacket * | cp | ) | [protected] |
Update the cached values to reflect the removal of this packet.
Decreases count and days_in_transit.
cp | Packet to be removed from cache. |
Reimplemented from CargoList< StationCargoList >.
Definition at line 539 of file cargopacket.cpp.
References CargoPacket::count, CargoList< StationCargoList >::RemoveFromCache(), and RemoveFromCacheLocal().
Referenced by InvalidateAllTo(), and UpdateCargoNextHop().
void StationCargoList::RemoveFromCacheLocal | ( | const CargoPacket * | cp, | |
uint | amount | |||
) | [protected] |
Update the local next-hop count cache.
cp | Packet the be removed. | |
amount | Cargo amount to be removed. |
Reimplemented from CargoList< StationCargoList >.
Definition at line 528 of file cargopacket.cpp.
References CargoPacket::next_order.
Referenced by RemoveFromCache().
Recompute the desired next hop of all cargo packets.
st | Station of this list. | |
cid | Cargo type of this list. |
Definition at line 596 of file cargopacket.cpp.
References _settings_game, EconomySettings::cargodest, CargoList< StationCargoList >::count, GameSettings::economy, INVALID_SOURCE, next_start, CargoList< StationCargoList >::packets, CargodestSettings::route_recalc_chunk, and UpdateCargoNextHop().
bool StationCargoList::UpdateCargoNextHop | ( | CargoPacket * | cp, | |
Station * | st, | |||
CargoID | cid | |||
) | [protected, virtual] |
Recompute the desired next hop of a cargo packet.
cp | Cargo packet to update. | |
st | Station of this list. | |
cid | Cargo type of this list. |
Reimplemented from CargoList< StationCargoList >.
Definition at line 570 of file cargopacket.cpp.
References AddToCache(), FindRouteLinkForCargo(), RouteLink::GetOriginOrderId(), CargoPacket::next_order, CargoPacket::next_station, and RemoveFromCache().
Referenced by Vehicle::BeginLoading(), and UpdateCargoNextHop().
friend class CargoList< StationCargoList > [friend] |
The super class ought to know what it's doing.
Definition at line 409 of file cargopacket.h.
struct SaveLoad* GetGoodsDesc | ( | ) | [friend] |
The stations, via GoodsEntry, have a CargoList.
Definition at line 244 of file station_sl.cpp.