OpenTTD Source  20241108-master-g80f628063a
LinkGraph::BaseEdge Struct Reference

An edge in the link graph. More...

#include <linkgraph.h>

Public Member Functions

 BaseEdge (NodeID dest_node=INVALID_NODE)
 Create an edge.
 
uint32_t TravelTime () const
 Get edge's average travel time. More...
 
TimerGameEconomy::Date LastUpdate () const
 Get the date of the last update to any part of the edge's capacity. More...
 
void Update (uint capacity, uint usage, uint32_t time, EdgeUpdateMode mode)
 Update an edge. More...
 
void Restrict ()
 
void Release ()
 
bool operator< (const BaseEdge &rhs) const
 Comparison operator based on dest_node.
 
bool operator< (NodeID rhs) const
 

Data Fields

uint capacity
 Capacity of the link.
 
uint usage
 Usage of the link.
 
uint64_t travel_time_sum
 Sum of the travel times of the link, in ticks.
 
TimerGameEconomy::Date last_unrestricted_update
 When the unrestricted part of the link was last updated.
 
TimerGameEconomy::Date last_restricted_update
 When the restricted part of the link was last updated.
 
NodeID dest_node
 Destination of the edge.
 

Friends

bool operator< (NodeID lhs, const LinkGraph::BaseEdge &rhs)
 

Detailed Description

An edge in the link graph.

Corresponds to a link between two stations.

Definition at line 42 of file linkgraph.h.

Member Function Documentation

◆ LastUpdate()

TimerGameEconomy::Date LinkGraph::BaseEdge::LastUpdate ( ) const
inline

Get the date of the last update to any part of the edge's capacity.

Returns
Last update.

Definition at line 62 of file linkgraph.h.

◆ TravelTime()

uint32_t LinkGraph::BaseEdge::TravelTime ( ) const
inline

Get edge's average travel time.

Returns
Travel time, in ticks.

Definition at line 56 of file linkgraph.h.

References capacity.

◆ Update()

void LinkGraph::BaseEdge::Update ( uint  capacity,
uint  usage,
uint32_t  travel_time,
EdgeUpdateMode  mode 
)

Update an edge.

If mode contains UM_REFRESH refresh the edge to have at least the given capacity and usage, otherwise add the capacity, usage and travel time. In any case set the respective update timestamp(s), according to the given mode.

Parameters
capacityCapacity to be added/updated.
usageUsage to be added.
travel_timeTravel time to be added, in ticks.
modeUpdate mode to be applied.

Definition at line 217 of file linkgraph.cpp.

References TimerGameEconomy::date, EUM_INCREASE, EUM_REFRESH, EUM_RESTRICTED, and EUM_UNRESTRICTED.


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