#include <cargopacket.h>
Public Types | |
| enum | MoveToAction { MTA_FINAL_DELIVERY, MTA_CARGO_LOAD, MTA_OTHER } |
| Kind of actions that could be done with packets on move. More... | |
| typedef std::list< CargoPacket * > | List |
| List of cargo packets. | |
Public Member Functions | |
| CargoList () | |
| Create the cargo list. | |
| ~CargoList () | |
| And destroy it ("frees" all cargo packets). | |
| const CargoList::List * | Packets () const |
| Returns a pointer to the cargo packet list (so you can iterate over it etc). | |
| void | AgeCargo () |
| Ages the all cargo in this list. | |
| bool | Empty () const |
| Checks whether this list is empty. | |
| uint | Count () const |
| Returns the number of cargo entities in this list. | |
| bool | UnpaidCargo () const |
| Is there some cargo that has not been paid for? | |
| Money | FeederShare () const |
| Returns total sum of the feeder share for all packets. | |
| StationID | Source () const |
| Returns source of the first cargo packet in this list. | |
| uint | DaysInTransit () const |
| Returns average number of days in transit for a cargo entity. | |
| void | Append (CargoPacket *cp) |
| Appends the given cargo packet. | |
| void | Truncate (uint count) |
| Truncates the cargo in this list to the given amount. | |
| bool | MoveTo (CargoList *dest, uint count, CargoList::MoveToAction mta=MTA_OTHER, uint data=0) |
| Moves the given amount of cargo to another list. | |
| void | InvalidateCache () |
| Invalidates the cached data and rebuild it. | |
Private Attributes | |
| List | packets |
| The cargo packets in this list. | |
| bool | empty |
| Cache for whether this list is empty or not. | |
| uint | count |
| Cache for the number of cargo entities. | |
| bool | unpaid_cargo |
| Cache for the unpaid cargo. | |
| Money | feeder_share |
| Cache for the feeder share. | |
| StationID | source |
| Cache for the source of the packet. | |
| uint | days_in_transit |
| Cache for the number of days in transit. | |
Friends | |
| void | SaveLoad_STNS (Station *st) |
Definition at line 79 of file cargopacket.h.
Kind of actions that could be done with packets on move.
Definition at line 85 of file cargopacket.h.
| const CargoList::List * CargoList::Packets | ( | ) | const |
Returns a pointer to the cargo packet list (so you can iterate over it etc).
Definition at line 57 of file cargopacket.cpp.
References packets.
| bool CargoList::Empty | ( | ) | const |
Checks whether this list is empty.
Definition at line 74 of file cargopacket.cpp.
References empty.
Referenced by MoveTo().
| uint CargoList::Count | ( | ) | const |
Returns the number of cargo entities in this list.
Definition at line 79 of file cargopacket.cpp.
References count.
| bool CargoList::UnpaidCargo | ( | ) | const |
Is there some cargo that has not been paid for?
Definition at line 84 of file cargopacket.cpp.
References unpaid_cargo.
| Money CargoList::FeederShare | ( | ) | const |
Returns total sum of the feeder share for all packets.
Definition at line 89 of file cargopacket.cpp.
References feeder_share.
| StationID CargoList::Source | ( | ) | const |
Returns source of the first cargo packet in this list.
Definition at line 94 of file cargopacket.cpp.
References source.
| uint CargoList::DaysInTransit | ( | ) | const |
Returns average number of days in transit for a cargo entity.
Definition at line 99 of file cargopacket.cpp.
References days_in_transit.
| void CargoList::Append | ( | CargoPacket * | cp | ) |
Appends the given cargo packet.
| cp | the cargo packet to add |
Definition at line 104 of file cargopacket.cpp.
References CargoPacket::count, CargoPacket::feeder_share, InvalidateCache(), CargoPacket::IsValid(), and packets.
Referenced by MoveTo().
| void CargoList::Truncate | ( | uint | count | ) |
Truncates the cargo in this list to the given amount.
It leaves the first count cargo entities and removes the rest.
| count | the maximum amount of entities to be in the list after the command |
Definition at line 126 of file cargopacket.cpp.
References CargoPacket::count, InvalidateCache(), and packets.
| bool CargoList::MoveTo | ( | CargoList * | dest, | |
| uint | count, | |||
| CargoList::MoveToAction | mta = MTA_OTHER, |
|||
| uint | data = 0 | |||
| ) |
Moves the given amount of cargo to another list.
Depending on the value of mta the side effects of this function differ:
| dest | the destination to move the cargo to | |
| count | the amount of cargo entities to move | |
| mta | how to handle the moving (side effects) | |
| data | Depending on mta the data of this variable differs:
| |
| mta | == MTA_FINAL_DELIVERY || dest != NULL |
Definition at line 149 of file cargopacket.cpp.
References Append(), CargoPacket::count, CargoPacket::days_in_transit, Empty(), CargoPacket::feeder_share, InvalidateCache(), CargoPacket::loaded_at_xy, MoveTo(), MTA_CARGO_LOAD, MTA_FINAL_DELIVERY, MTA_OTHER, packets, CargoPacket::paid_for, CargoPacket::source, and CargoPacket::source_xy.
Referenced by MoveTo().
1.5.6