CargoSourceSink Struct Reference

An entity producing or accepting cargo with a destination. More...

#include <cargodest_base.h>

Inheritance diagram for CargoSourceSink:
Industry Town

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.
CargoLinkGetRandomLink (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.

Detailed Description

An entity producing or accepting cargo with a destination.

Definition at line 44 of file cargodest_base.h.


Member Function Documentation

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]

Get the link weight for this as a destination for a specific cargo.

Implemented in Industry, and Town.

virtual SourceID CargoSourceSink::GetID (  )  const [pure virtual]

Get the source ID corresponding with this entity.

Implemented in Industry, and Town.

Referenced by MoveCargoWithDestinationToStationWorker().

CargoLink * CargoSourceSink::GetRandomLink ( CargoID  cid,
bool  allow_self 
)

Get a random demand link.

Parameters:
cid Cargo type
allow_self Indicates if the local link is acceptable as a result.
Returns:
Pointer to a demand link or this->cargo_links[cid].End() if no link found.

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().

virtual TileArea CargoSourceSink::GetTileForDestination ( CargoID  cid  )  [pure virtual]

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.

Parameters:
cid Cargo type for which a link should be searched.
dest Destination to search for.
Returns:
True if a link to the destination is present.

Definition at line 69 of file cargodest_base.h.

References cargo_links, and SmallVector< T, S >::Contains().

Referenced by EnumAnyDest(), and RemoveLowestLink().


Field Documentation

Sum of the destination weights for each cargo type.

Definition at line 48 of file cargodest_base.h.

Referenced by GetRandomLink(), RemoveInvalidLinks(), and UpdateLinkWeights().

NOSAVE: Incoming link count for each cargo.

Definition at line 54 of file cargodest_base.h.

Referenced by AddMissingIndustryLinks(), CreateNewLinks(), RebuildCargoLinkCounts(), and RemoveLowestLink().

NOSAVE: Desired link count for each cargo.

Definition at line 51 of file cargodest_base.h.

Referenced by AddMissingIndustryLinks(), CreateNewLinks(), EnumAnyDest(), and UpdateExpectedLinks().


The documentation for this struct was generated from the following files:

Generated on Sun May 8 07:30:58 2011 for OpenTTD by  doxygen 1.6.1