156 if (rtt == RTT_TRAM) {
177 return (rtt == RTT_TRAM) ? GetRoadTypeTram(t) : GetRoadTypeRoad(t);
195inline bool HasRoadTypeRoad(
Tile t)
200inline bool HasRoadTypeTram(
Tile t)
253 if (rtt == RTT_ROAD) {
316 SB(t.
m5(), 4, 2, drd);
453#define IsOnDesert IsOnSnow
465#define ToggleDesert ToggleSnow
505 SB(tile.
m6(), 3, 3, s);
527 return GB(t.
m7(), 0, 4) == 15;
583 SB(t.
m4(), 0, 6, rt);
595 SB(t.
m8(), 6, 6, rt);
606 if (rtt == RTT_TRAM) {
683 SB(tile.
m5(), 0, 2, dir);
698 tile.
m2() = depot_id;
702 SB(tile.
m6(), 2, 4, 0);
debug_inline constexpr 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 T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
constexpr T AB(T &x, const uint8_t s, const uint8_t n, const U i)
Add i to n bits of x starting at bit s.
debug_inline static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
constexpr T ToggleBit(T &x, const uint8_t y)
Toggles a bit in a variable.
Wrapper class to abstract away the way the tiles are stored.
debug_inline uint16_t & m8()
General purpose.
debug_inline uint16_t & m2()
Primarily used for indices to towns, industries and stations.
debug_inline uint8_t & m7()
Primarily used for newgrf support.
debug_inline uint8_t & m4()
General purpose.
debug_inline uint8_t & m6()
General purpose.
debug_inline uint8_t & m3()
General purpose.
debug_inline uint8_t & m1()
Primarily used for ownership information.
debug_inline uint8_t & m5()
General purpose.
Owner
Enum for all companies/owners.
@ OWNER_NONE
The tile has no ownership.
@ OWNER_TOWN
A town owns the tile, or a town is expanding.
Header files for depots (not hangars)
uint16_t DepotID
Type for the unique identifier of depots.
Axis OtherAxis(Axis a)
Select the other axis as provided.
Axis
Allow incrementing of DiagDirDiff variables.
DiagDirection
Enumeration for diagonal directions.
The different types of rail.
RailType
Enumeration for all possible railtypes.
Functions related to roads.
void SetRoadOwner(Tile t, RoadTramType rtt, Owner o)
Set the owner of a specific road type.
bool HasCrossingReservation(Tile t)
Get the reservation state of the rail crossing.
bool HasTownOwnedRoad(Tile t)
Checks if given tile has town owned road.
static debug_inline bool IsNormalRoadTile(Tile t)
Return whether a tile is a normal road tile.
static debug_inline bool IsRoadDepot(Tile t)
Return whether a tile is a road depot.
void SetRoadDepotExitDirection(Tile tile, DiagDirection dir)
Sets the exit direction of a road depot.
RoadTypes GetPresentRoadTypes(Tile t)
Get the present road types of a tile.
void SetRoadTypeRoad(Tile t, RoadType rt)
Set the road road type of a tile.
void SetRoadTypeTram(Tile t, RoadType rt)
Set the tram road type of a tile.
RoadBits GetAnyRoadBits(Tile tile, RoadTramType rtt, bool straight_tunnel_bridge_entrance=false)
Returns the RoadBits on an arbitrary tile Special behaviour:
bool IsLevelCrossingTile(Tile t)
Return whether a tile is a level crossing tile.
bool IncreaseRoadWorksCounter(Tile t)
Increase the progress counter of road works.
RoadBits GetRoadBits(Tile t, RoadTramType rtt)
Get the present road bits for a specific road type.
RoadTileType
The different types of road tiles.
@ ROAD_TILE_NORMAL
Normal road.
@ ROAD_TILE_DEPOT
Depot (one entrance)
@ ROAD_TILE_CROSSING
Level crossing.
bool MayHaveRoad(Tile t)
Test whether a tile can have road/tram types.
bool HasTileAnyRoadType(Tile t, RoadTypes rts)
Check if a tile has one of the specified road types.
bool IsValidDisallowedRoadDirections(DisallowedRoadDirections drt)
Checks if a DisallowedRoadDirections is valid.
Axis GetCrossingRoadAxis(Tile t)
Get the road axis of a level crossing.
TrackBits GetCrossingRailBits(Tile tile)
Get the rail track bits of a level crossing.
void SetDisallowedRoadDirections(Tile t, DisallowedRoadDirections drd)
Sets the disallowed directions.
Track GetCrossingRailTrack(Tile tile)
Get the rail track of a level crossing.
void StartRoadWorks(Tile t)
Start road works on a tile.
void SetCrossingBarred(Tile t, bool barred)
Set the bar state of a level crossing.
DisallowedRoadDirections GetDisallowedRoadDirections(Tile t)
Gets the disallowed directions.
void SetRoadTypes(Tile t, RoadType road_rt, RoadType tram_rt)
Set the present road types of a tile.
bool HasTileRoadType(Tile t, RoadTramType rtt)
Check if a tile has a road or a tram road type.
DiagDirection GetRoadDepotDirection(Tile t)
Get the direction of the exit of a road depot.
static debug_inline bool IsRoadDepotTile(Tile t)
Return whether a tile is a road depot tile.
void BarCrossing(Tile t)
Bar a level crossing.
void MakeRoadCrossing(Tile t, Owner road, Owner tram, Owner rail, Axis roaddir, RailType rat, RoadType road_rt, RoadType tram_rt, uint town)
Make a level crossing.
void MakeRoadNormal(Tile t, RoadBits bits, RoadType road_rt, RoadType tram_rt, TownID town, Owner road, Owner tram)
Make a normal road tile.
Roadside GetRoadside(Tile tile)
Get the decorations of a road.
RoadBits GetAllRoadBits(Tile tile)
Get all set RoadBits on the given tile.
void ToggleSnow(Tile t)
Toggle the snow/desert state of a road tile.
bool IsOnSnow(Tile t)
Check if a road tile has snow/desert.
Axis GetCrossingRailAxis(Tile t)
Get the rail axis of a level crossing.
TrackBits GetCrossingReservationTrackBits(Tile t)
Get the reserved track bits for a rail crossing.
void TerminateRoadWorks(Tile t)
Terminate road works on a tile.
RoadBits GetCrossingRoadBits(Tile tile)
Get the road bits of a level crossing.
void SetRoadType(Tile t, RoadTramType rtt, RoadType rt)
Set the road type of a tile.
Owner GetRoadOwner(Tile t, RoadTramType rtt)
Get the owner of a specific road type.
static debug_inline RoadTileType GetRoadTileType(Tile t)
Get the type of the road tile.
bool IsCrossingBarred(Tile t)
Check if the level crossing is barred.
void SetRoadside(Tile tile, Roadside s)
Set the decorations of a road.
void UnbarCrossing(Tile t)
Unbar a level crossing.
bool IsRoadOwner(Tile t, RoadTramType rtt, Owner o)
Check if a specific road type is owned by an owner.
void MakeRoadDepot(Tile tile, Owner owner, DepotID depot_id, DiagDirection dir, RoadType rt)
Make a road depot.
void SetCrossingReservation(Tile t, bool b)
Set the reservation state of the rail crossing.
void SetRoadBits(Tile t, RoadBits r, RoadTramType rtt)
Set the present road bits for a specific road type.
Roadside
The possible road side decorations.
@ ROADSIDE_GRASS_ROAD_WORKS
Road on grass with road works.
@ ROADSIDE_PAVED
Road with paved sidewalks.
@ ROADSIDE_PAVED_ROAD_WORKS
Road with sidewalks and road works.
@ ROADSIDE_STREET_LIGHTS
Road with street lights on paved sidewalks.
@ ROADSIDE_BARREN
Road on barren land.
@ ROADSIDE_GRASS
Road on grass.
@ ROADSIDE_TREES
Road with trees on paved sidewalks.
bool IsLevelCrossing(Tile t)
Return whether a tile is a level crossing.
bool HasRoadWorks(Tile t)
Check if a tile has road works.
static debug_inline bool IsNormalRoad(Tile t)
Return whether a tile is a normal road.
Enums and other types related to roads.
RoadBits
Enumeration for the road parts on a tile.
@ ROAD_Y
Full road along the y-axis (north-west + south-east)
@ ROAD_X
Full road along the x-axis (south-west + north-east)
RoadTypes
The different roadtypes we support, but then a bitmask of them.
@ ROADTYPES_NONE
No roadtypes.
RoadType
The different roadtypes we support.
@ INVALID_ROADTYPE
flag for invalid roadtype
DisallowedRoadDirections
Which directions are disallowed ?
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 TileType GetTileType(Tile tile)
Get the tiletype of a given tile.
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
@ MP_ROAD
A tile with road (or tram tracks)
@ MP_STATION
A tile of a station.
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
Different conversion functions from one kind of track to another.
TrackBits AxisToTrackBits(Axis a)
Maps an Axis to the corresponding TrackBits value.
Track AxisToTrack(Axis a)
Convert an Axis to the corresponding Track AXIS_X -> TRACK_X AXIS_Y -> TRACK_Y Uses the fact that the...
TrackBits
Allow incrementing of Track variables.
@ TRACK_BIT_NONE
No track.
Track
These are used to specify a single track.