diff options
author | rubidium <rubidium@openttd.org> | 2007-11-12 18:28:55 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-11-12 18:28:55 +0000 |
commit | abbde80e53c0724ecf2e7315fb806865e7576bc7 (patch) | |
tree | 14498b2bf1fec89440b98b33b4602690cd148f38 /src | |
parent | 14fe7a9fed94e94a2b486107df8953cf834e1b35 (diff) | |
download | openttd-abbde80e53c0724ecf2e7315fb806865e7576bc7.tar.xz |
(svn r11419) -Fix [FS#1388]: articulated vehicle breaking up when making a 90 degree turn immediately after a 180 degree turn.
Diffstat (limited to 'src')
-rw-r--r-- | src/roadveh_cmd.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 0bb6c80c4..8bfbaa764 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -1415,7 +1415,29 @@ static Trackdir FollowPreviousRoadVehicle(const Vehicle *v, const Vehicle *prev, } 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; } |