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 %s is full (maximum %d)", 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;
217 assert(!_tbdset.
IsIn(t1, d1));
219 if (_tbdset.
Remove(t2, d2))
return false;
242 return _tbdset.
Add(t1, d1);
274 while (_tbdset.
Get(&tile, &enterdir)) {
302 tracks = tracks_masked;
320 if (IsPbsSignal(sig)) {
322 }
else if (!_tbuset.
Add(tile, reversedir)) {
413 while (_tbuset.
Get(&tile, &trackdir)) {
444 _globset.
Add(tile, exitdir);
480 while (_globset.
Get(&tile, &dir)) {
511 _tbdset.
Add(tile, dir);
522 _tbdset.
Add(tile, dir);
594 _globset.
Add(tile, _search_dir_1[track]);
595 _globset.
Add(tile, _search_dir_2[track]);
619 _globset.
Add(tile, side);
641 _globset.
Add(tile, side);
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...
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
Owner
Enum for all companies/owners.
bool HasVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Checks whether a vehicle is on a specific location.
CommandCost EnsureNoTrainOnTrackBits(TileIndex tile, TrackBits track_bits)
Tests if a vehicle interacts with the specified track bits.
Free and has no pre-signal exits or at least one green exit.
static bool HasSignalOnTrackdir(TileIndex tile, Trackdir trackdir)
Checks for the presence of signals along the given trackdir on the given rail tile.
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
void AddTrackToSignalBuffer(TileIndex tile, Track track, Owner owner)
Add track to signal update buffer.
Definition of stuff that is very close to a company, like the company struct itself.
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...
TrackdirBits
Enumeration of bitmasks for the TrackDirs.
static TransportType GetTunnelBridgeTransportType(TileIndex t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
bool IsEmpty()
Checks for empty set.
Track upper, direction west.
SignalType
Type of signal, i.e.
"Arrow" to the south-west
Maps accessors for stations.
SmallSet(const char *name)
Constructor - just set default values and 'name'.
static const uint SIG_GLOB_SIZE
number of open blocks (block can be opened more times until detected)
static Owner _last_owner
last owner whose track was put into _globset
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 Track TrackdirToTrack(Trackdir trackdir)
Returns the Track that a given Trackdir represents.
Base for the train class.
static bool HasSignalOnTrack(TileIndex tile, Track track)
Checks for the presence of signals (either way) on the given track on the given rail tile...
Functions related to debugging.
Trackdir
Enumeration for tracks and directions.
A tile with road (or tram tracks)
SignalState
These are states in which a signal can be.
static bool IsOnewaySignal(TileIndex t, Track track)
One-way signals can't be passed the 'wrong' way.
Functions related to vehicles.
void AddSideToSignalBuffer(TileIndex tile, DiagDirection side, Owner owner)
Add side of tile to signal update buffer.
static SmallSet< DiagDirection, SIG_TBD_SIZE > _tbdset("_tbdset")
set of open nodes in current signal block
static SigSegState UpdateSignalsInBuffer(Owner owner)
Updates blocks in _globset buffer.
bool IsFull()
Checks for full set.
void Reset()
Reset variables to default values.
Flag for an invalid DiagDirection.
SigFlags
Current signal block state flags.
static bool IsLevelCrossing(TileIndex t)
Return whether a tile is a level crossing.
"Arrow" to the north-east
static DiagDirection TrackdirToExitdir(Trackdir trackdir)
Maps a trackdir to the (4-way) direction the tile is exited when following that trackdir.
static void SetSignalStateByTrackdir(TileIndex tile, Trackdir trackdir, SignalState state)
Sets the state of the signal along the given trackdir.
static Train * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
static SmallSet< DiagDirection, SIG_GLOB_SIZE > _globset("_globset")
set of places to be updated in following runs
static const TrackdirBits _enterdir_to_trackdirbits[DIAGDIR_END]
incidating trackdirbits with given enterdir
uint Items()
Reads the number of items.
Functions related to (drawing on) viewports.
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 Track TrackBitsToTrack(TrackBits tracks)
Converts TrackBits to Track.
two or more green exits found
static SigFlags ExploreSegment(Owner owner)
Search signal block.
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Segment is a PBS segment.
bool Remove(TileIndex tile, Tdir dir)
Tries to remove first instance of given tile and dir.
Track right, direction north.
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
static DiagDirection GetRailDepotDirection(TileIndex t)
Returns the direction the depot is facing to.
static DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
Track left, direction south.
Definition of base types and functions in a cross-platform compatible way.
Track y-axis, direction south-east.
A number of safeguards to prevent using unsafe methods.
static Axis GetRailStationAxis(TileIndex t)
Get the rail direction of a rail station.
static Axis GetCrossingRoadAxis(TileIndex t)
Get the road axis of a level crossing.
static bool IsValidDiagDirection(DiagDirection d)
Checks if an integer value is a valid DiagDirection.
static const uint SIG_TBD_SIZE
number of intersections - open nodes in current block
TrackBits
Bitfield corresponding to Track.
static void ResetSets()
Reset all sets after one set overflowed.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
static const uint SIG_TBU_SIZE
these are the maximums used for updating signal blocks
Set containing 'items' items of 'tile and Tdir' No tree structure is used because it would cause slow...
#define lengthof(x)
Return the length of an fixed size array.
Track left, direction north.
static SmallSet< Trackdir, SIG_TBU_SIZE > _tbuset("_tbuset")
set of signals that will be updated
static DiagDirection GetTunnelBridgeDirection(TileIndex t)
Get the direction pointing to the other end.
bool Failed() const
Did this command fail?
static Trackdir ReverseTrackdir(Trackdir trackdir)
Maps a trackdir to the reverse trackdir.
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
static bool HasSignals(TileIndex t)
Checks if a rail tile has signals.
#define DEBUG(name, level,...)
Output a line of debugging information.
uint8 FindFirstBit(uint32 x)
Search the first set bit in a 32 bit variable.
static TrackBits GetTrackBits(TileIndex tile)
Gets the track bits of the given tile.
static Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
static TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
Determines type of the wormhole and returns its other end.
Track lower, direction east.
static bool IsRailDepot(TileIndex t)
Is this rail tile a rail depot?
bool IsStationTileBlocked(TileIndex tile)
Check whether a rail station tile is NOT traversable.
Tunnel entry/exit and bridge heads.
static const TrackBits _enterdir_to_trackbits[DIAGDIR_END]
incidating trackbits with given enterdir
uint32 TileIndex
The index/ID of a Tile.
Track
These are used to specify a single track.
bool Get(TileIndex *tile, Tdir *dir)
Reads the last added element into the set.
bool Overflowed()
Returns value of 'overflowed'.
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...
VehicleType type
Type of vehicle.
"Arrow" to the south-east
bool IsIn(TileIndex tile, Tdir dir)
Tries to find given tile and dir in the set.
static TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
SigSegState
State of the signal segment.
Track x-axis, direction south-west.
Track y-axis, direction north-west.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Functions that have tunnels and bridges in common.
void SetSignalsOnBothDir(TileIndex tile, Track track, Owner owner)
Update signals at segments that are at both ends of given (existent or non-existent) track...
Track lower, direction west.
DiagDirection
Enumeration for diagonal directions.
Track upper, direction east.
Northeast, upper right on your monitor.
Track x-axis, direction north-east.
static SignalState GetSignalStateByTrackdir(TileIndex tile, Trackdir trackdir)
Gets the state of the signal along the given trackdir.
static void UpdateSignalsAroundSegment(SigFlags flags)
Update signals around segment in _tbuset.
static const uint SIG_GLOB_UPDATE
how many items need to be in _globset to force update
"Arrow" to the north-west
static Vehicle * TrainOnTileEnum(Vehicle *v, void *)
Check whether there is a train on rail, not in a depot.
Track right, direction south.
some of buffers was full, do not continue