summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pbs.cpp3
-rw-r--r--src/train_cmd.cpp2
2 files changed, 4 insertions, 1 deletions
diff --git a/src/pbs.cpp b/src/pbs.cpp
index 01e7b2f37..3dbd5b883 100644
--- a/src/pbs.cpp
+++ b/src/pbs.cpp
@@ -369,7 +369,8 @@ Train *GetTrainForReservation(TileIndex tile, Track track)
*/
bool IsSafeWaitingPosition(const Train *v, TileIndex tile, Trackdir trackdir, bool include_line_end, bool forbid_90deg)
{
- if (IsRailDepotTile(tile)) return true;
+ /* A depot is safe if we enter it, but not when we exit. */
+ if (IsRailDepotTile(tile) && TrackdirToExitdir(trackdir) != GetRailDepotDirection(tile)) return true;
if (IsTileType(tile, MP_RAILWAY)) {
/* For non-pbs signals, stop on the signal tile. */
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 4473c5265..101aeca0a 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -2200,6 +2200,8 @@ void FreeTrainTrackReservation(const Train *v, TileIndex origin, Trackdir orig_t
bool free_tile = tile != v->tile || !(IsRailStationTile(v->tile) || IsTileType(v->tile, MP_TUNNELBRIDGE));
StationID station_id = IsRailStationTile(v->tile) ? GetStationIndex(v->tile) : INVALID_STATION;
+ /* A train inside a depot can't have a reservation. */
+ if (v->track == TRACK_BIT_DEPOT) return;
/* Don't free reservation if it's not ours. */
if (TracksOverlap(GetReservedTrackbits(tile) | TrackToTrackBits(TrackdirToTrack(td)))) return;