diff options
author | rubidium <rubidium@openttd.org> | 2008-08-02 22:57:18 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-08-02 22:57:18 +0000 |
commit | bba8ff290ea114099e1afa8ef8d65ae6a8600f37 (patch) | |
tree | 7786762d0673cc8cf376a5d0773bdc5829154819 /src | |
parent | 88b1ee0b436e0c8590ea4803d168b8c953018fa4 (diff) | |
download | openttd-bba8ff290ea114099e1afa8ef8d65ae6a8600f37.tar.xz |
(svn r13966) -Codechange [YAPP]: Bar level crossings upon path reservation. (michi_cc)
Diffstat (limited to 'src')
-rw-r--r-- | src/pbs.cpp | 7 | ||||
-rw-r--r-- | src/train_cmd.cpp | 8 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/pbs.cpp b/src/pbs.cpp index 04b956fbd..089591e9b 100644 --- a/src/pbs.cpp +++ b/src/pbs.cpp @@ -101,6 +101,8 @@ bool TryReserveRailTrack(TileIndex tile, Track t) case MP_ROAD: if (IsLevelCrossing(tile) && !GetCrossingReservation(tile)) { SetCrossingReservation(tile, true); + BarCrossing(tile); + MarkTileDirtyByTile(tile); return true; } break; @@ -149,7 +151,10 @@ bool TryReserveRailTrack(TileIndex tile, Track t) break; case MP_ROAD: - if (IsLevelCrossing(tile)) SetCrossingReservation(tile, false); + if (IsLevelCrossing(tile)) { + SetCrossingReservation(tile, false); + UpdateLevelCrossing(tile); + } break; case MP_STATION: diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index d774a7ee6..0fdac279d 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1773,8 +1773,8 @@ void UpdateLevelCrossing(TileIndex tile, bool sound) { assert(IsLevelCrossingTile(tile)); - /* train on crossing || train approaching crossing */ - bool new_state = VehicleFromPos(tile, NULL, &TrainOnTileEnum) != NULL || TrainApproachingCrossing(tile); + /* train on crossing || train approaching crossing || reserved */ + bool new_state = VehicleFromPos(tile, NULL, &TrainOnTileEnum) != NULL || TrainApproachingCrossing(tile) || GetCrossingReservation(tile); if (new_state != IsCrossingBarred(tile)) { if (new_state && sound) { @@ -3734,6 +3734,10 @@ static void TrainController(Vehicle *v, Vehicle *nomove, bool update_image) if (IsFrontEngine(v)) { v->load_unload_time_rem = 0; + /* If we are approching a crossing that is reserved, play the sound now. */ + TileIndex crossing = TrainApproachingCrossingTile(v); + if (crossing != INVALID_TILE && GetCrossingReservation(crossing)) SndPlayTileFx(SND_0E_LEVEL_CROSSING, crossing); + /* Always try to extend the reservation when entering a tile. */ CheckNextTrainTile(v); } |