MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / UpdateLevelCrossingTile

Function UpdateLevelCrossingTile

src/train_cmd.cpp:1769–1783  ·  view source on GitHub ↗

* Sets a level crossing tile to the correct state. * @param tile Tile to update. * @param sound Should we play sound? * @param force_barred Should we set the crossing to barred? * @pre tile is a rail-road crossing. */

Source from the content-addressed store, hash-verified

1767 * @pre tile is a rail-road crossing.
1768 */
1769static void UpdateLevelCrossingTile(TileIndex tile, bool sound, bool force_barred)
1770{
1771 assert(IsLevelCrossingTile(tile));
1772 bool set_barred;
1773
1774 /* We force the crossing to be barred when an adjacent crossing is barred, otherwise let it decide for itself. */
1775 set_barred = force_barred || CheckLevelCrossing(tile);
1776
1777 /* The state has changed */
1778 if (set_barred != IsCrossingBarred(tile)) {
1779 if (set_barred && sound && _settings_client.sound.ambient) SndPlayTileFx(SND_0E_LEVEL_CROSSING, tile);
1780 SetCrossingBarred(tile, set_barred);
1781 MarkTileDirtyByTile(tile);
1782 }
1783}
1784
1785/**
1786 * Update a level crossing to barred or open (crossing may include multiple adjacent tiles).

Callers 1

UpdateLevelCrossingFunction · 0.85

Calls 6

IsLevelCrossingTileFunction · 0.85
CheckLevelCrossingFunction · 0.85
IsCrossingBarredFunction · 0.85
SndPlayTileFxFunction · 0.85
SetCrossingBarredFunction · 0.85
MarkTileDirtyByTileFunction · 0.70

Tested by

no test coverage detected