summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2009-12-27 14:37:46 +0000
committermichi_cc <michi_cc@openttd.org>2009-12-27 14:37:46 +0000
commit182b0b5c141da2afb1d686c08ea786b28d3e0689 (patch)
treef9b1f358971fd8c0ec74c8ab31ee84ed80b90ac9 /src
parent29e05554d77179fea485f43a0d3cbb4b9d5623fc (diff)
downloadopenttd-182b0b5c141da2afb1d686c08ea786b28d3e0689.tar.xz
(svn r18646) -Fix [FS#3418]: [YAPP] Don't extend the reserved path through a newly built path signal directly in front of a stopped or loading train. Also restore the reserved path in more cases after removing a signal.
Diffstat (limited to 'src')
-rw-r--r--src/rail_cmd.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 8fcb666b1..f2f2832b8 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -973,7 +973,13 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1,
MarkTileDirtyByTile(tile);
AddTrackToSignalBuffer(tile, track, _current_company);
YapfNotifyTrackLayoutChange(tile, track);
- if (v != NULL) TryPathReserve(v, true);
+ if (v != NULL) {
+ /* Extend the train's path if it's not stopped or loading, or not at a safe position. */
+ if (!(((v->vehstatus & VS_STOPPED) && v->cur_speed == 0) || v->current_order.IsType(OT_LOADING)) ||
+ !IsSafeWaitingPosition(v, v->tile, v->GetVehicleTrackdir(), true, _settings_game.pf.forbid_90_deg)) {
+ TryPathReserve(v, true);
+ }
+ }
}
return cost;
@@ -1214,6 +1220,18 @@ CommandCost CmdRemoveSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1
Train *v = NULL;
if (HasReservedTracks(tile, TrackToTrackBits(track))) {
v = GetTrainForReservation(tile, track);
+ } else if (IsPbsSignal(GetSignalType(tile, track))) {
+ /* PBS signal, might be the end of a path reservation. */
+ Trackdir td = TrackToTrackdir(track);
+ for (int i = 0; v == NULL && i < 2; i++, td = ReverseTrackdir(td)) {
+ /* Only test the active signal side. */
+ if (!HasSignalOnTrackdir(tile, ReverseTrackdir(td))) continue;
+ TileIndex next = TileAddByDiagDir(tile, TrackdirToExitdir(td));
+ TrackBits tracks = TrackdirBitsToTrackBits(TrackdirReachesTrackdirs(td));
+ if (HasReservedTracks(next, tracks)) {
+ v = GetTrainForReservation(next, TrackBitsToTrack(GetReservedTrackbits(next) & tracks));
+ }
+ }
}
SetPresentSignals(tile, GetPresentSignals(tile) & ~SignalOnTrack(track));