diff options
author | smatz <smatz@openttd.org> | 2008-01-17 20:41:33 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2008-01-17 20:41:33 +0000 |
commit | 8d077b16d8749c34482125e6a51cac098209aa87 (patch) | |
tree | 37fe41422eb623a05d7c933ea9ba8f121e35cd01 /src/train_cmd.cpp | |
parent | ac0fa7f69f43d92bcd117c068774064c00b98528 (diff) | |
download | openttd-8d077b16d8749c34482125e6a51cac098209aa87.tar.xz |
(svn r11910) -Fix: play 'ding-ding' crossing sound in more cases (except gameload and crossing construction)
-Fix: crossing sound is bound to tile, not to vehicle
Diffstat (limited to 'src/train_cmd.cpp')
-rw-r--r-- | src/train_cmd.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 68c5080f2..ad6a8afe3 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1683,20 +1683,23 @@ static Vehicle *TrainApproachingCrossing(TileIndex tile) /** * Sets correct crossing state * @param tile tile to update + * @param sound should we play sound? * @pre tile is a rail-road crossing */ -void UpdateLevelCrossing(TileIndex tile) +void UpdateLevelCrossing(TileIndex tile, bool sound) { assert(IsLevelCrossingTile(tile)); - UnbarCrossing(tile); - /* train on crossing || train approaching crossing */ - if (VehicleFromPos(tile, NULL, &TrainOnTileEnum) || TrainApproachingCrossing(tile)) { - BarCrossing(tile); - } + bool new_state = VehicleFromPos(tile, NULL, &TrainOnTileEnum) || TrainApproachingCrossing(tile); - MarkTileDirtyByTile(tile); + if (new_state != IsCrossingBarred(tile)) { + if (new_state && sound) { + SndPlayTileFx(SND_0E_LEVEL_CROSSING, tile); + } + SetCrossingBarred(tile, new_state); + MarkTileDirtyByTile(tile); + } } @@ -3458,7 +3461,7 @@ static bool TrainCheckIfLineEnds(Vehicle *v) /* approaching a rail/road crossing? then make it red */ if (IsLevelCrossingTile(tile) && !IsCrossingBarred(tile)) { BarCrossing(tile); - SndPlayVehicleFx(SND_0E_LEVEL_CROSSING, v); + SndPlayTileFx(SND_0E_LEVEL_CROSSING, tile); MarkTileDirtyByTile(tile); } |