Prevent train reversing when wholly inside a train depot
See: #316, https://github.com/OpenTTD/OpenTTD/issues/9520
This commit is contained in:
@@ -2715,6 +2715,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.
|
||||||
@@ -2722,6 +2730,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user