#include "stdafx.h"
#include "openttd.h"
#include "debug.h"
#include "tile_cmd.h"
#include "rail_map.h"
#include "road_map.h"
#include "station_map.h"
#include "tunnelbridge_map.h"
#include "vehicle_func.h"
#include "train.h"
#include "newgrf_station.h"
#include "functions.h"
#include "track_type.h"
#include "track_func.h"
#include "signal_func.h"
#include "player_func.h"
Go to the source code of this file.
Data Structures | |
struct | SmallSet< Tdir, items > |
Set containing 'items' items of 'tile and Tdir' No tree structure is used because it would cause slowdowns in most usual cases. More... | |
struct | SmallSet< Tdir, items >::SSdata |
Element of set. More... | |
Enumerations | |
enum | { SIG_TBU_SIZE = 64, SIG_TBD_SIZE = 256, SIG_GLOB_SIZE = 128, SIG_GLOB_UPDATE = 64 } |
these are the maximums used for updating signal blocks More... | |
enum | SigFlags { SF_NONE = 0, SF_TRAIN = 1 << 0, SF_EXIT = 1 << 1, SF_EXIT2 = 1 << 2, SF_GREEN = 1 << 3, SF_GREEN2 = 1 << 4, SF_FULL = 1 << 5 } |
Current signal block state flags. More... | |
Functions | |
assert_compile ((int) SIG_GLOB_UPDATE<=(int) SIG_GLOB_SIZE) | |
static void * | TrainOnTileEnum (Vehicle *v, void *) |
Check whether there is a train on rail, not in a depot. | |
static bool | CheckAddToTodoSet (TileIndex t1, DiagDirection d1, TileIndex t2, DiagDirection d2) |
Perform some operations before adding data into Todo set The new and reverse direction is removed from _globset, because we are sure it doesn't need to be checked again Also, remove reverse direction from _tbdset This is the 'core' part so the graph seaching won't enter any tile twice. | |
static bool | MaybeAddToTodoSet (TileIndex t1, DiagDirection d1, TileIndex t2, DiagDirection d2) |
Perform some operations before adding data into Todo set The new and reverse direction is removed from Global set, because we are sure it doesn't need to be checked again Also, remove reverse direction from Todo set This is the 'core' part so the graph seaching won't enter any tile twice. | |
static SigFlags | ExploreSegment (Owner owner) |
Search signal block. | |
static void | UpdateSignalsAroundSegment (SigFlags flags) |
Update signals around segment in _tbuset. | |
static void | ResetSets () |
Reset all sets after one set overflowed. | |
static bool | UpdateSignalsInBuffer (Owner owner) |
Updates blocks in _globset buffer. | |
void | UpdateSignalsInBuffer () |
Update signals in buffer Called from 'outside'. | |
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. | |
bool | 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. | |
Variables | |
static const TrackBitsByte | _enterdir_to_trackbits [DIAGDIR_END] |
incidating trackbits with given enterdir | |
static const TrackdirBitsShort | _enterdir_to_trackdirbits [DIAGDIR_END] |
incidating trackdirbits with given enterdir | |
static SmallSet< Trackdir, SIG_TBU_SIZE > | _tbuset ("_tbuset") |
set of signals that will be updated | |
static SmallSet< DiagDirection, SIG_TBD_SIZE > | _tbdset ("_tbdset") |
set of open nodes in current signal block | |
static SmallSet< DiagDirection, SIG_GLOB_SIZE > | _globset ("_globset") |
set of places to be updated in following runs | |
static Owner | _last_owner = INVALID_OWNER |
last owner whose track was put into _globset |
Definition in file signal.cpp.
anonymous enum |
these are the maximums used for updating signal blocks
Definition at line 24 of file signal.cpp.
enum SigFlags |
Current signal block state flags.
Definition at line 251 of file signal.cpp.
void AddSideToSignalBuffer | ( | TileIndex | tile, | |
DiagDirection | side, | |||
Owner | owner | |||
) |
Add side of tile to signal update buffer.
tile | tile where we start | |
side | side of tile | |
owner | owner whose signals we will update |
Definition at line 607 of file signal.cpp.
References _globset, INVALID_OWNER, SIG_GLOB_UPDATE, and UpdateSignalsInBuffer().
Referenced by CmdBuildBridge(), CmdBuildTrainDepot(), and CmdBuildTunnel().
Add track to signal update buffer.
tile | tile where we start | |
track | track at which ends we will update signals | |
owner | owner whose signals we will update |
Definition at line 575 of file signal.cpp.
References _globset, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, INVALID_OWNER, SIG_GLOB_UPDATE, and UpdateSignalsInBuffer().
Referenced by CmdBuildRailroadStation(), CmdBuildSingleRail(), CmdBuildSingleSignal(), CmdRemoveFromRailroadStation(), CmdRemoveSingleRail(), CmdRemoveSingleSignal(), RemoveTrainWaypoint(), and SetSignalsOnBothDir().
static bool CheckAddToTodoSet | ( | TileIndex | t1, | |
DiagDirection | d1, | |||
TileIndex | t2, | |||
DiagDirection | d2 | |||
) | [inline, static] |
Perform some operations before adding data into Todo set The new and reverse direction is removed from _globset, because we are sure it doesn't need to be checked again Also, remove reverse direction from _tbdset This is the 'core' part so the graph seaching won't enter any tile twice.
t1 | tile we are entering | |
d1 | direction (tile side) we are entering | |
t2 | tile we are leaving | |
d2 | direction (tile side) we are leaving |
Definition at line 216 of file signal.cpp.
References _globset, and _tbdset.
Referenced by MaybeAddToTodoSet().
Search signal block.
owner | owner whose signals we are updating |
Definition at line 270 of file signal.cpp.
References _tbdset, _tbuset, DIAGDIR_BEGIN, DIAGDIR_END, DiagDirToAxis(), FindFirstBit(), GetOtherTunnelBridgeEnd(), GetRailDepotDirection(), GetRailTileType(), GetSignalStateByTrackdir(), GetTileOwner(), GetTileType(), GetTrackBits(), GetTunnelBridgeDirection(), GetTunnelBridgeTransportType(), GetWaypointAxis(), HasSignalOnTrack(), HasSignalOnTrackdir(), HasSignals(), HasVehicleOnPos(), INVALID_DIAGDIR, IsRailDepot(), MaybeAddToTodoSet(), MP_RAILWAY, MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, RAIL_TILE_WAYPOINT, ReverseDiagDir(), ReverseTrackdir(), SF_EXIT, SF_EXIT2, SF_FULL, SF_GREEN, SF_GREEN2, SF_TRAIN, SIGNAL_STATE_GREEN, SIGTYPE_EXIT, TileOffsByDiagDir(), TRACK_BIT_HORZ, TRACK_BIT_NONE, TRACK_BIT_VERT, TrackBitsToTrack(), and TrainOnTileEnum().
Referenced by UpdateSignalsInBuffer().
static bool MaybeAddToTodoSet | ( | TileIndex | t1, | |
DiagDirection | d1, | |||
TileIndex | t2, | |||
DiagDirection | d2 | |||
) | [inline, static] |
Perform some operations before adding data into Todo set The new and reverse direction is removed from Global set, because we are sure it doesn't need to be checked again Also, remove reverse direction from Todo set This is the 'core' part so the graph seaching won't enter any tile twice.
t1 | tile we are entering | |
d1 | direction (tile side) we are entering | |
t2 | tile we are leaving | |
d2 | direction (tile side) we are leaving |
Definition at line 242 of file signal.cpp.
References _tbdset, and CheckAddToTodoSet().
Referenced by ExploreSegment().
Update signals at segments that are at both ends of given (existent or non-existent) track.
tile | tile where we start | |
track | track at which ends we will update signals | |
owner | owner whose signals we will update |
Definition at line 651 of file signal.cpp.
References _globset, AddTrackToSignalBuffer(), and UpdateSignalsInBuffer().
Referenced by DeleteLastWagon().
static void UpdateSignalsAroundSegment | ( | SigFlags | flags | ) | [static] |
Update signals around segment in _tbuset.
flags | info about segment |
Definition at line 410 of file signal.cpp.
References _globset, _tbuset, GetSignalStateByTrackdir(), HasSignalOnTrackdir(), MarkTileDirtyByTile(), ReverseTrackdir(), SetSignalStateByTrackdir(), SF_EXIT, SF_EXIT2, SF_GREEN, SF_GREEN2, SF_TRAIN, SIGNAL_STATE_GREEN, SIGNAL_STATE_RED, SIGTYPE_COMBO, SIGTYPE_ENTRY, SIGTYPE_EXIT, TrackdirToExitdir(), and TrackdirToTrack().
Referenced by UpdateSignalsInBuffer().
static bool UpdateSignalsInBuffer | ( | Owner | owner | ) | [static] |
Updates blocks in _globset buffer.
owner | player whose signals we are updating |
Definition at line 472 of file signal.cpp.
References _globset, _tbdset, _tbuset, ExploreSegment(), GetOtherTunnelBridgeEnd(), GetRailDepotDirection(), GetTileType(), GetTunnelBridgeDirection(), GetTunnelBridgeTransportType(), INVALID_DIAGDIR, IsRailDepot(), MP_RAILWAY, MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, ResetSets(), ReverseDiagDir(), SF_EXIT, SF_FULL, SF_GREEN, SF_TRAIN, TileOffsByDiagDir(), TRACK_BIT_NONE, TrackStatusToTrackBits(), and UpdateSignalsAroundSegment().
Referenced by AddSideToSignalBuffer(), AddTrackToSignalBuffer(), DoCommandP(), DoFloodTile(), SetSignalsOnBothDir(), UpdateSignalsInBuffer(), and UpdateSignalsOnSegment().
bool 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.
tile | tile where we start | |
side | side of tile | |
owner | owner whose signals we will update |
Definition at line 633 of file signal.cpp.
References _globset, and UpdateSignalsInBuffer().
Referenced by DeleteLastWagon().
const TrackBitsByte _enterdir_to_trackbits[DIAGDIR_END] [static] |
Initial value:
{ {TRACK_BIT_3WAY_NE}, {TRACK_BIT_3WAY_SE}, {TRACK_BIT_3WAY_SW}, {TRACK_BIT_3WAY_NW} }
Definition at line 35 of file signal.cpp.
const TrackdirBitsShort _enterdir_to_trackdirbits[DIAGDIR_END] [static] |
Initial value:
{ {TRACKDIR_BIT_X_SW | TRACKDIR_BIT_UPPER_W | TRACKDIR_BIT_RIGHT_S}, {TRACKDIR_BIT_Y_NW | TRACKDIR_BIT_LOWER_W | TRACKDIR_BIT_RIGHT_N}, {TRACKDIR_BIT_X_NE | TRACKDIR_BIT_LOWER_E | TRACKDIR_BIT_LEFT_N}, {TRACKDIR_BIT_Y_SE | TRACKDIR_BIT_UPPER_E | TRACKDIR_BIT_LEFT_S} }
Definition at line 43 of file signal.cpp.