diff options
author | Patric Stout <truebrain@openttd.org> | 2021-09-18 15:56:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-18 15:56:23 +0200 |
commit | 7acdaaaf2f6c5f4a605031d25a891e16ff603965 (patch) | |
tree | 9a915ba0bdc489f5352a5bdf067809c4f95c6cbf | |
parent | 18247bb3b8aaad6db1137e5590b695a8e0dd8068 (diff) | |
download | openttd-7acdaaaf2f6c5f4a605031d25a891e16ff603965.tar.xz |
Fix: Prevent train reversing when wholly inside a train depot (#9557)
Co-authored-by: Jonathan G Rennison <j.g.rennison@gmail.com>
-rw-r--r-- | src/train_cmd.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index f926be637..f5eb32d7f 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1809,6 +1809,14 @@ static void AdvanceWagonsAfterSwap(Train *v) } } +static bool IsWholeTrainInsideDepot(const Train *v) +{ + for (const Train *u = v; u != nullptr; u = u->Next()) { + if (u->track != TRACK_BIT_DEPOT || u->tile != v->tile) return false; + } + return true; +} + /** * Turn a train around. * @param v %Train to turn around. @@ -1816,6 +1824,7 @@ static void AdvanceWagonsAfterSwap(Train *v) void ReverseTrainDirection(Train *v) { if (IsRailDepotTile(v->tile)) { + if (IsWholeTrainInsideDepot(v)) return; InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); } |