Mercurial > hg > openttd
changeset 7869:ed704f977a00 draft
(svn r11419) -Fix [FS#1388]: articulated vehicle breaking up when making a 90 degree turn immediately after a 180 degree turn.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Mon, 12 Nov 2007 18:28:55 +0000 |
parents | 3ee1134b5a85 |
children | 6c407857c836 |
files | src/roadveh_cmd.cpp |
diffstat | 1 files changed, 23 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -1415,7 +1415,29 @@ } 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; }