Add reverse at waypoint orders.

The train will reverse when its tail is within the waypoint tile.
This is useful for reversing on train en-route, without creating
dedicated reversing sidings or platforms.
This commit is contained in:
Jonathan G Rennison
2015-10-28 23:50:22 +00:00
parent 78f8627c34
commit 7bcd090a0f
13 changed files with 81 additions and 5 deletions

View File

@@ -3129,6 +3129,11 @@ static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, i
{
if (v->type == VEH_TRAIN) {
StationID station_id = GetStationIndex(tile);
if (v->current_order.IsType(OT_GOTO_WAYPOINT) && v->current_order.GetDestination() == station_id && v->current_order.GetWaypointFlags() & OWF_REVERSE) {
Train *t = Train::From(v);
// reverse at waypoint
if (t->reverse_distance == 0) t->reverse_distance = t->gcache.cached_total_length;
}
if (!v->current_order.ShouldStopAtStation(v, station_id)) return VETSB_CONTINUE;
if (!IsRailStation(tile) || !v->IsFrontEngine()) return VETSB_CONTINUE;