summaryrefslogtreecommitdiff
path: root/train_cmd.c
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-06-02 13:15:50 +0000
committerpeter1138 <peter1138@openttd.org>2006-06-02 13:15:50 +0000
commitfbe7303c3aac2bbad40903bd5d9b618e56317a24 (patch)
tree939f47159af8c9fdd058c40ee63b40b4eced46ee /train_cmd.c
parent25a63ec7af6fadb2d33ef84f79597c14b10e7f39 (diff)
downloadopenttd-fbe7303c3aac2bbad40903bd5d9b618e56317a24.tar.xz
(svn r5071) - Fix (FS#184): "Erroneous train reversal on waypoints". When processing the next train order, do not even consider reversing the train if the last order was to a waypoint.
Diffstat (limited to 'train_cmd.c')
-rw-r--r--train_cmd.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/train_cmd.c b/train_cmd.c
index 9b008682b..1d27c901d 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -2347,7 +2347,7 @@ bad:;
static bool ProcessTrainOrder(Vehicle *v)
{
const Order *order;
- bool result;
+ bool at_waypoint = false;
switch (v->current_order.type) {
case OT_GOTO_DEPOT:
@@ -2366,6 +2366,7 @@ static bool ProcessTrainOrder(Vehicle *v)
// check if we've reached the waypoint?
if (v->current_order.type == OT_GOTO_WAYPOINT && v->tile == v->dest_tile) {
v->cur_order_index++;
+ at_waypoint = true;
}
// check if we've reached a non-stop station while TTDPatch nonstop is enabled..
@@ -2400,29 +2401,28 @@ static bool ProcessTrainOrder(Vehicle *v)
v->dest_tile = 0;
- result = false;
+ InvalidateVehicleOrder(v);
+
switch (order->type) {
case OT_GOTO_STATION:
if (order->station == v->last_station_visited)
v->last_station_visited = INVALID_STATION;
v->dest_tile = GetStation(order->station)->xy;
- result = CheckReverseTrain(v);
break;
case OT_GOTO_DEPOT:
v->dest_tile = GetDepot(order->station)->xy;
- result = CheckReverseTrain(v);
break;
case OT_GOTO_WAYPOINT:
v->dest_tile = GetWaypoint(order->station)->xy;
- result = CheckReverseTrain(v);
break;
- }
- InvalidateVehicleOrder(v);
+ default:
+ return false;
+ }
- return result;
+ return !at_waypoint && CheckReverseTrain(v);
}
static void MarkTrainDirty(Vehicle *v)