(svn r5072) - Backport from trunk (r5071): 0.4
authorpeter1138
Fri, 02 Jun 2006 13:23:22 +0000
branch0.4
changeset 10025 c904d781d751
parent 10024 cec4977c086d
child 10026 1fd0bf7728c6
(svn r5072) - Backport from trunk (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.
train_cmd.c
--- a/train_cmd.c	Mon May 22 16:44:16 2006 +0000
+++ b/train_cmd.c	Fri Jun 02 13:23:22 2006 +0000
@@ -2288,7 +2288,7 @@
 static bool ProcessTrainOrder(Vehicle *v)
 {
 	const Order *order;
-	bool result;
+	bool at_waypoint = false;
 
 	// These are un-interruptible
 	if (v->current_order.type >= OT_GOTO_DEPOT &&
@@ -2308,6 +2308,7 @@
 	// 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..
@@ -2342,29 +2343,28 @@
 
 	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;
+
+		default:
+			return false;
 	}
 
-	InvalidateVehicleOrder(v);
-
-	return result;
+	return !at_waypoint && CheckReverseTrain(v);
 }
 
 static void MarkTrainDirty(Vehicle *v)