Changeset - r7869:d6cfc5bdbba9
[Not reviewed]
master
0 1 0
rubidium - 17 years ago 2007-11-12 18:28:55
rubidium@openttd.org
(svn r11419) -Fix [FS#1388]: articulated vehicle breaking up when making a 90 degree turn immediately after a 180 degree turn.
1 file changed with 23 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/roadveh_cmd.cpp
Show inline comments
 
@@ -1415,7 +1415,29 @@ static Trackdir FollowPreviousRoadVehicl
 
	} else if (HASBIT(prev_state, RVS_IN_DT_ROAD_STOP)) {
 
		dir = (Trackdir)(prev_state & RVSB_ROAD_STOP_TRACKDIR_MASK);
 
	} else if (prev_state < TRACKDIR_END) {
 
		dir = (Trackdir)prev_state;
 
		if (already_reversed && prev->tile != tile) {
 
			/*
 
			 * The vehicle has reversed, but did not go straight back.
 
			 * It immediatelly turn onto another tile. This means that
 
			 * the roadstate of the previous vehicle cannot be used
 
			 * as the direction we have to go with this vehicle.
 
			 *
 
			 * Next table is build in the following way:
 
			 *  - first row for when the vehicle in front went to the northern or
 
			 *    western tile, second for southern and eastern.
 
			 *  - columns represent the entry direction.
 
			 *  - cell values are determined by the Trackdir one has to take from
 
			 *    the entry dir (column) to the tile in north or south by only
 
			 *    going over the trackdirs used for turning 90 degrees, i.e.
 
			 *    TRACKDIR_{UPPER,RIGHT,LOWER,LEFT}_{N,E,S,W}.
 
			 */
 
			Trackdir reversed_turn_lookup[2][DIAGDIR_END] = {
 
				{ TRACKDIR_UPPER_W, TRACKDIR_RIGHT_N, TRACKDIR_LEFT_N,  TRACKDIR_UPPER_E },
 
				{ TRACKDIR_RIGHT_S, TRACKDIR_LOWER_W, TRACKDIR_LOWER_E, TRACKDIR_LEFT_S  }};
 
			dir = reversed_turn_lookup[prev->tile < tile ? 0 : 1][ReverseDiagDir(entry_dir)];
 
		} else {
 
			dir = (Trackdir)prev_state;
 
		}
 
	} else {
 
		return INVALID_TRACKDIR;
 
	}
0 comments (0 inline, 0 general)