53 template <
typename Tdir, u
int items>
68 SmallSet(
const char *name) : n(0), overflowed(false), name(name) { }
74 this->overflowed =
false;
83 return this->overflowed;
122 for (uint i = 0; i < this->n; i++) {
123 if (this->data[i].tile == tile && this->data[i].dir == dir) {
124 this->data[i] = this->data[--this->n];
140 for (uint i = 0; i < this->n; i++) {
141 if (this->data[i].tile == tile && this->data[i].dir == dir)
return true;
158 DEBUG(misc, 0,
"SignalSegment too complex. Set %s is full (maximum %d)", name, items);
162 this->data[this->n].tile = tile;
163 this->data[this->n].dir = dir;
177 if (this->n == 0)
return false;
180 *tile = this->data[this->n].tile;
181 *dir = this->data[this->n].dir;
219 assert(!_tbdset.
IsIn(t1, d1));
221 if (_tbdset.
Remove(t2, d2))
return false;
244 return _tbdset.
Add(t1, d1);
276 while (_tbdset.
Get(&tile, &enterdir)) {
304 tracks = tracks_masked;
322 if (IsPbsSignal(sig)) {
324 }
else if (!_tbuset.
Add(tile, reversedir)) {
415 while (_tbuset.
Get(&tile, &trackdir)) {
446 _globset.
Add(tile, exitdir);
482 while (_globset.
Get(&tile, &dir)) {
513 _tbdset.
Add(tile, dir);
524 _tbdset.
Add(tile, dir);
596 _globset.
Add(tile, _search_dir_1[track]);
597 _globset.
Add(tile, _search_dir_2[track]);
621 _globset.
Add(tile, side);
643 _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.
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...
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.
SignalType
Type of signal, i.e.
Maps accessors for stations.
"Arrow" to the south-west
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...
Flag for an invalid DiagDirection.
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.
Track
These are used to specify a single track.
A tile with road (or tram tracks)
Track right, direction south.
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
Northeast, upper right on your monitor.
static SigSegState UpdateSignalsInBuffer(Owner owner)
Updates blocks in _globset buffer.
bool IsFull()
Checks for full set.
void Reset()
Reset variables to default values.
SigFlags
Current signal block state flags.
static bool IsLevelCrossing(TileIndex t)
Return whether a tile is a level crossing.
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.
"Arrow" to the north-west
Track upper, direction east.
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.
Track right, direction north.
TrackBits
Bitfield corresponding to Track.
Track x-axis, direction north-east.
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.
Track upper, direction west.
Track lower, direction west.
Segment is a PBS segment.
bool Remove(TileIndex tile, Tdir dir)
Tries to remove first instance of given tile and dir.
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.
"Arrow" to the north-east
Definition of base types and functions in a cross-platform compatible way.
A number of safeguards to prevent using unsafe methods.
static Axis GetRailStationAxis(TileIndex t)
Get the rail direction of a rail station.
Trackdir
Enumeration for tracks and directions.
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
static void ResetSets()
Reset all sets after one set overflowed.
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...
DiagDirection
Enumeration for diagonal directions.
#define lengthof(x)
Return the length of an fixed size array.
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.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset)
Mark a tile given by its index dirty for repaint.
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.
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
Track x-axis, direction south-west.
uint32 TileIndex
The index/ID of a Tile.
Track y-axis, direction north-west.
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...
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.
TrackdirBits
Enumeration of bitmasks for the TrackDirs.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-NULL) Titem.
"Arrow" to the south-east
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 y-axis, direction south-east.
Track left, direction south.
Track left, direction north.
Owner
Enum for all companies/owners.
static SignalState GetSignalStateByTrackdir(TileIndex tile, Trackdir trackdir)
Gets the state of the signal along the given trackdir.
Track lower, direction east.
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
VehicleTypeByte type
Type of vehicle.
static Vehicle * TrainOnTileEnum(Vehicle *v, void *)
Check whether there is a train on rail, not in a depot.
some of buffers was full, do not continue