OpenTTD Source  20241120-master-g6d3adc6169
GoodsEntry Struct Reference

Stores station stats for a single cargo. More...

#include <station_base.h>

Public Types

enum  GoodsEntryStatus {
  GES_ACCEPTANCE , GES_RATING , GES_EVER_ACCEPTED , GES_LAST_MONTH ,
  GES_CURRENT_MONTH , GES_ACCEPTED_BIGTICK
}
 Status of this cargo for the station. More...
 

Public Member Functions

bool HasVehicleEverTriedLoading () const
 Reports whether a vehicle has ever tried to load the cargo at this station. More...
 
bool HasRating () const
 Does this cargo have a rating at this station? More...
 
StationID GetVia (StationID source) const
 Get the best next hop for a cargo packet from station source. More...
 
StationID GetVia (StationID source, StationID excluded, StationID excluded2=INVALID_STATION) const
 Get the best next hop for a cargo packet from station source, optionally excluding one or two stations. More...
 

Data Fields

StationCargoList cargo {}
 The cargo packets of cargo waiting in this station.
 
FlowStatMap flows {}
 Planned flows through this station.
 
uint max_waiting_cargo = 0
 Max cargo from this station waiting at any station.
 
NodeID node = INVALID_NODE
 ID of node in link graph referring to this goods entry.
 
LinkGraphID link_graph = INVALID_LINK_GRAPH
 Link graph this station belongs to.
 
uint8_t status = 0
 Status of this cargo, see GoodsEntryStatus.
 
uint8_t time_since_pickup = 255
 Number of rating-intervals (up to 255) since the last vehicle tried to load this cargo. More...
 
uint8_t rating = INITIAL_STATION_RATING
 Station rating for this cargo.
 
uint8_t last_speed = 0
 Maximum speed (up to 255) of the last vehicle that tried to load this cargo. More...
 
uint8_t last_age = 255
 Age in years (up to 255) of the last vehicle that tried to load this cargo. More...
 
uint8_t amount_fract = 0
 Fractional part of the amount in the cargo list.
 

Detailed Description

Stores station stats for a single cargo.

Definition at line 166 of file station_base.h.

Member Enumeration Documentation

◆ GoodsEntryStatus

Status of this cargo for the station.

Enumerator
GES_ACCEPTANCE 

Set when the station accepts the cargo currently for final deliveries.

It is updated every STATION_ACCEPTANCE_TICKS ticks by checking surrounding tiles for acceptance >= 8/8.

GES_RATING 

This indicates whether a cargo has a rating at the station.

Set when cargo was ever waiting at the station. It is set when cargo supplied by surrounding tiles is moved to the station, or when arriving vehicles unload/transfer cargo without it being a final delivery.

This flag is cleared after 255 * STATION_RATING_TICKS of not having seen a pickup.

GES_EVER_ACCEPTED 

Set when a vehicle ever delivered cargo to the station for final delivery.

This flag is never cleared.

GES_LAST_MONTH 

Set when cargo was delivered for final delivery last month.

This flag is set to the value of GES_CURRENT_MONTH at the start of each month.

GES_CURRENT_MONTH 

Set when cargo was delivered for final delivery this month.

This flag is reset on the beginning of every month.

GES_ACCEPTED_BIGTICK 

Set when cargo was delivered for final delivery during the current STATION_ACCEPTANCE_TICKS interval.

This flag is reset every STATION_ACCEPTANCE_TICKS ticks.

Definition at line 168 of file station_base.h.

Member Function Documentation

◆ GetVia() [1/2]

StationID GoodsEntry::GetVia ( StationID  source) const
inline

Get the best next hop for a cargo packet from station source.

Parameters
sourceSource of the packet.
Returns
The chosen next hop or INVALID_STATION if none was found.

Definition at line 268 of file station_base.h.

References flows.

Referenced by StationCargoReroute::operator()(), and VehicleCargoReroute::operator()().

◆ GetVia() [2/2]

StationID GoodsEntry::GetVia ( StationID  source,
StationID  excluded,
StationID  excluded2 = INVALID_STATION 
) const
inline

Get the best next hop for a cargo packet from station source, optionally excluding one or two stations.

Parameters
sourceSource of the packet.
excludedIf this station would be chosen choose the second best one instead.
excluded2Second station to be excluded, if != INVALID_STATION.
Returns
The chosen next hop or INVALID_STATION if none was found.

Definition at line 282 of file station_base.h.

◆ HasRating()

bool GoodsEntry::HasRating ( ) const
inline

Does this cargo have a rating at this station?

Returns
true if the cargo has a rating, i.e. cargo has been moved to the station.

Definition at line 258 of file station_base.h.

References GES_RATING, and HasBit().

Referenced by StationViewWindow::DrawCargoRatings().

◆ HasVehicleEverTriedLoading()

bool GoodsEntry::HasVehicleEverTriedLoading ( ) const
inline

Reports whether a vehicle has ever tried to load the cargo at this station.

This does not imply that there was cargo available for loading. Refer to GES_RATING for that.

Returns
true if vehicle tried to load.

Definition at line 252 of file station_base.h.

Field Documentation

◆ last_age

uint8_t GoodsEntry::last_age = 255

Age in years (up to 255) of the last vehicle that tried to load this cargo.

This does not imply there was any cargo to load.

Definition at line 243 of file station_base.h.

◆ last_speed

uint8_t GoodsEntry::last_speed = 0

Maximum speed (up to 255) of the last vehicle that tried to load this cargo.

This does not imply there was any cargo to load. The unit used is a special vehicle-specific speed unit for station ratings.

  • Trains: km-ish/h
  • RV: km-ish/h
  • Ships: 0.5 * km-ish/h
  • Aircraft: 8 * mph

Definition at line 237 of file station_base.h.

◆ time_since_pickup

uint8_t GoodsEntry::time_since_pickup = 255

Number of rating-intervals (up to 255) since the last vehicle tried to load this cargo.

The unit used is STATION_RATING_TICKS. This does not imply there was any cargo to load.

Definition at line 224 of file station_base.h.


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