197 uint8_t track_b =
GB(t.
m2(), 8, 3);
304 SB(t.
m2(), pos, 3, s);
308 inline bool IsPresignalEntry(
Tile t,
Track track)
313 inline bool IsPresignalExit(
Tile t,
Track track)
324 inline void CycleSignalSide(
Tile t,
Track track)
329 sig =
GB(t.
m3(), pos, 2);
330 if (--sig == 0) sig = IsPbsSignal(GetSignalType(t, track)) ? 2 : 3;
331 SB(t.
m3(), pos, 2, sig);
343 SB(t.
m2(), pos, 1, v);
354 SB(tile.
m4(), 4, 4, state);
364 return GB(tile.
m4(), 4, 4);
385 SB(tile.
m3(), 4, 4, signals);
395 return GB(tile.
m3(), 4, 4);
505 SB(t.
m4(), 0, 4, rgt);
513 inline bool IsSnowRailGround(
Tile t)
541 SB(tile.
m5(), 0, 2, dir);
557 tile.
m2() = depot_id;
561 SB(tile.
m6(), 2, 4, 0);
563 tile.
m8() = rail_type;
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr T AssignBit(T &x, const uint8_t y, bool value)
Assigns a bit in a variable.
constexpr T SB(T &x, const uint8_t s, const uint8_t n, const U d)
Set n bits in x starting at bit s to d.
constexpr static debug_inline uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
Wrapper class to abstract away the way the tiles are stored.
debug_inline uint16_t & m8()
General purpose.
debug_inline uint8_t & m7()
Primarily used for newgrf support.
debug_inline uint8_t & m5()
General purpose.
debug_inline uint8_t & m4()
General purpose.
debug_inline uint16_t & m2()
Primarily used for indices to towns, industries and stations.
debug_inline uint8_t & m6()
General purpose.
debug_inline uint8_t & m3()
General purpose.
Owner
Enum for all companies/owners.
Header files for depots (not hangars)
uint16_t DepotID
Type for the unique identifier of depots.
DiagDirection
Enumeration for diagonal directions.
bool HasOnewaySignalBlockingTrackdir(Tile tile, Trackdir td)
Is a one-way signal blocking the trackdir? A one-way signal on the trackdir against will block,...
uint GetSignalStates(Tile tile)
Set the states of the signals (Along/AgainstTrackDir)
void MakeRailDepot(Tile tile, Owner owner, DepotID depot_id, DiagDirection dir, RailType rail_type)
Make a rail depot.
RailType GetRailType(Tile t)
Gets the rail type of the given tile.
bool HasSignalOnTrackdir(Tile tile, Trackdir trackdir)
Checks for the presence of signals along the given trackdir on the given rail tile.
static debug_inline RailTileType GetRailTileType(Tile t)
Returns the RailTileType (normal with or without signals, waypoint or depot).
TrackBits GetTrackBits(Tile tile)
Gets the track bits of the given tile.
static debug_inline bool IsRailDepotTile(Tile t)
Is this tile rail tile and a rail depot?
RailGroundType
The ground 'under' the rail.
@ RAIL_GROUND_FENCE_HORIZ1
Grass with a fence at the southern side.
@ RAIL_GROUND_FENCE_VERT1
Grass with a fence at the eastern side.
@ RAIL_GROUND_ICE_DESERT
Icy or sandy.
@ RAIL_GROUND_FENCE_NE
Grass with a fence at the NE edge.
@ RAIL_GROUND_FENCE_NESW
Grass with a fence at the NE and SW edges.
@ RAIL_GROUND_FENCE_HORIZ2
Grass with a fence at the northern side.
@ RAIL_GROUND_FENCE_SW
Grass with a fence at the SW edge.
@ RAIL_GROUND_FENCE_NW
Grass with a fence at the NW edge.
@ RAIL_GROUND_WATER
Grass with a fence and shore or water on the free halftile.
@ RAIL_GROUND_BARREN
Nothing (dirt)
@ RAIL_GROUND_FENCE_VERT2
Grass with a fence at the western side.
@ RAIL_GROUND_GRASS
Grassy.
@ RAIL_GROUND_HALF_SNOW
Snow only on higher part of slope (steep or one corner raised)
@ RAIL_GROUND_FENCE_SENW
Grass with a fence at the NW and SE edges.
@ RAIL_GROUND_FENCE_SE
Grass with a fence at the SE edge.
Track GetRailDepotTrack(Tile t)
Returns the track of a depot, ignoring direction.
void SetTrackReservation(Tile t, TrackBits b)
Sets the reserved track bits of the tile.
bool IsSignalPresent(Tile t, uint8_t signalbit)
Checks whether the given signals is present.
DiagDirection GetRailDepotDirection(Tile t)
Returns the direction the depot is facing to.
void SetTrackBits(Tile t, TrackBits b)
Sets the track bits of the given tile.
void SetSignalStateByTrackdir(Tile tile, Trackdir trackdir, SignalState state)
Sets the state of the signal along the given trackdir.
uint GetPresentSignals(Tile tile)
Get whether the given signals are present (Along/AgainstTrackDir)
bool HasSignalOnTrack(Tile tile, Track track)
Checks for the presence of signals (either way) on the given track on the given rail tile.
bool HasPbsSignalOnTrackdir(Tile tile, Trackdir td)
Is a pbs signal present along the trackdir?
bool IsOnewaySignal(Tile t, Track track)
One-way signals can't be passed the 'wrong' way.
void SetPresentSignals(Tile tile, uint signals)
Set whether the given signals are present (Along/AgainstTrackDir)
static debug_inline bool IsRailDepot(Tile t)
Is this rail tile a rail depot?
void SetRailDepotExitDirection(Tile tile, DiagDirection dir)
Sets the exit direction of a rail depot.
void UnreserveTrack(Tile tile, Track t)
Lift the reservation of a specific track on a tile.
RailType GetTileRailType(Tile tile)
Return the rail type of tile, or INVALID_RAILTYPE if this is no rail tile.
void SetDepotReservation(Tile t, bool b)
Set the reservation state of the depot.
TrackBits GetDepotReservationTrackBits(Tile t)
Get the reserved track bits for a depot.
static debug_inline bool IsPlainRail(Tile t)
Returns whether this is plain rails, with or without signals.
TrackBits GetRailReservationTrackBits(Tile t)
Returns the reserved track bits of the tile.
bool HasDepotReservation(Tile t)
Get the reservation state of the depot.
void SetHasSignals(Tile tile, bool signals)
Add/remove the 'has signal' bit from the RailTileType.
bool TryReserveTrack(Tile tile, Track t)
Try to reserve a specific track on a tile.
RailTileType
Different types of Rail-related tiles.
@ RAIL_TILE_DEPOT
Depot (one entrance)
@ RAIL_TILE_NORMAL
Normal rail tile without signals.
@ RAIL_TILE_SIGNALS
Normal rail tile with signals.
bool HasSignals(Tile t)
Checks if a rail tile has signals.
static debug_inline bool IsPlainRailTile(Tile t)
Checks whether the tile is a rail tile or rail tile with signals.
SignalState GetSignalStateByTrackdir(Tile tile, Trackdir trackdir)
Gets the state of the signal along the given trackdir.
bool HasTrack(Tile tile, Track track)
Returns whether the given track is present on the given tile.
SignalState GetSingleSignalState(Tile t, uint8_t signalbit)
Get the state of a single signal.
void SetSignalStates(Tile tile, uint state)
Set the states of the signals (Along/AgainstTrackDir)
void SetRailType(Tile t, RailType r)
Sets the rail type of the given tile.
The different types of rail.
RailType
Enumeration for all possible railtypes.
Functions related to signals.
uint8_t SignalAlongTrackdir(Trackdir trackdir)
Maps a trackdir to the bit that stores its status in the map arrays, in the direction along with the ...
uint8_t SignalOnTrack(Track track)
Maps a Track to the bits that store the status of the two signals that can be present on the given tr...
Types and classes related to signals.
SignalType
Type of signal, i.e.
@ SIGTYPE_PBS_ONEWAY
no-entry signal
@ SIGTYPE_PBS
normal pbs signal
@ SIGTYPE_ENTRY
presignal block entry
@ SIGTYPE_COMBO
presignal inter-block
@ SIGTYPE_EXIT
presignal block exit
SignalState
These are states in which a signal can be.
@ SIGNAL_STATE_RED
The signal is red.
@ SIGNAL_STATE_GREEN
The signal is green.
SignalVariant
Variant of the signal, i.e.
Map writing/reading functions for tiles.
void SetTileType(Tile tile, TileType type)
Set the type of a tile.
void SetTileOwner(Tile tile, Owner owner)
Sets the owner of a tile.
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
Different conversion functions from one kind of track to another.
Track TrackdirToTrack(Trackdir trackdir)
Returns the Track that a given Trackdir represents.
Track TrackToOppositeTrack(Track t)
Find the opposite track to a given track.
TrackBits TrackToTrackBits(Track track)
Maps a Track to the corresponding TrackBits value.
Trackdir ReverseTrackdir(Trackdir trackdir)
Maps a trackdir to the reverse trackdir.
bool TracksOverlap(TrackBits bits)
Checks if the given tracks overlap, ie form a crossing.
bool IsValidTrackdir(Trackdir trackdir)
Checks if a Trackdir is valid for non-road vehicles.
bool IsValidTrack(Track track)
Checks if a Track is valid.
Track RemoveFirstTrack(TrackBits *tracks)
Removes first Track from TrackBits and returns it.
Track DiagDirToDiagTrack(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal track incidating with that diagdir.
TrackBits
Allow incrementing of Track variables.
@ INVALID_TRACK_BIT
Flag for an invalid trackbits value.
@ TRACK_BIT_NONE
No track.
Trackdir
Enumeration for tracks and directions.
Track
These are used to specify a single track.
@ INVALID_TRACK
Flag for an invalid track.
@ TRACK_LOWER
Track in the lower corner of the tile (south)
@ TRACK_RIGHT
Track in the right corner of the tile (east)
Map accessors for water tiles.
void SetDockingTile(Tile t, bool b)
Set the docking tile state of a tile.