OpenTTD Source: CYapfReserveTrack< Types > Class Template Reference

OpenTTD Source 15.0-RC2

Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
CYapfReserveTrack< Types > Class Template Reference
Inheritance diagram for CYapfReserveTrack< Types >:

## Public Types
typedef Types::Tpf | Tpf
| the pathfinder class (derived from THIS class)
typedef Types::TrackFollower | TrackFollower
typedef Types::NodeList::Item | Node
| this will be our node type

## Public Member Functions
void | SetReservationTarget (Node *node, TileIndex tile, Trackdir td)
| Set the target to where the reservation should be extended.
void | FindSafePositionOnNode (Node *node)
| Check the node for a possible reservation target.
bool | TryReservePath (PBSTileInfo *target, TileIndex origin)
| Try to reserve the path till the reservation target.

## Protected Member Functions
Tpf & | Yapf ()
| to access inherited pathfinder

## Private Member Functions
bool | FindSafePositionProc (TileIndex tile, Trackdir td)
bool | ReserveRailStationPlatform (TileIndex &tile, DiagDirection dir)
| Reserve a railway platform.
bool | ReserveSingleTrack (TileIndex tile, Trackdir td)
| Try to reserve a single track/platform.
bool | UnreserveSingleTrack (TileIndex tile, Trackdir td)
| Unreserve a single track/platform.

## Private Attributes
TileIndex | res_dest_tile
| The reservation target tile.
Trackdir | res_dest_td
| The reservation target trackdir.
Node * | res_dest_node
| The reservation target node.
TileIndex | res_fail_tile
| The tile where the reservation failed.
Trackdir | res_fail_td
| The trackdir where the reservation failed.
TileIndex | origin_tile
| Tile our reservation will originate from.
std::vector< std::pair< TileIndex, Trackdir > > | signals_set_to_red
| List of signals turned red during a path reservation.

## Detailed Description

template<class Types>
class CYapfReserveTrack< Types >

Definition at line 36 of file yapf_rail.cpp.

## Member Typedef Documentation

## ◆ Node

template<class Types >

typedef Types::NodeList::Item CYapfReserveTrack< Types >::Node

this will be our node type

Definition at line 40 of file yapf_rail.cpp.

## ◆ Tpf

template<class Types >

typedef Types::Tpf CYapfReserveTrack< Types >::Tpf

the pathfinder class (derived from THIS class)

Definition at line 38 of file yapf_rail.cpp.

## ◆ TrackFollower

template<class Types >

typedef Types::TrackFollower CYapfReserveTrack< Types >::TrackFollower

Definition at line 39 of file yapf_rail.cpp.

## Member Function Documentation

## ◆ FindSafePositionOnNode()

template<class Types >

void CYapfReserveTrack< Types >::FindSafePositionOnNode | ( | Node * | node | ) |
| inline

Check the node for a possible reservation target.

Definition at line 150 of file yapf_rail.cpp.

References CYapfReserveTrack< Types >::Yapf().

## ◆ FindSafePositionProc()

template<class Types >

bool CYapfReserveTrack< Types >::FindSafePositionProc | ( | TileIndex | tile,
|  | Trackdir | td
| ) |  |
| inlineprivate

Definition at line 59 of file yapf_rail.cpp.

## ◆ ReserveRailStationPlatform()

template<class Types >

bool CYapfReserveTrack< Types >::ReserveRailStationPlatform | ( | TileIndex & | tile,
|  | DiagDirection | dir
| ) |  |
| inlineprivate

Reserve a railway platform.

Tile contains the failed tile on abort.

Definition at line 70 of file yapf_rail.cpp.

References BaseStation::GetByTile(), HasStationReservation(), IsCompatibleTrainStationTile(), MarkTileDirtyByTile(), PathReservation, SetRailStationReservation(), TileAdd(), TileOffsByDiagDir(), and TriggerStationRandomisation().

Referenced by CYapfReserveTrack< Types >::ReserveSingleTrack().

## ◆ ReserveSingleTrack()

template<class Types >

bool CYapfReserveTrack< Types >::ReserveSingleTrack | ( | TileIndex | tile,
|  | Trackdir | td
| ) |  |
| inlineprivate

Try to reserve a single track/platform.

Definition at line 90 of file yapf_rail.cpp.

References BaseStation::GetByTile(), GetSignalStateByTrackdir(), HasPbsSignalOnTrackdir(), IsRailStationTile(), IsRailWaypointTile(), MarkTileDirtyByTile(), PathReservation, CYapfReserveTrack< Types >::res_dest_td, CYapfReserveTrack< Types >::ReserveRailStationPlatform(), ReverseTrackdir(), SetSignalStateByTrackdir(), SIGNAL_STATE_GREEN, SIGNAL_STATE_RED, TrackdirToExitdir(), TrackdirToTrack(), TriggerStationRandomisation(), and TryReserveRailTrack().

## ◆ SetReservationTarget()

template<class Types >

void CYapfReserveTrack< Types >::SetReservationTarget | ( | Node * | node,
|  | TileIndex | tile,
|  | Trackdir | td
| ) |  |
| inline

Set the target to where the reservation should be extended.

Definition at line 142 of file yapf_rail.cpp.

## ◆ TryReservePath()

template<class Types >

bool CYapfReserveTrack< Types >::TryReservePath | ( | PBSTileInfo * | target,
|  | TileIndex | origin
| ) |  |
| inline

Try to reserve the path till the reservation target.

Definition at line 163 of file yapf_rail.cpp.

References INVALID_TILE, INVALID_TRACK, IsWaitingPositionFree(), PBSTileInfo::okay, CYapfReserveTrack< Types >::res_dest_node, CYapfReserveTrack< Types >::res_dest_td, CYapfReserveTrack< Types >::res_dest_tile, CYapfReserveTrack< Types >::res_fail_tile, SetSignalStateByTrackdir(), SIGNAL_STATE_GREEN, CYapfReserveTrack< Types >::signals_set_to_red, PBSTileInfo::tile, PBSTileInfo::trackdir, CYapfReserveTrack< Types >::Yapf(), and YapfNotifyTrackLayoutChange().

## ◆ UnreserveSingleTrack()

template<class Types >

bool CYapfReserveTrack< Types >::UnreserveSingleTrack | ( | TileIndex | tile,
|  | Trackdir | td
| ) |  |
| inlineprivate

Unreserve a single track/platform.

Stops when the previous failure is reached.

Definition at line 125 of file yapf_rail.cpp.

References IsCompatibleTrainStationTile(), IsRailStationTile(), CYapfReserveTrack< Types >::res_fail_td, ReverseTrackdir(), SetRailStationReservation(), TileAdd(), TileOffsByDiagDir(), TrackdirToExitdir(), TrackdirToTrack(), and UnreserveRailTrack().

## ◆ Yapf()

template<class Types >

Tpf & CYapfReserveTrack< Types >::Yapf | ( |  | ) |
| inlineprotected

to access inherited pathfinder

Definition at line 44 of file yapf_rail.cpp.

Referenced by CYapfReserveTrack< Types >::FindSafePositionOnNode(), and CYapfReserveTrack< Types >::TryReservePath().

## Field Documentation

## ◆ origin_tile

template<class Types >

TileIndex CYapfReserveTrack< Types >::origin_tile
| private

Tile our reservation will originate from.

Definition at line 55 of file yapf_rail.cpp.

## ◆ res_dest_node

template<class Types >

Node* CYapfReserveTrack< Types >::res_dest_node
| private

The reservation target node.

Definition at line 52 of file yapf_rail.cpp.

Referenced by CYapfReserveTrack< Types >::TryReservePath().

## ◆ res_dest_td

template<class Types >

Trackdir CYapfReserveTrack< Types >::res_dest_td
| private

The reservation target trackdir.

Definition at line 51 of file yapf_rail.cpp.

Referenced by CYapfReserveTrack< Types >::ReserveSingleTrack(), and CYapfReserveTrack< Types >::TryReservePath().

## ◆ res_dest_tile

template<class Types >

TileIndex CYapfReserveTrack< Types >::res_dest_tile
| private

The reservation target tile.

Definition at line 50 of file yapf_rail.cpp.

Referenced by CYapfReserveTrack< Types >::TryReservePath().

## ◆ res_fail_td

template<class Types >

Trackdir CYapfReserveTrack< Types >::res_fail_td
| private

The trackdir where the reservation failed.

Definition at line 54 of file yapf_rail.cpp.

Referenced by CYapfReserveTrack< Types >::UnreserveSingleTrack().

## ◆ res_fail_tile

template<class Types >

TileIndex CYapfReserveTrack< Types >::res_fail_tile
| private

The tile where the reservation failed.

Definition at line 53 of file yapf_rail.cpp.

Referenced by CYapfReserveTrack< Types >::TryReservePath().

## ◆ signals_set_to_red

template<class Types >

std::vector<std::pair<TileIndex, Trackdir> > CYapfReserveTrack< Types >::signals_set_to_red
| private

List of signals turned red during a path reservation.

Definition at line 57 of file yapf_rail.cpp.

Referenced by CYapfReserveTrack< Types >::TryReservePath().

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

- src/pathfinder/yapf/yapf_rail.cpp