Enumerations | Functions

signal_func.h File Reference

Functions related to signals. More...

#include "signal_type.h"
#include "track_type.h"
#include "tile_type.h"
#include "direction_type.h"
#include "company_type.h"
#include "debug.h"

Go to the source code of this file.

Enumerations

enum  SigSegState { SIGSEG_FREE, SIGSEG_FULL, SIGSEG_PBS }
 

State of the signal segment.

More...

Functions

static byte SignalAlongTrackdir (Trackdir trackdir)
 Maps a trackdir to the bit that stores its status in the map arrays, in the direction along with the trackdir.
static byte SignalAgainstTrackdir (Trackdir trackdir)
 Maps a trackdir to the bit that stores its status in the map arrays, in the direction against the trackdir.
static byte SignalOnTrack (Track track)
 Maps a Track to the bits that store the status of the two signals that can be present on the given track.
static bool IsEntrySignal (SignalType type)
 Is a given signal type a presignal entry signal?
static bool IsExitSignal (SignalType type)
 Is a given signal type a presignal exit signal?
static bool IsComboSignal (SignalType type)
 Is a given signal type a presignal combo signal?
static bool IsPbsSignal (SignalType type)
 Is a given signal type a PBS signal?
static bool IsProgrammableSignal (SignalType type)
 Is this a programmable signal?
static bool IsSpeedSignal (SignalType type)
 Is this a speed signal?
static bool IsSignalSpritePBS (SignalType type)
 Does a given signal have a PBS sprite?
static SignalType NextSignalType (SignalType cur, uint which_signals)
void CheckRemoveSignalsFromTile (TileIndex tile)
 Checks for any data attached to any signals, and removes it.
void CheckRemoveSignal (TileIndex tile, Track track)
 Checks for, and removes, any extra signal data.
void AddSignalDependency (SignalReference on, SignalReference dep)
 Adds a signal dependency The signal identified by dep will be marked as dependend upon the signal identified by on.
void RemoveSignalDependency (SignalReference on, SignalReference dep)
 Removes a signal dependency.
void FreeSignalDependencies ()
 Frees signal dependencies (for newgame/load).
SigSegState UpdateSignalsOnSegment (TileIndex tile, DiagDirection side, Owner owner)
 Update signals, starting at one side of a tile Will check tile next to this at opposite side too.
void SetSignalsOnBothDir (TileIndex tile, Track track, Owner owner)
 Update signals at segments that are at both ends of given (existent or non-existent) track.
void AddTrackToSignalBuffer (TileIndex tile, Track track, Owner owner)
 Add track to signal update buffer.
void AddSideToSignalBuffer (TileIndex tile, DiagDirection side, Owner owner)
 Add side of tile to signal update buffer.
void UpdateSignalsInBuffer ()
 Update signals in buffer Called from 'outside'.

Detailed Description

Functions related to signals.

Definition in file signal_func.h.


Enumeration Type Documentation

State of the signal segment.

Enumerator:
SIGSEG_FREE 

Free and has no pre-signal exits or at least one green exit.

SIGSEG_FULL 

Occupied by a train.

SIGSEG_PBS 

Segment is a PBS segment.

Definition at line 115 of file signal_func.h.


Function Documentation

void AddSideToSignalBuffer ( TileIndex  tile,
DiagDirection  side,
Owner  owner 
)

Add side of tile to signal update buffer.

Parameters:
tile tile where we start
side side of tile
owner owner whose signals we will update

Definition at line 697 of file signal.cpp.

References _globset, _last_owner, IsOneSignalBlock(), SIG_GLOB_UPDATE, and UpdateSignalsInBuffer().

Referenced by CmdBuildBridge(), CmdBuildSingleSignal(), CmdBuildTrainDepot(), CmdBuildTunnel(), DeleteVisibleTrain(), DoClearBridge(), and DoClearTunnel().

void AddTrackToSignalBuffer ( TileIndex  tile,
Track  track,
Owner  owner 
)
void CheckRemoveSignal ( TileIndex  tile,
Track  track 
)

Checks for, and removes, any extra signal data.

Call when removing a piece of track which is potentially signalled, in order to free any extra data that may be associated with said track.

Definition at line 811 of file signal.cpp.

References SmallVector< T, S >::Begin(), SmallVector< T, S >::End(), GetTileOwner(), HasSignalOnTrack(), IsProgrammableSignal(), and IsSpeedSignal().

Referenced by CheckRemoveSignalsFromTile(), CmdRemoveSingleRail(), and CmdRemoveSingleSignal().

void CheckRemoveSignalsFromTile ( TileIndex  tile  ) 

Checks for any data attached to any signals, and removes it.

Call when performing an action which may potentially remove signals from a tile, in order to avoid leaking data.

Definition at line 792 of file signal.cpp.

References CheckRemoveSignal(), GetTrackBits(), HasSignalOnTrack(), HasSignals(), INVALID_TRACK, and RemoveFirstTrack().

void RemoveSignalDependency ( SignalReference  on,
SignalReference  dep 
)

Removes a signal dependency.

Arguments same as AddSignalDependency

Definition at line 757 of file signal.cpp.

References SmallVector< T, S >::End(), SmallVector< T, S >::Erase(), SmallVector< T, S >::Find(), and SmallVector< T, S >::Length().

void SetSignalsOnBothDir ( TileIndex  tile,
Track  track,
Owner  owner 
)

Update signals at segments that are at both ends of given (existent or non-existent) track.

See also:
UpdateSignalsInBuffer()
Parameters:
tile tile where we start
track track at which ends we will update signals
owner owner whose signals we will update

Definition at line 742 of file signal.cpp.

References _globset, AddTrackToSignalBuffer(), and UpdateSignalsInBuffer().

Referenced by DeleteLastWagon().

SigSegState UpdateSignalsOnSegment ( TileIndex  tile,
DiagDirection  side,
Owner  owner 
)

Update signals, starting at one side of a tile Will check tile next to this at opposite side too.

See also:
UpdateSignalsInBuffer()
Parameters:
tile tile where we start
side side of tile
owner owner whose signals we will update
Returns:
the state of the signal segment

Definition at line 724 of file signal.cpp.

References _globset, and UpdateSignalsInBuffer().

Referenced by CheckTrainStayInWormHole(), DeleteLastWagon(), and VehicleEnterDepot().