Container for cargo from the same location and time. More...
#include <cargopacket.h>
Public Member Functions | |
CargoPacket () | |
Create a new packet for savegame loading. | |
CargoPacket (StationID source, TileIndex source_xy, uint16 count, SourceType source_type, SourceID source_id, TileIndex dest_xy=INVALID_TILE, SourceType dest_type=ST_INDUSTRY, SourceID dest_id=INVALID_SOURCE, OrderID next_order=INVALID_ORDER, StationID next_station=INVALID_STATION, byte flags=0) | |
Creates a new cargo packet. | |
CargoPacket (uint16 count, byte days_in_transit, StationID source, TileIndex source_xy, TileIndex loaded_at_xy, Money feeder_share=0, SourceType source_type=ST_INDUSTRY, SourceID source_id=INVALID_SOURCE, TileIndex dest_xy=INVALID_TILE, SourceType dest_type=ST_INDUSTRY, SourceID dest_id=INVALID_SOURCE, OrderID next_order=INVALID_ORDER, StationID next_station=INVALID_STATION, byte flags=0) | |
Creates a new cargo packet. | |
~CargoPacket () | |
Destroy the packet. | |
CargoPacket * | Split (uint new_size) |
Split this packet in two and return the split off part. | |
void | Merge (CargoPacket *cp) |
Merge another packet into this one. | |
FORCEINLINE uint16 | Count () const |
Gets the number of 'items' in this packet. | |
FORCEINLINE Money | FeederShare () const |
Gets the amount of money already paid to earlier vehicles in the feeder chain. | |
FORCEINLINE byte | DaysInTransit () const |
Gets the number of days this cargo has been in transit. | |
FORCEINLINE SourceType | SourceSubsidyType () const |
Gets the type of the cargo's source. | |
FORCEINLINE SourceID | SourceSubsidyID () const |
Gets the ID of the cargo's source. | |
FORCEINLINE SourceID | SourceStation () const |
Gets the ID of the station where the cargo was loaded for the first time. | |
FORCEINLINE TileIndex | SourceStationXY () const |
Gets the coordinates of the cargo's source station. | |
FORCEINLINE TileIndex | LoadedAtXY () const |
Gets the coordinates of the cargo's last loading station. | |
FORCEINLINE TileIndex | DestinationXY () const |
Gets the coordinates of the cargo's destination. | |
FORCEINLINE SourceID | DestinationID () const |
Gets the ID of the destination of the cargo. | |
FORCEINLINE SourceType | DestinationType () const |
Gets the type of the destination of the cargo. | |
FORCEINLINE byte | Flags () const |
Gets the routing behaviour flags of this packet. | |
FORCEINLINE OrderID | NextHop () const |
Gets the order ID of the next desired hop. | |
FORCEINLINE StationID | NextStation () const |
Gets the station ID where the packet should be unloaded next. | |
Static Public Member Functions | |
static void | InvalidateAllFrom (SourceType src_type, SourceID src) |
Invalidates (sets source_id to INVALID_SOURCE) all cargo packets from given source. | |
static void | InvalidateAllFrom (StationID sid) |
Invalidates (sets source to INVALID_STATION) all cargo packets from given station. | |
static void | AfterLoad () |
Savegame conversion for cargopackets. | |
Static Public Attributes | |
static const uint16 | MAX_COUNT = UINT16_MAX |
Maximum number of items in a single cargo packet. | |
Private Attributes | |
Money | feeder_share |
Value of feeder pickup to be paid for on delivery of cargo. | |
uint16 | count |
The amount of cargo in this packet. | |
byte | days_in_transit |
Amount of days this packet has been in transit. | |
SourceTypeByte | source_type |
Type of source_id . | |
SourceID | source_id |
Index of source, INVALID_SOURCE if unknown/invalid. | |
StationID | source |
The station where the cargo came from first. | |
TileIndex | source_xy |
The origin of the cargo (first station in feeder chain). | |
TileIndex | loaded_at_xy |
Location where this cargo has been loaded into the vehicle. | |
TileIndex | dest_xy |
Destination tile or INVALID_TILE if no specific destination. | |
SourceID | dest_id |
Index of the destination. | |
SourceTypeByte | dest_type |
Type of dest_id. | |
byte | flags |
Flags influencing the routing decision of this packet, see RouteFlags. | |
OrderID | next_order |
Next desired hop. | |
StationID | next_station |
Unload at this station next. | |
Friends | |
class | CargoList |
The CargoList caches, thus needs to know about it. | |
class | VehicleCargoList |
class | StationCargoList |
struct SaveLoad * | GetCargoPacketDesc () |
We want this to be saved, right? | |
bool | CargodestModeChanged (int32 p1) |
Container for cargo from the same location and time.
Definition at line 40 of file cargopacket.h.
CargoPacket::CargoPacket | ( | StationID | source, | |
TileIndex | source_xy, | |||
uint16 | count, | |||
SourceType | source_type, | |||
SourceID | source_id, | |||
TileIndex | dest_xy = INVALID_TILE , |
|||
SourceType | dest_type = ST_INDUSTRY , |
|||
SourceID | dest_id = INVALID_SOURCE , |
|||
OrderID | next_order = INVALID_ORDER , |
|||
StationID | next_station = INVALID_STATION , |
|||
byte | flags = 0 | |||
) |
Creates a new cargo packet.
source | Source station of the packet. | |
source_xy | Source location of the packet. | |
count | Number of cargo entities to put in this packet. | |
source_type | 'Type' of source the packet comes from (for subsidies). | |
source_id | Actual source of the packet (for subsidies). | |
dest_xy | Destination location of the packet. | |
dest_type | 'Type' of the destination. | |
dest_id | Actual destination of the packet. | |
next_order | Desired next hop of the packet. | |
next_station | Station to unload the packet next. | |
flags | Routing flags of the packet. |
Definition at line 56 of file cargopacket.cpp.
CargoPacket::CargoPacket | ( | uint16 | count, | |
byte | days_in_transit, | |||
StationID | source, | |||
TileIndex | source_xy, | |||
TileIndex | loaded_at_xy, | |||
Money | feeder_share = 0 , |
|||
SourceType | source_type = ST_INDUSTRY , |
|||
SourceID | source_id = INVALID_SOURCE , |
|||
TileIndex | dest_xy = INVALID_TILE , |
|||
SourceType | dest_type = ST_INDUSTRY , |
|||
SourceID | dest_id = INVALID_SOURCE , |
|||
OrderID | next_order = INVALID_ORDER , |
|||
StationID | next_station = INVALID_STATION , |
|||
byte | flags = 0 | |||
) |
Creates a new cargo packet.
Initializes the fields that cannot be changed later. Used when loading or splitting packets.
count | Number of cargo entities to put in this packet. | |
days_in_transit | Number of days the cargo has been in transit. | |
source | Station the cargo was initially loaded. | |
source_xy | Station location the cargo was initially loaded. | |
loaded_at_xy | Location the cargo was loaded last. | |
feeder_share | Feeder share the packet has already accumulated. | |
source_type | 'Type' of source the packet comes from (for subsidies). | |
source_id | Actual source of the packet (for subsidies). | |
dest_xy | Destination location of the packet. | |
dest_type | 'Type' of the destination. | |
dest_id | Actual destination of the packet. | |
next_order | Desired next hop of the packet. | |
next_station | Station to unload the packet next. | |
flags | Routing flags of the packet. |
Definition at line 95 of file cargopacket.cpp.
CargoPacket::~CargoPacket | ( | ) | [inline] |
Destroy the packet.
Definition at line 73 of file cargopacket.h.
FORCEINLINE uint16 CargoPacket::Count | ( | ) | const [inline] |
Gets the number of 'items' in this packet.
Definition at line 82 of file cargopacket.h.
References count.
Referenced by AddCargoPacketToList(), AddVehicleCargoDestSummary(), and StationViewWindow::OrderWaitingCargo().
FORCEINLINE byte CargoPacket::DaysInTransit | ( | ) | const [inline] |
Gets the number of days this cargo has been in transit.
This number isn't really in days, but in 2.5 days (185 ticks) and it is capped at 255.
Definition at line 103 of file cargopacket.h.
References days_in_transit.
Referenced by CargoPayment::PayFinalDelivery(), and CargoPayment::PayTransfer().
FORCEINLINE SourceID CargoPacket::DestinationID | ( | ) | const [inline] |
Gets the ID of the destination of the cargo.
Definition at line 166 of file cargopacket.h.
References dest_id.
Referenced by AddCargoPacketToList(), AddVehicleCargoDestSummary(), FindRouteLinkForCargo(), CargoList< Tinst >::MoveTo(), and CargoPayment::PayFinalDelivery().
FORCEINLINE SourceType CargoPacket::DestinationType | ( | ) | const [inline] |
Gets the type of the destination of the cargo.
Definition at line 175 of file cargopacket.h.
References dest_type.
Referenced by AddCargoPacketToList(), AddVehicleCargoDestSummary(), FindRouteLinkForCargo(), and CargoPayment::PayFinalDelivery().
FORCEINLINE TileIndex CargoPacket::DestinationXY | ( | ) | const [inline] |
Gets the coordinates of the cargo's destination.
Definition at line 157 of file cargopacket.h.
References dest_xy.
Referenced by FindRouteLinkForCargo().
FORCEINLINE Money CargoPacket::FeederShare | ( | ) | const [inline] |
Gets the amount of money already paid to earlier vehicles in the feeder chain.
Definition at line 92 of file cargopacket.h.
References feeder_share.
Referenced by CargoPayment::PayFinalDelivery().
FORCEINLINE byte CargoPacket::Flags | ( | ) | const [inline] |
Gets the routing behaviour flags of this packet.
Definition at line 184 of file cargopacket.h.
References flags.
Referenced by FindRouteLinkForCargo().
void CargoPacket::InvalidateAllFrom | ( | StationID | sid | ) | [static] |
Invalidates (sets source to INVALID_STATION) all cargo packets from given station.
sid | Station that gets removed. |
Definition at line 165 of file cargopacket.cpp.
References FOR_ALL_CARGOPACKETS, next_station, and source.
void CargoPacket::InvalidateAllFrom | ( | SourceType | src_type, | |
SourceID | src | |||
) | [static] |
Invalidates (sets source_id to INVALID_SOURCE) all cargo packets from given source.
src_type | Type of source. | |
src | Index of source. |
Definition at line 146 of file cargopacket.cpp.
References dest_id, dest_type, dest_xy, FOR_ALL_CARGOPACKETS, INVALID_SOURCE, INVALID_TILE, StationCargoList::InvalidateAllTo(), source_id, and source_type.
Referenced by Station::~Station(), and Town::~Town().
FORCEINLINE TileIndex CargoPacket::LoadedAtXY | ( | ) | const [inline] |
Gets the coordinates of the cargo's last loading station.
Definition at line 148 of file cargopacket.h.
References loaded_at_xy.
Referenced by CargoPayment::PayTransfer().
FORCEINLINE void CargoPacket::Merge | ( | CargoPacket * | cp | ) |
Merge another packet into this one.
cp | Packet to be merged in. |
Definition at line 134 of file cargopacket.cpp.
References count, and feeder_share.
Referenced by CargoList< Tinst >::Append().
FORCEINLINE OrderID CargoPacket::NextHop | ( | ) | const [inline] |
Gets the order ID of the next desired hop.
Definition at line 193 of file cargopacket.h.
References next_order.
Referenced by GetNextHopStation(), and CargoList< Tinst >::MoveTo().
FORCEINLINE StationID CargoPacket::NextStation | ( | ) | const [inline] |
Gets the station ID where the packet should be unloaded next.
Definition at line 202 of file cargopacket.h.
References next_station.
Referenced by AddCargoPacketToList(), and CargoList< Tinst >::MoveTo().
FORCEINLINE SourceID CargoPacket::SourceStation | ( | ) | const [inline] |
Gets the ID of the station where the cargo was loaded for the first time.
Definition at line 130 of file cargopacket.h.
References source.
Referenced by StationViewWindow::OrderWaitingCargo().
FORCEINLINE TileIndex CargoPacket::SourceStationXY | ( | ) | const [inline] |
Gets the coordinates of the cargo's source station.
Definition at line 139 of file cargopacket.h.
References source_xy.
Referenced by CargoPayment::PayFinalDelivery().
FORCEINLINE SourceID CargoPacket::SourceSubsidyID | ( | ) | const [inline] |
Gets the ID of the cargo's source.
An IndustryID, TownID or CompanyID.
Definition at line 121 of file cargopacket.h.
References source_id.
Referenced by CargoPayment::PayFinalDelivery().
FORCEINLINE SourceType CargoPacket::SourceSubsidyType | ( | ) | const [inline] |
Gets the type of the cargo's source.
industry, town or head quarter.
Definition at line 112 of file cargopacket.h.
References source_type.
Referenced by CargoPayment::PayFinalDelivery().
FORCEINLINE CargoPacket * CargoPacket::Split | ( | uint | new_size | ) |
Split this packet in two and return the split off part.
new_size | Size of the remaining part. |
Definition at line 119 of file cargopacket.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_cargopacket_pool >::CanAllocateItem(), CargoPacket(), count, days_in_transit, dest_id, dest_type, dest_xy, feeder_share, flags, loaded_at_xy, next_order, next_station, source, source_id, source_type, and source_xy.
Referenced by CargoList< Tinst >::MoveTo().
friend class CargoList [friend] |
The CargoList caches, thus needs to know about it.
Definition at line 58 of file cargopacket.h.
struct SaveLoad* GetCargoPacketDesc | ( | ) | [friend] |
We want this to be saved, right?
Definition at line 87 of file cargopacket_sl.cpp.
const uint16 CargoPacket::MAX_COUNT = UINT16_MAX [static] |
Maximum number of items in a single cargo packet.
Definition at line 66 of file cargopacket.h.
Referenced by CargoList< Tinst >::Append().