An entity producing or accepting cargo with a destination. More...
#include <cargodest_base.h>
Public Member Functions | |
virtual SourceType | GetType () const =0 |
Get the type of this entity. | |
virtual SourceID | GetID () const =0 |
Get the source ID corresponding with this entity. | |
bool | HasLinkTo (CargoID cid, const CargoSourceSink *dest) const |
Test if a demand link to a destination exists. | |
virtual bool | AcceptsCargo (CargoID cid) const =0 |
Is this cargo accepted? | |
virtual bool | SuppliesCargo (CargoID cid) const =0 |
Is this cargo produced? | |
virtual uint | GetDestinationWeight (CargoID cid, byte weight_mod) const =0 |
Get the link weight for this as a destination for a specific cargo. | |
CargoLink * | GetRandomLink (CargoID cid, bool allow_self) |
Get a random demand link. | |
virtual void | CreateSpecialLinks (CargoID cid) |
Create the special cargo links for a cargo if not already present. | |
virtual TileArea | GetTileForDestination (CargoID cid)=0 |
Get a random destination tile index for this cargo. | |
void | SaveCargoSourceSink () |
void | LoadCargoSourceSink () |
void | PtrsCargoSourceSink () |
Data Fields | |
SmallVector< CargoLink, 8 > | cargo_links [NUM_CARGO] |
List of destinations for each cargo type. | |
uint | cargo_links_weight [NUM_CARGO] |
Sum of the destination weights for each cargo type. | |
uint16 | num_links_expected [NUM_CARGO] |
NOSAVE: Desired link count for each cargo. | |
uint | num_incoming_links [NUM_CARGO] |
NOSAVE: Incoming link count for each cargo. |
An entity producing or accepting cargo with a destination.
Definition at line 44 of file cargodest_base.h.
void CargoSourceSink::CreateSpecialLinks | ( | CargoID | cid | ) | [virtual] |
Create the special cargo links for a cargo if not already present.
Reimplemented in Town.
Definition at line 317 of file cargodest.cpp.
References SmallVector< T, S >::Append(), cargo_links, SmallVector< T, S >::Get(), and LWM_ANYWHERE.
Referenced by UpdateExpectedLinks().
virtual uint CargoSourceSink::GetDestinationWeight | ( | CargoID | cid, | |
byte | weight_mod | |||
) | const [pure virtual] |
virtual SourceID CargoSourceSink::GetID | ( | ) | const [pure virtual] |
Get the source ID corresponding with this entity.
Implemented in Industry, and Town.
Referenced by MoveCargoWithDestinationToStationWorker().
Get a random demand link.
cid | Cargo type | |
allow_self | Indicates if the local link is acceptable as a result. |
Definition at line 752 of file cargodest.cpp.
References AcceptsCargo(), cargo_links, cargo_links_weight, CargoLink::dest, SmallVector< T, S >::End(), and CargoLink::weight.
Referenced by MoveCargoWithDestinationToStationWorker().
Get a random destination tile index for this cargo.
Implemented in Industry, and Town.
Referenced by MoveCargoWithDestinationToStationWorker().
virtual SourceType CargoSourceSink::GetType | ( | ) | const [pure virtual] |
Get the type of this entity.
Implemented in Industry, and Town.
Referenced by MoveCargoWithDestinationToStationWorker(), and CargoDestinationList::OnClick().
bool CargoSourceSink::HasLinkTo | ( | CargoID | cid, | |
const CargoSourceSink * | dest | |||
) | const [inline] |
Test if a demand link to a destination exists.
cid | Cargo type for which a link should be searched. | |
dest | Destination to search for. |
Definition at line 69 of file cargodest_base.h.
References cargo_links, and SmallVector< T, S >::Contains().
Referenced by EnumAnyDest(), and RemoveLowestLink().
SmallVector<CargoLink, 8> CargoSourceSink::cargo_links[NUM_CARGO] |
List of destinations for each cargo type.
Definition at line 46 of file cargodest_base.h.
Referenced by AddMissingIndustryLinks(), CreateNewLinks(), Town::CreateSpecialLinks(), CreateSpecialLinks(), EnumAnyDest(), GetRandomLink(), HasLinkTo(), MoveCargoWithDestinationToStationWorker(), RebuildCargoLinkCounts(), CargoDestinationList::RebuildList(), RemoveInvalidLinks(), RemoveLowestLink(), UpdateExpectedLinks(), and UpdateLinkWeights().
uint CargoSourceSink::cargo_links_weight[NUM_CARGO] |
Sum of the destination weights for each cargo type.
Definition at line 48 of file cargodest_base.h.
Referenced by GetRandomLink(), RemoveInvalidLinks(), and UpdateLinkWeights().
uint CargoSourceSink::num_incoming_links[NUM_CARGO] |
NOSAVE: Incoming link count for each cargo.
Definition at line 54 of file cargodest_base.h.
Referenced by AddMissingIndustryLinks(), CreateNewLinks(), RebuildCargoLinkCounts(), and RemoveLowestLink().
uint16 CargoSourceSink::num_links_expected[NUM_CARGO] |
NOSAVE: Desired link count for each cargo.
Definition at line 51 of file cargodest_base.h.
Referenced by AddMissingIndustryLinks(), CreateNewLinks(), EnumAnyDest(), and UpdateExpectedLinks().