Changeset - r3934:9868ebc2c374
[Not reviewed]
master
0 1 0
peter1138 - 18 years ago 2006-06-02 13:15:50
peter1138@openttd.org
(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.
1 file changed with 8 insertions and 8 deletions:
0 comments (0 inline, 0 general)
train_cmd.c
Show inline comments
 
@@ -2344,13 +2344,13 @@ bad:;
 
	return reverse_best != 0;
 
}
 

	
 
static bool ProcessTrainOrder(Vehicle *v)
 
{
 
	const Order *order;
 
	bool result;
 
	bool at_waypoint = false;
 

	
 
	switch (v->current_order.type) {
 
		case OT_GOTO_DEPOT:
 
			if (!(v->current_order.flags & OF_PART_OF_ORDERS)) return false;
 
			if ((v->current_order.flags & OF_SERVICE_IF_NEEDED) &&
 
					!VehicleNeedsService(v)) {
 
@@ -2363,12 +2363,13 @@ static bool ProcessTrainOrder(Vehicle *v
 
			return false;
 
	}
 

	
 
	// 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..
 
	if (_patches.new_nonstop &&
 
			v->current_order.flags & OF_NON_STOP &&
 
			IsTileType(v->tile, MP_STATION) &&
 
@@ -2397,35 +2398,34 @@ static bool ProcessTrainOrder(Vehicle *v
 

	
 
	// Otherwise set it, and determine the destination tile.
 
	v->current_order = *order;
 

	
 
	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)
 
{
 
	do {
 
		v->cur_image = GetTrainImage(v, v->direction);
0 comments (0 inline, 0 general)