* 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. */
| 1767 | * @pre tile is a rail-road crossing. |
| 1768 | */ |
| 1769 | static 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). |
no test coverage detected