mirror of https://github.com/OpenTTD/OpenTTD
Fix: Prevent train reversing when wholly inside a train depot (#9557)
Co-authored-by: Jonathan G Rennison <j.g.rennison@gmail.com>pull/9559/head
parent
18247bb3b8
commit
7acdaaaf2f
|
@ -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.
|
* Turn a train around.
|
||||||
* @param v %Train to turn around.
|
* @param v %Train to turn around.
|
||||||
|
@ -1816,6 +1824,7 @@ static void AdvanceWagonsAfterSwap(Train *v)
|
||||||
void ReverseTrainDirection(Train *v)
|
void ReverseTrainDirection(Train *v)
|
||||||
{
|
{
|
||||||
if (IsRailDepotTile(v->tile)) {
|
if (IsRailDepotTile(v->tile)) {
|
||||||
|
if (IsWholeTrainInsideDepot(v)) return;
|
||||||
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue