Mercurial > hg > openttd
changeset 8356:68587b4684d2 draft
(svn r11922) -Codechange: use MaybeBarCrossingWithSound() to bar crossing with sound
author | smatz <smatz@openttd.org> |
---|---|
date | Fri, 18 Jan 2008 21:44:20 +0000 |
parents | 73ad124db503 |
children | 711bbeced0a7 |
files | src/train_cmd.cpp |
diffstat | 1 files changed, 17 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1704,6 +1704,21 @@ /** + * Bars crossing and plays ding-ding sound if not barred already + * @param tile tile with crossing + * @pre tile is a rail-road crossing + */ +static inline void MaybeBarCrossingWithSound(TileIndex tile) +{ + if (!IsCrossingBarred(tile)) { + BarCrossing(tile); + SndPlayTileFx(SND_0E_LEVEL_CROSSING, tile); + MarkTileDirtyByTile(tile); + } +} + + +/** * Advances wagons for train reversing, needed for variable length wagons. * Needs to be called once before the train is reversed, and once after it. * @param v First vehicle in chain @@ -1780,7 +1795,7 @@ /* maybe we are approaching crossing now, after reversal */ crossing = TrainApproachingCrossingTile(v); - if (crossing != INVALID_TILE) UpdateLevelCrossing(crossing); + if (crossing != INVALID_TILE) MaybeBarCrossingWithSound(crossing); } /** Reverse train. @@ -3459,11 +3474,7 @@ if ((ts & (ts >> 16)) != 0) return TrainApproachingLineEnd(v, true); /* approaching a rail/road crossing? then make it red */ - if (IsLevelCrossingTile(tile) && !IsCrossingBarred(tile)) { - BarCrossing(tile); - SndPlayTileFx(SND_0E_LEVEL_CROSSING, tile); - MarkTileDirtyByTile(tile); - } + if (IsLevelCrossingTile(tile)) MaybeBarCrossingWithSound(tile); return true; }