OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
51 template <
typename Tdir, u
int items>
66 SmallSet(
const char *name) : n(0), overflowed(false), name(name) { }
72 this->overflowed =
false;
81 return this->overflowed;
120 for (uint i = 0; i < this->n; i++) {
121 if (this->data[i].tile == tile && this->data[i].dir == dir) {
122 this->data[i] = this->data[--this->n];
138 for (uint i = 0; i < this->n; i++) {
139 if (this->data[i].tile == tile && this->data[i].dir == dir)
return true;
156 Debug(misc, 0,
"SignalSegment too complex. Set {} is full (maximum {})", name, items);
160 this->data[this->n].tile = tile;
161 this->data[this->n].dir = dir;
175 if (this->n == 0)
return false;
178 *tile = this->data[this->n].tile;
179 *dir = this->data[this->n].dir;
219 return !
_tbdset.Remove(t2, d2);
272 while (
_tbdset.Get(&tile, &enterdir)) {
300 tracks = tracks_masked;
318 if (IsPbsSignal(sig)) {
320 }
else if (!
_tbuset.Add(tile, reversedir)) {
411 while (
_tbuset.Get(&tile, &trackdir)) {
592 _globset.Add(tile, _search_dir_1[track]);
593 _globset.Add(tile, _search_dir_2[track]);
static void UpdateSignalsAroundSegment(SigFlags flags)
Update signals around segment in _tbuset.
uint32 TileIndex
The index/ID of a Tile.
@ TRACK_BIT_NONE
No track.
@ TRACKDIR_BIT_UPPER_W
Track upper, direction west.
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
@ TRACK_BIT_3WAY_SW
"Arrow" to the south-west
static SigSegState UpdateSignalsInBuffer(Owner owner)
Updates blocks in _globset buffer.
TrackdirBits
Enumeration of bitmasks for the TrackDirs.
static bool HasSignalOnTrack(TileIndex tile, Track track)
Checks for the presence of signals (either way) on the given track on the given rail tile.
static const uint SIG_GLOB_UPDATE
how many items need to be in _globset to force update
bool HasVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Checks whether a vehicle is on a specific location.
@ SF_EXIT
exitsignal found
@ TRANSPORT_RAIL
Transport by train.
static void ResetSets()
Reset all sets after one set overflowed.
static Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
@ DIAGDIR_END
Used for iterations.
@ SIGNAL_STATE_GREEN
The signal is green.
static bool IsValidDiagDirection(DiagDirection d)
Checks if an integer value is a valid DiagDirection.
SignalState
These are states in which a signal can be.
static TrackBits GetTrackBits(TileIndex tile)
Gets the track bits of the given tile.
static const TrackBits _enterdir_to_trackbits[DIAGDIR_END]
incidating trackbits with given enterdir
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.
static bool HasSignals(TileIndex t)
Checks if a rail tile has signals.
Owner
Enum for all companies/owners.
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 fro...
@ MP_ROAD
A tile with road (or tram tracks)
static Vehicle * TrainOnTileEnum(Vehicle *v, void *)
Check whether there is a train on rail, not in a depot.
static bool IsRailDepot(TileIndex t)
Is this rail tile a rail depot?
SmallSet(const char *name)
Constructor - just set default values and 'name'.
static const uint SIG_TBU_SIZE
these are the maximums used for updating signal blocks
bool Add(TileIndex tile, Tdir dir)
Adds tile & dir into the set, checks for full set Sets the 'overflowed' flag if the set was full.
static bool IsLevelCrossing(TileIndex t)
Return whether a tile is a level crossing.
static DiagDirection GetRailDepotDirection(TileIndex t)
Returns the direction the depot is facing to.
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
SignalType
Type of signal, i.e.
void SetSignalsOnBothDir(TileIndex tile, Track track, Owner owner)
Update signals at segments that are at both ends of given (existent or non-existent) track.
uint Items()
Reads the number of items.
@ TRACK_BIT_VERT
Left and right track.
static Track TrackBitsToTrack(TrackBits tracks)
Converts TrackBits to Track.
@ SF_EXIT2
two or more exits found
@ TRACKDIR_BIT_X_NE
Track x-axis, direction north-east.
@ TRACKDIR_BIT_LOWER_E
Track lower, direction east.
static bool HasStationRail(TileIndex t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
static const uint SIG_TBD_SIZE
number of intersections - open nodes in current block
static TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
@ SIGNAL_STATE_RED
The signal is red.
static DiagDirection TrackdirToExitdir(Trackdir trackdir)
Maps a trackdir to the (4-way) direction the tile is exited when following that trackdir.
@ INVALID_OWNER
An invalid owner.
bool Failed() const
Did this command fail?
@ SIGTYPE_COMBO
presignal inter-block
static bool HasSignalOnTrackdir(TileIndex tile, Trackdir trackdir)
Checks for the presence of signals along the given trackdir on the given rail tile.
static const uint SIG_GLOB_SIZE
number of open blocks (block can be opened more times until detected)
static const TrackdirBits _enterdir_to_trackdirbits[DIAGDIR_END]
incidating trackdirbits with given enterdir
static void SetSignalStateByTrackdir(TileIndex tile, Trackdir trackdir, SignalState state)
Sets the state of the signal along the given trackdir.
@ TRACKDIR_BIT_LOWER_W
Track lower, direction west.
@ SIGSEG_PBS
Segment is a PBS segment.
static DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
@ TRACKDIR_BIT_Y_SE
Track y-axis, direction south-east.
@ TRACKDIR_BIT_LEFT_S
Track left, direction south.
@ TRACKDIR_BIT_RIGHT_S
Track right, direction south.
@ INVALID_DIAGDIR
Flag for an invalid DiagDirection.
@ TRACKDIR_BIT_LEFT_N
Track left, direction north.
bool Get(TileIndex *tile, Tdir *dir)
Reads the last added element into the set.
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
SigFlags
Current signal block state flags.
static SmallSet< Trackdir, SIG_TBU_SIZE > _tbuset("_tbuset")
set of signals that will be updated
@ INVALID_TRACKDIR
Flag for an invalid trackdir.
DiagDirection
Enumeration for diagonal directions.
SigSegState
State of the signal segment.
bool IsIn(TileIndex tile, Tdir dir)
Tries to find given tile and dir in the set.
static bool IsOnewaySignal(TileIndex t, Track track)
One-way signals can't be passed the 'wrong' way.
static DiagDirection GetTunnelBridgeDirection(TileIndex t)
Get the direction pointing to the other end.
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
@ TRACK_BIT_DEPOT
Bitflag for a depot.
static SigFlags ExploreSegment(Owner owner)
Search signal block.
bool IsEmpty()
Checks for empty set.
bool IsStationTileBlocked(TileIndex tile)
Check whether a rail station tile is NOT traversable.
@ SF_FULL
some of buffers was full, do not continue
@ TRACK_BIT_HORZ
Upper and lower track.
CommandCost EnsureNoTrainOnTrackBits(TileIndex tile, TrackBits track_bits)
Tests if a vehicle interacts with the specified track bits.
@ TRACK_BIT_3WAY_NE
"Arrow" to the north-east
static Train * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
static Axis GetRailStationAxis(TileIndex t)
Get the rail direction of a rail station.
@ TRACKDIR_BIT_Y_NW
Track y-axis, direction north-west.
static Owner _last_owner
last owner whose track was put into _globset
bool IsFull()
Checks for full set.
static SignalState GetSignalStateByTrackdir(TileIndex tile, Trackdir trackdir)
Gets the state of the signal along the given trackdir.
@ SF_GREEN2
two or more green exits found
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
void AddSideToSignalBuffer(TileIndex tile, DiagDirection side, Owner owner)
Add side of tile to signal update buffer.
Set containing 'items' items of 'tile and Tdir' No tree structure is used because it would cause slow...
@ TRACK_BIT_3WAY_SE
"Arrow" to the south-east
@ MP_STATION
A tile of a station.
@ DIAGDIR_BEGIN
Used for iterations.
@ SF_TRAIN
train found in segment
bool Overflowed()
Returns value of 'overflowed'.
void AddTrackToSignalBuffer(TileIndex tile, Track track, Owner owner)
Add track to signal update buffer.
@ SIGSEG_FULL
Occupied by a train.
@ SF_GREEN
green exitsignal found
static SmallSet< DiagDirection, SIG_GLOB_SIZE > _globset("_globset")
set of places to be updated in following runs
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
TrackBits
Bitfield corresponding to Track.
void Reset()
Reset variables to default values.
#define Debug(name, level, format_string,...)
Ouptut a line of debugging information.
#define lengthof(x)
Return the length of an fixed size array.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
static Axis GetCrossingRoadAxis(TileIndex t)
Get the road axis of a level crossing.
@ TRACKDIR_BIT_X_SW
Track x-axis, direction south-west.
static TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
Determines type of the wormhole and returns its other end.
static Trackdir ReverseTrackdir(Trackdir trackdir)
Maps a trackdir to the reverse trackdir.
Trackdir
Enumeration for tracks and directions.
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
@ VEH_TRAIN
Train vehicle type.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
VehicleType type
Type of vehicle.
bool Remove(TileIndex tile, Tdir dir)
Tries to remove first instance of given tile and dir.
static SmallSet< DiagDirection, SIG_TBD_SIZE > _tbdset("_tbdset")
set of open nodes in current signal block
Track
These are used to specify a single track.
@ TRACKDIR_BIT_RIGHT_N
Track right, direction north.
static TransportType GetTunnelBridgeTransportType(TileIndex t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
@ DIAGDIR_NE
Northeast, upper right on your monitor.
@ TRACK_BIT_3WAY_NW
"Arrow" to the north-west
@ TRACKDIR_BIT_UPPER_E
Track upper, direction east.
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 fro...
@ SIGSEG_FREE
Free and has no pre-signal exits or at least one green exit.
uint8 FindFirstBit(uint32 x)
Search the first set bit in a 32 bit variable.
static Track TrackdirToTrack(Trackdir trackdir)
Returns the Track that a given Trackdir represents.