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) | |
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) | |
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. | |
void | Reduce (uint count) |
Reduce the packet by the given amount and remove the feeder share. | |
void | SetLoadPlace (TileIndex load_place) |
Sets the tile where the packet was loaded last. | |
void | AddFeederShare (Money new_share) |
Adds some feeder share to the packet. | |
uint16 | Count () const |
Gets the number of 'items' in this packet. | |
Money | FeederShare () const |
Gets the amount of money already paid to earlier vehicles in the feeder chain. | |
Money | FeederShare (uint part) const |
Gets part of the amount of money already paid to earlier vehicles in the feeder chain. | |
byte | DaysInTransit () const |
Gets the number of days this cargo has been in transit. | |
SourceType | SourceSubsidyType () const |
Gets the type of the cargo's source. | |
SourceID | SourceSubsidyID () const |
Gets the ID of the cargo's source. | |
SourceID | SourceStation () const |
Gets the ID of the station where the cargo was loaded for the first time. | |
TileIndex | SourceStationXY () const |
Gets the coordinates of the cargo's source station. | |
TileIndex | LoadedAtXY () const |
Gets the coordinates of the cargo's last loading station. | |
StationID | NextStation () const |
Gets the ID of station the cargo wants to go 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). | |
union { | |
TileIndex loaded_at_xy | |
Location where this cargo has been loaded into the vehicle. | |
StationID next_station | |
Station where the cargo wants to go 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? |
Container for cargo from the same location and time.
Definition at line 42 of file cargopacket.h.
CargoPacket::CargoPacket | ( | StationID | source, | |
TileIndex | source_xy, | |||
uint16 | count, | |||
SourceType | source_type, | |||
SourceID | source_id | |||
) |
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). |
Definition at line 44 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 | |||
) |
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). |
Definition at line 71 of file cargopacket.cpp.
CargoPacket::~CargoPacket | ( | ) | [inline] |
Destroy the packet.
Definition at line 71 of file cargopacket.h.
void CargoPacket::AddFeederShare | ( | Money | new_share | ) | [inline] |
Adds some feeder share to the packet.
new_share | Feeder share to be added. |
Definition at line 87 of file cargopacket.h.
References feeder_share.
uint16 CargoPacket::Count | ( | ) | const [inline] |
Gets the number of 'items' in this packet.
Definition at line 93 of file cargopacket.h.
References count.
Referenced by StationViewWindow::BuildCargoList(), CargoReroute::operator()(), CargoShift::operator()(), CargoTransfer::operator()(), CargoReturn::operator()(), CargoReservation::operator()(), CargoLoad::operator()(), CargoRemoval< Tsource >::Postprocess(), CargoRemoval< Tsource >::Preprocess(), and CargoMovement< Tsource, Tdest >::Preprocess().
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 (CARGO_AGING_TICKS = 185 ticks) and it is capped at 255.
Definition at line 125 of file cargopacket.h.
References days_in_transit.
Referenced by CargoPayment::PayFinalDelivery(), and CargoPayment::PayTransfer().
Money CargoPacket::FeederShare | ( | uint | part | ) | const [inline] |
Gets part of the amount of money already paid to earlier vehicles in the feeder chain.
part | Amount of cargo to get the share for. |
Definition at line 114 of file cargopacket.h.
References count, and feeder_share.
Money CargoPacket::FeederShare | ( | ) | const [inline] |
Gets the amount of money already paid to earlier vehicles in the feeder chain.
Definition at line 103 of file cargopacket.h.
References feeder_share.
Referenced by CargoPayment::PayFinalDelivery(), Reduce(), VehicleCargoList::RemoveFromCache(), and Split().
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 127 of file cargopacket.cpp.
References FOR_ALL_CARGOPACKETS, INVALID_SOURCE, source_id, and source_type.
Referenced by Station::~Station(), and Town::~Town().
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 139 of file cargopacket.cpp.
References FOR_ALL_CARGOPACKETS, and source.
TileIndex CargoPacket::LoadedAtXY | ( | ) | const [inline] |
Gets the coordinates of the cargo's last loading station.
Definition at line 170 of file cargopacket.h.
References loaded_at_xy.
Referenced by CargoPayment::PayTransfer().
void CargoPacket::Merge | ( | CargoPacket * | cp | ) |
Merge another packet into this one.
cp | Packet to be merged in. |
Definition at line 104 of file cargopacket.cpp.
References count, and feeder_share.
Referenced by CargoList< Tinst, Tcont >::TryMerge().
StationID CargoPacket::NextStation | ( | ) | const [inline] |
Gets the ID of station the cargo wants to go next.
Definition at line 179 of file cargopacket.h.
References next_station.
Referenced by CargoTransfer::operator()().
void CargoPacket::Reduce | ( | uint | count | ) |
Reduce the packet by the given amount and remove the feeder share.
count | Amount to be removed. |
Definition at line 115 of file cargopacket.cpp.
References feeder_share, and FeederShare().
Referenced by CargoRemoval< Tsource >::Postprocess(), and StationCargoList::Truncate().
void CargoPacket::SetLoadPlace | ( | TileIndex | load_place | ) | [inline] |
Sets the tile where the packet was loaded last.
load_place | Tile where the packet was loaded last. |
Definition at line 81 of file cargopacket.h.
References loaded_at_xy.
Referenced by CargoReservation::operator()(), and CargoLoad::operator()().
SourceID CargoPacket::SourceStation | ( | ) | const [inline] |
Gets the ID of the station where the cargo was loaded for the first time.
Definition at line 152 of file cargopacket.h.
References source.
Referenced by StationViewWindow::BuildCargoList(), and CargoReroute::operator()().
TileIndex CargoPacket::SourceStationXY | ( | ) | const [inline] |
Gets the coordinates of the cargo's source station.
Definition at line 161 of file cargopacket.h.
References source_xy.
Referenced by CargoPayment::PayFinalDelivery().
SourceID CargoPacket::SourceSubsidyID | ( | ) | const [inline] |
Gets the ID of the cargo's source.
An IndustryID, TownID or CompanyID.
Definition at line 143 of file cargopacket.h.
References source_id.
Referenced by CargoPayment::PayFinalDelivery().
SourceType CargoPacket::SourceSubsidyType | ( | ) | const [inline] |
Gets the type of the cargo's source.
industry, town or head quarter.
Definition at line 134 of file cargopacket.h.
References source_type.
Referenced by CargoPayment::PayFinalDelivery().
CargoPacket * CargoPacket::Split | ( | uint | new_size | ) |
Split this packet in two and return the split off part.
new_size | Size of the split part. |
Definition at line 89 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, feeder_share, FeederShare(), loaded_at_xy, source, source_id, source_type, and source_xy.
Referenced by CargoMovement< Tsource, Tdest >::Preprocess().
friend class CargoList [friend] |
The CargoList caches, thus needs to know about it.
Definition at line 57 of file cargopacket.h.
struct SaveLoad* GetCargoPacketDesc | ( | ) | [friend] |
We want this to be saved, right?
Definition at line 92 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 64 of file cargopacket.h.
Referenced by CargoList< Tinst, Tcont >::TryMerge().