OpenTTD Source
20241121-master-g67a0fccfad
|
Map accessors for roads. More...
#include "track_func.h"
#include "depot_type.h"
#include "rail_type.h"
#include "road_func.h"
#include "tile_map.h"
#include "road_type.h"
Go to the source code of this file.
Macros | |
#define | IsOnDesert IsOnSnow |
Check if a road tile has snow/desert. | |
#define | ToggleDesert ToggleSnow |
Toggle the snow/desert state of a road tile. | |
Enumerations | |
enum | RoadTileType { ROAD_TILE_NORMAL , ROAD_TILE_CROSSING , ROAD_TILE_DEPOT } |
The different types of road tiles. More... | |
enum | Roadside : uint8_t { ROADSIDE_BARREN = 0 , ROADSIDE_GRASS = 1 , ROADSIDE_PAVED = 2 , ROADSIDE_STREET_LIGHTS = 3 , ROADSIDE_TREES = 5 , ROADSIDE_GRASS_ROAD_WORKS = 6 , ROADSIDE_PAVED_ROAD_WORKS = 7 } |
The possible road side decorations. More... | |
Functions | |
bool | MayHaveRoad (Tile t) |
Test whether a tile can have road/tram types. More... | |
static debug_inline RoadTileType | GetRoadTileType (Tile t) |
Get the type of the road tile. More... | |
static debug_inline bool | IsNormalRoad (Tile t) |
Return whether a tile is a normal road. More... | |
static debug_inline bool | IsNormalRoadTile (Tile t) |
Return whether a tile is a normal road tile. More... | |
bool | IsLevelCrossing (Tile t) |
Return whether a tile is a level crossing. More... | |
bool | IsLevelCrossingTile (Tile t) |
Return whether a tile is a level crossing tile. More... | |
static debug_inline bool | IsRoadDepot (Tile t) |
Return whether a tile is a road depot. More... | |
static debug_inline bool | IsRoadDepotTile (Tile t) |
Return whether a tile is a road depot tile. More... | |
RoadBits | GetRoadBits (Tile t, RoadTramType rtt) |
Get the present road bits for a specific road type. More... | |
RoadBits | GetAllRoadBits (Tile tile) |
Get all set RoadBits on the given tile. More... | |
void | SetRoadBits (Tile t, RoadBits r, RoadTramType rtt) |
Set the present road bits for a specific road type. More... | |
RoadType | GetRoadTypeRoad (Tile t) |
RoadType | GetRoadTypeTram (Tile t) |
RoadType | GetRoadType (Tile t, RoadTramType rtt) |
RoadTypes | GetPresentRoadTypes (Tile t) |
Get the present road types of a tile. More... | |
bool | HasRoadTypeRoad (Tile t) |
bool | HasRoadTypeTram (Tile t) |
bool | HasTileRoadType (Tile t, RoadTramType rtt) |
Check if a tile has a road or a tram road type. More... | |
bool | HasTileAnyRoadType (Tile t, RoadTypes rts) |
Check if a tile has one of the specified road types. More... | |
Owner | GetRoadOwner (Tile t, RoadTramType rtt) |
Get the owner of a specific road type. More... | |
void | SetRoadOwner (Tile t, RoadTramType rtt, Owner o) |
Set the owner of a specific road type. More... | |
bool | IsRoadOwner (Tile t, RoadTramType rtt, Owner o) |
Check if a specific road type is owned by an owner. More... | |
bool | HasTownOwnedRoad (Tile t) |
Checks if given tile has town owned road. More... | |
bool | IsValidDisallowedRoadDirections (DisallowedRoadDirections drt) |
Checks if a DisallowedRoadDirections is valid. More... | |
DisallowedRoadDirections | GetDisallowedRoadDirections (Tile t) |
Gets the disallowed directions. More... | |
void | SetDisallowedRoadDirections (Tile t, DisallowedRoadDirections drd) |
Sets the disallowed directions. More... | |
Axis | GetCrossingRoadAxis (Tile t) |
Get the road axis of a level crossing. More... | |
Axis | GetCrossingRailAxis (Tile t) |
Get the rail axis of a level crossing. More... | |
RoadBits | GetCrossingRoadBits (Tile tile) |
Get the road bits of a level crossing. More... | |
Track | GetCrossingRailTrack (Tile tile) |
Get the rail track of a level crossing. More... | |
TrackBits | GetCrossingRailBits (Tile tile) |
Get the rail track bits of a level crossing. More... | |
bool | HasCrossingReservation (Tile t) |
Get the reservation state of the rail crossing. More... | |
void | SetCrossingReservation (Tile t, bool b) |
Set the reservation state of the rail crossing. More... | |
TrackBits | GetCrossingReservationTrackBits (Tile t) |
Get the reserved track bits for a rail crossing. More... | |
bool | IsCrossingBarred (Tile t) |
Check if the level crossing is barred. More... | |
void | SetCrossingBarred (Tile t, bool barred) |
Set the bar state of a level crossing. More... | |
void | UnbarCrossing (Tile t) |
Unbar a level crossing. More... | |
void | BarCrossing (Tile t) |
Bar a level crossing. More... | |
bool | IsOnSnow (Tile t) |
Check if a road tile has snow/desert. More... | |
void | ToggleSnow (Tile t) |
Toggle the snow/desert state of a road tile. More... | |
Roadside | GetRoadside (Tile tile) |
Get the decorations of a road. More... | |
void | SetRoadside (Tile tile, Roadside s) |
Set the decorations of a road. More... | |
bool | HasRoadWorks (Tile t) |
Check if a tile has road works. More... | |
bool | IncreaseRoadWorksCounter (Tile t) |
Increase the progress counter of road works. More... | |
void | StartRoadWorks (Tile t) |
Start road works on a tile. More... | |
void | TerminateRoadWorks (Tile t) |
Terminate road works on a tile. More... | |
DiagDirection | GetRoadDepotDirection (Tile t) |
Get the direction of the exit of a road depot. More... | |
RoadBits | GetAnyRoadBits (Tile tile, RoadTramType rtt, bool straight_tunnel_bridge_entrance=false) |
Returns the RoadBits on an arbitrary tile Special behaviour: More... | |
void | SetRoadTypeRoad (Tile t, RoadType rt) |
Set the road road type of a tile. More... | |
void | SetRoadTypeTram (Tile t, RoadType rt) |
Set the tram road type of a tile. More... | |
void | SetRoadType (Tile t, RoadTramType rtt, RoadType rt) |
Set the road type of a tile. More... | |
void | SetRoadTypes (Tile t, RoadType road_rt, RoadType tram_rt) |
Set the present road types of a tile. More... | |
void | MakeRoadNormal (Tile t, RoadBits bits, RoadType road_rt, RoadType tram_rt, TownID town, Owner road, Owner tram) |
Make a normal road tile. More... | |
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. More... | |
void | SetRoadDepotExitDirection (Tile tile, DiagDirection dir) |
Sets the exit direction of a road depot. More... | |
void | MakeRoadDepot (Tile tile, Owner owner, DepotID depot_id, DiagDirection dir, RoadType rt) |
Make a road depot. More... | |
Map accessors for roads.
Definition in file road_map.h.
enum Roadside : uint8_t |
The possible road side decorations.
Definition at line 477 of file road_map.h.
enum RoadTileType |
The different types of road tiles.
Enumerator | |
---|---|
ROAD_TILE_NORMAL | Normal road. |
ROAD_TILE_CROSSING | Level crossing. |
ROAD_TILE_DEPOT | Depot (one entrance) |
Definition at line 22 of file road_map.h.
|
inline |
Bar a level crossing.
t | The tile to change. |
Definition at line 447 of file road_map.h.
References SetCrossingBarred().
Get all set RoadBits on the given tile.
tile | The tile from which we want to get the RoadBits |
Definition at line 141 of file road_map.h.
References GetRoadBits().
Referenced by GetAxisForNewRoadWaypoint().
Returns the RoadBits on an arbitrary tile Special behaviour:
If straight_tunnel_bridge_entrance is set a ROAD_X or ROAD_Y for bridge ramps and tunnel entrances is returned depending on the orientation of the tunnel or bridge.
tile | the tile to get the road bits for |
rt | the road type to get the road bits form |
straight_tunnel_bridge_entrance | whether to return straight road bits for tunnels/bridges. |
Definition at line 33 of file road_map.cpp.
References AxisToRoadBits(), DiagDirToAxis(), DiagDirToRoadBits(), GetBayRoadStopDir(), GetCrossingRoadBits(), GetDriveThroughStopAxis(), GetRoadBits(), GetRoadDepotDirection(), GetRoadTileType(), GetTileType(), GetTunnelBridgeDirection(), GetTunnelBridgeTransportType(), HasTileRoadType(), IsAnyRoadStopTile(), IsDriveThroughStopTile(), MayHaveRoad(), MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, ReverseDiagDir(), ROAD_NONE, ROAD_TILE_CROSSING, ROAD_TILE_DEPOT, ROAD_TILE_NORMAL, and TRANSPORT_ROAD.
Referenced by CleanUpRoadBits(), and GetTownRoadBits().
Get the rail axis of a level crossing.
t | The tile to query. |
Definition at line 337 of file road_map.h.
References GetCrossingRoadAxis(), IsLevelCrossing(), and OtherAxis().
Referenced by DrawTile_Road(), GetCrossingRailBits(), GetCrossingRailTrack(), and TrainApproachingCrossing().
Get the rail track bits of a level crossing.
tile | The tile to query. |
Definition at line 368 of file road_map.h.
References AxisToTrackBits(), and GetCrossingRailAxis().
Referenced by GetCrossingReservationTrackBits(), and GetRailTrackBitsUniversal().
Get the rail track of a level crossing.
tile | The tile to query. |
Definition at line 358 of file road_map.h.
References AxisToTrack(), and GetCrossingRailAxis().
Referenced by CmdConvertRail().
Get the reserved track bits for a rail crossing.
t | the tile |
Definition at line 405 of file road_map.h.
References GetCrossingRailBits(), HasCrossingReservation(), and TRACK_BIT_NONE.
Referenced by GetReservedTrackbits().
Get the road axis of a level crossing.
t | The tile to query. |
Definition at line 325 of file road_map.h.
References GB(), IsLevelCrossing(), and Tile::m5().
Referenced by GetCrossingRailAxis(), GetCrossingRoadBits(), MarkDirtyAdjacentLevelCrossingTiles(), TrainApproachingCrossingTile(), UpdateAdjacentLevelCrossingTilesOnLevelCrossingRemoval(), and UpdateLevelCrossing().
Get the road bits of a level crossing.
tile | The tile to query. |
Definition at line 348 of file road_map.h.
References AXIS_X, GetCrossingRoadAxis(), ROAD_X, and ROAD_Y.
Referenced by GetAnyRoadBits().
|
inline |
Gets the disallowed directions.
t | the tile to get the directions from |
Definition at line 301 of file road_map.h.
References GB(), IsNormalRoad(), and Tile::m5().
Referenced by GrowTownWithBridge().
Get the present road types of a tile.
t | The tile to query. |
Definition at line 185 of file road_map.h.
Referenced by HasTileAnyRoadType().
Get the present road bits for a specific road type.
t | The tile to query. |
rt | Road type. |
Definition at line 128 of file road_map.h.
References IsNormalRoad().
Referenced by ConnectRoadToStructure(), DrawRoadBits(), DrawRoadCatenary(), GetAllRoadBits(), GetAnyRoadBits(), and CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::GetSingleTramBit().
|
inline |
Get the direction of the exit of a road depot.
t | The tile to query. |
Definition at line 565 of file road_map.h.
References GB(), IsRoadDepot(), and Tile::m5().
Referenced by CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::CanEnterNewTile(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::CanExitOldTile(), CanRoadContinueIntoNextTile(), CmdBuildRoadVehicle(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::ForcedReverse(), GetAnyRoadBits(), RoadVehicle::GetVehicleTrackdir(), and CYapfCostRoadT< Types >::PfCalcCost().
Get the owner of a specific road type.
t | The tile to query. |
rtt | RoadTramType. |
Definition at line 234 of file road_map.h.
References MayHaveRoad().
Referenced by FixOwnerOfRailTrack(), and IsRoadOwner().
Get the decorations of a road.
tile | The tile to query. |
Definition at line 493 of file road_map.h.
References GB(), and Tile::m6().
Referenced by HasRoadWorks(), StartRoadWorks(), and TerminateRoadWorks().
|
static |
Get the type of the road tile.
t | Tile to query. |
Definition at line 52 of file road_map.h.
Referenced by DrawTile_Road(), GetAnyRoadBits(), and IsLevelCrossing().
|
inline |
Get the reservation state of the rail crossing.
t | the crossing tile |
Definition at line 380 of file road_map.h.
References HasBit(), IsLevelCrossingTile(), and Tile::m5().
Referenced by CheckLevelCrossing(), GetCrossingReservationTrackBits(), and TryReserveRailTrack().
|
inline |
Check if a tile has road works.
t | The tile to check. |
Definition at line 513 of file road_map.h.
References GetRoadside(), and ROADSIDE_GRASS_ROAD_WORKS.
Referenced by StartRoadWorks(), and TerminateRoadWorks().
Check if a tile has one of the specified road types.
t | The tile to check. |
rts | Allowed road types. |
Definition at line 222 of file road_map.h.
References GetPresentRoadTypes(), and MayHaveRoad().
Referenced by CheckRoadBlockedForOvertaking(), CmdBuildRoadVehicle(), RoadStop::GetNextRoadStop(), and GetVehicleCannotUseStationReason().
|
inline |
Check if a tile has a road or a tram road type.
t | The tile to check. |
tram | True to check tram, false to check road. |
Definition at line 211 of file road_map.h.
Referenced by GetAnyRoadBits(), HasTownOwnedRoad(), and IsRoadOwner().
|
inline |
Checks if given tile has town owned road.
t | tile to check |
Definition at line 280 of file road_map.h.
References HasTileRoadType().
Referenced by ClosestTownFromTile(), UpdateNearestTownForRoadTiles(), and Town::~Town().
|
inline |
Increase the progress counter of road works.
t | The tile to modify. |
Definition at line 523 of file road_map.h.
References AB(), GB(), and Tile::m7().
|
inline |
Check if the level crossing is barred.
t | The tile to query. |
Definition at line 416 of file road_map.h.
References HasBit(), IsLevelCrossing(), and Tile::m5().
Referenced by MaybeBarCrossingWithSound(), UpdateAdjacentLevelCrossingTilesOnLevelCrossingRemoval(), and UpdateLevelCrossingTile().
|
inline |
Return whether a tile is a level crossing.
t | Tile to query. |
Definition at line 85 of file road_map.h.
References GetRoadTileType(), and ROAD_TILE_CROSSING.
Referenced by AfterLoadCompanyStats(), CmdConvertRail(), GetCrossingRailAxis(), GetCrossingRoadAxis(), GetRailTrackBitsUniversal(), GetReservedTrackbits(), GetTileRailType(), IsCrossingBarred(), IsLevelCrossingTile(), CYapfCostRailT< Types >::OneTileCost(), CYapfCostRoadT< Types >::OneTileCost(), SetCrossingBarred(), TryReserveRailTrack(), and UnreserveRailTrack().
|
inline |
Return whether a tile is a level crossing tile.
t | Tile to query. |
Definition at line 95 of file road_map.h.
References IsLevelCrossing(), IsTileType(), and MP_ROAD.
Referenced by CmdConvertRail(), FixOwnerOfRailTrack(), HasCrossingReservation(), MarkDirtyAdjacentLevelCrossingTiles(), SetCrossingReservation(), TrainApproachingCrossing(), TrainApproachingCrossingTile(), TrainOnCrossing(), UpdateAdjacentLevelCrossingTilesOnLevelCrossingRemoval(), UpdateLevelCrossing(), and UpdateLevelCrossingTile().
|
static |
Return whether a tile is a normal road.
t | Tile to query. |
Definition at line 64 of file road_map.h.
Referenced by DrawRoadCatenary(), GetDisallowedRoadDirections(), GetRoadBits(), SetDisallowedRoadDirections(), and SetRoadBits().
|
static |
Return whether a tile is a normal road tile.
t | Tile to query. |
Definition at line 74 of file road_map.h.
Referenced by CleanUpRoadBits(), ConnectRoadToStructure(), GetAxisForNewRoadWaypoint(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::GetSingleTramBit(), and GrowTownWithBridge().
|
inline |
Check if a road tile has snow/desert.
t | The tile to query. |
Definition at line 459 of file road_map.h.
References HasBit(), and Tile::m7().
|
static |
Return whether a tile is a road depot.
t | Tile to query. |
Definition at line 106 of file road_map.h.
Referenced by CanRoadContinueIntoNextTile(), ClosestTownFromTile(), GetRoadDepotDirection(), GetTownIndex(), SetTownIndex(), and UpdateNearestTownForRoadTiles().
|
static |
Return whether a tile is a road depot tile.
t | Tile to query. |
Definition at line 116 of file road_map.h.
Referenced by GetDepotIndex(), GetTownRoadBits(), IsDepotTile(), CYapfCostRoadT< Types >::PfCalcCost(), CYapfDestinationAnyDepotRoadT< Types >::PfDetectDestination(), and SetRoadDepotExitDirection().
Check if a specific road type is owned by an owner.
t | The tile to query. |
tram | True to check tram, false to check road. |
o | Owner to compare with. |
Definition at line 268 of file road_map.h.
References GetRoadOwner(), and HasTileRoadType().
|
inline |
Checks if a DisallowedRoadDirections is valid.
wc | The value to check |
Definition at line 291 of file road_map.h.
References DRD_END.
Referenced by CmdBuildLongRoad().
|
inline |
Make a level crossing.
t | Tile to make a level crossing. |
road | New owner of road. |
tram | New owner of tram tracks. |
rail | New owner of the rail track. |
roaddir | Axis of the road. |
rat | New rail type. |
road_rt | The road roadtype to set for the tile. |
tram_rt | The tram roadtype to set for the tile. |
town | Town ID if the road is a town-owned road. |
Definition at line 660 of file road_map.h.
References INVALID_ROADTYPE, Tile::m2(), Tile::m3(), Tile::m4(), Tile::m5(), Tile::m6(), Tile::m7(), Tile::m8(), MP_ROAD, ROAD_TILE_CROSSING, SB(), SetRoadOwner(), SetRoadTypes(), SetTileOwner(), and SetTileType().
|
inline |
Make a road depot.
tile | Tile to make a depot on. |
owner | New owner of the depot. |
depot_id | New depot ID. |
dir | Direction of the depot exit. |
rt | Road type of the depot. |
Definition at line 694 of file road_map.h.
References INVALID_ROADTYPE, Tile::m2(), Tile::m3(), Tile::m4(), Tile::m5(), Tile::m6(), Tile::m7(), Tile::m8(), MP_ROAD, ROAD_TILE_DEPOT, SB(), SetRoadType(), SetTileOwner(), and SetTileType().
|
inline |
Make a normal road tile.
t | Tile to make a normal road. |
bits | Road bits to set for all present road types. |
road_rt | The road roadtype to set for the tile. |
tram_rt | The tram roadtype to set for the tile. |
town | Town ID if the road is a town-owned road. |
road | New owner of road. |
tram | New owner of tram tracks. |
Definition at line 635 of file road_map.h.
References INVALID_ROADTYPE, Tile::m2(), Tile::m3(), Tile::m5(), Tile::m6(), Tile::m7(), MP_ROAD, ROAD_TILE_NORMAL, SB(), SetRoadOwner(), SetRoadTypes(), SetTileOwner(), and SetTileType().
|
inline |
Test whether a tile can have road/tram types.
t | Tile to query. |
Definition at line 33 of file road_map.h.
References GetTileType(), MP_ROAD, MP_STATION, and MP_TUNNELBRIDGE.
Referenced by CanConnectToRoad(), DrawRoadTypeCatenary(), GetAnyRoadBits(), GetRoadOwner(), HasTileAnyRoadType(), RemoveRoad(), SetRoadTypeRoad(), and SetRoadTypeTram().
|
inline |
Set the bar state of a level crossing.
t | The tile to modify. |
barred | True if the crossing should be barred, false otherwise. |
Definition at line 428 of file road_map.h.
References AssignBit(), IsLevelCrossing(), and Tile::m5().
Referenced by BarCrossing(), UnbarCrossing(), and UpdateAdjacentLevelCrossingTilesOnLevelCrossingRemoval().
|
inline |
Set the reservation state of the rail crossing.
t | the crossing tile |
b | the reservation state |
Definition at line 393 of file road_map.h.
References AssignBit(), IsLevelCrossingTile(), and Tile::m5().
Referenced by MaybeBarCrossingWithSound(), TryReserveRailTrack(), and UnreserveRailTrack().
|
inline |
Sets the disallowed directions.
t | the tile to set the directions for |
drd | the disallowed directions |
Definition at line 312 of file road_map.h.
References DRD_END, IsNormalRoad(), Tile::m5(), and SB().
Set the present road bits for a specific road type.
t | The tile to change. |
r | The new road bits. |
rt | Road type. |
Definition at line 153 of file road_map.h.
References IsNormalRoad().
|
inline |
Sets the exit direction of a road depot.
tile | Tile of the depot. |
dir | Direction of the depot exit. |
Definition at line 680 of file road_map.h.
References IsRoadDepotTile(), Tile::m5(), and SB().
Set the owner of a specific road type.
t | The tile to change. |
rtt | RoadTramType. |
o | New owner of the given road type. |
Definition at line 251 of file road_map.h.
Referenced by ConvertRoadTypeOwner(), MakeDriveThroughRoadStop(), MakeRoadBridgeRamp(), MakeRoadCrossing(), MakeRoadNormal(), and MakeRoadTunnel().
Set the decorations of a road.
tile | The tile to change. |
s | The new road decoration of the tile. |
Definition at line 503 of file road_map.h.
References Tile::m6(), and SB().
Referenced by StartRoadWorks(), and TerminateRoadWorks().
Set the road type of a tile.
t | The tile to change. |
rtt | Set road or tram type. |
rt | The road type to set. |
Definition at line 604 of file road_map.h.
Referenced by MakeRoadDepot().
Set the road road type of a tile.
t | The tile to change. |
rt | The road type to set. |
Definition at line 579 of file road_map.h.
References INVALID_ROADTYPE, and MayHaveRoad().
Referenced by SetRoadTypes().
Set the present road types of a tile.
t | The tile to change. |
road_rt | The road roadtype to set for the tile. |
tram_rt | The tram roadtype to set for the tile. |
Definition at line 619 of file road_map.h.
References SetRoadTypeRoad(), and SetRoadTypeTram().
Referenced by MakeDriveThroughRoadStop(), MakeRailTunnel(), MakeRoadCrossing(), and MakeRoadNormal().
Set the tram road type of a tile.
t | The tile to change. |
rt | The road type to set. |
Definition at line 591 of file road_map.h.
References INVALID_ROADTYPE, and MayHaveRoad().
Referenced by SetRoadTypes().
|
inline |
Start road works on a tile.
t | The tile to start the work on. |
Definition at line 535 of file road_map.h.
References GetRoadside(), HasRoadWorks(), ROADSIDE_BARREN, ROADSIDE_GRASS, ROADSIDE_GRASS_ROAD_WORKS, ROADSIDE_PAVED_ROAD_WORKS, and SetRoadside().
|
inline |
Terminate road works on a tile.
t | Tile to stop the road works on. |
Definition at line 551 of file road_map.h.
References GetRoadside(), HasRoadWorks(), Tile::m7(), ROADSIDE_GRASS, ROADSIDE_GRASS_ROAD_WORKS, SB(), and SetRoadside().
|
inline |
Toggle the snow/desert state of a road tile.
t | The tile to change. |
Definition at line 470 of file road_map.h.
References Tile::m7(), and ToggleBit().
|
inline |
Unbar a level crossing.
t | The tile to change. |
Definition at line 438 of file road_map.h.
References SetCrossingBarred().