Functions

# trafficlight_func.h File Reference

Functions related to trafficlights. More...

`#include "road_map.h"`

Go to the source code of this file.

## Functions
TrackdirBits | GetTrafficLightDisallowedDirections (TileIndex tile)
| Get a bitmask of the directions forbidden to drive on due to traffic light(s).
void | DrawTrafficLights (TileInfo *ti)
| Draws traffic lights on a tile.
CommandCost | CmdBuildTrafficLights (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build traffic lights on a crossing.
CommandCost | CmdRemoveTrafficLights (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Removes traffic lights from a tile.
void | ClearAllTrafficLights ()
| Clear all traffic lights from the map.

## Detailed Description

Functions related to trafficlights.

Definition in file trafficlight_func.h.

## Function Documentation

CommandCost CmdBuildTrafficLights | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build traffic lights on a crossing.

Parameters:

  | tile | Tile where to place the traffic lights.
  | flags | Operation to perform.
  | p1 | Unused.
  | p2 | Unused.

Returns:
  CommandCost Cost or error.

Definition at line 189 of file trafficlight.cpp.

References _current_company, _settings_game, AddAnimatedTile(), ConstructionSettings::allow_building_tls_in_towns, CheckTLCSize(), CMD_ERROR, GameSettings::construction, CountBits(), DC_EXEC, EXPENSES_CONSTRUCTION, GetAllRoadBits(), GetRoadTileType(), GetTileOwner(), HasTrafficLights(), IsTileOwner(), IsTileType(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), MarkTileDirtyByTile(), MP_ROAD, OWNER_NONE, OWNER_TOWN, return_cmd_error, ROAD_TILE_NORMAL, and ConstructionSettings::traffic_lights.

CommandCost CmdRemoveTrafficLights | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Removes traffic lights from a tile.

Parameters:

  | tile | Tile where to remove the traffic lights.
  | flags | Operation to perform.
  | p1 | Unused.
  | p2 | Unused.

Returns:
  CommandCost Cost or error.

Definition at line 230 of file trafficlight.cpp.

References _cheats, _current_company, _settings_game, ConstructionSettings::allow_building_tls_in_towns, CMD_ERROR, GameSettings::construction, DC_EXEC, DeleteAnimatedTile(), EXPENSES_CONSTRUCTION, GetRoadTileType(), GetTileOwner(), HasTrafficLights(), IsTileOwner(), IsTileType(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), Cheats::magic_bulldozer, MarkTileDirtyByTile(), MP_ROAD, OWNER_NONE, OWNER_TOWN, return_cmd_error, ROAD_TILE_NORMAL, and Cheat::value.

void DrawTrafficLights | ( | TileInfo * | ti | ) |

Draws traffic lights on a tile.

Parameters:

  | ti | TileInfo of the tile to draw on.

Definition at line 270 of file trafficlight.cpp.

References _settings_game, _tl_offsets, _tls_to_sprites, DrawRoadDetail(), DRD_BOTH, DRD_NORTHBOUND, DRD_SOUTHBOUND, GetAllRoadBits(), GetDisallowedRoadDirections(), GetTLState(), HasTrafficLights(), IsNormalRoad(), IsTileType(), MP_ROAD, ROAD_NE, VehicleSettings::road_side, TileInfo::tile, TileDiffXY(), and GameSettings::vehicle.

Referenced by DrawRoadBits().

TrackdirBits GetTrafficLightDisallowedDirections | ( | TileIndex | tile | ) |

Get a bitmask of the directions forbidden to drive on due to traffic light(s).

Parameters:

  | tile | Tile to check.

Returns:
  Bitmask of forbidden directions.

Definition at line 162 of file trafficlight.cpp.

References _tls_to_trackdir, GetIntraTLCAllowedDirections(), and GetTLState().