diff options
author | frosch <frosch@openttd.org> | 2016-08-15 18:33:29 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2016-08-15 18:33:29 +0000 |
commit | cff2b493653eda314f997f998b297621eeb9e190 (patch) | |
tree | 7c78e9d598489cdf03aa5ee91cdbe2d0e9dad232 | |
parent | 3cb7d9703b376b8798e5726591add2d4e2a17223 (diff) | |
download | openttd-cff2b493653eda314f997f998b297621eeb9e190.tar.xz |
(svn r27629) -Fix: When dragging multiple vehicles in the depot, make the destination gap as long as the chain instead of just considering the first vehicle.
-rw-r--r-- | src/train_gui.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/train_gui.cpp b/src/train_gui.cpp index d9da09701..219d016ec 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -56,15 +56,16 @@ void CcBuildWagon(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p * @param px The current x position to draw from. * @param max_width The maximum space available to draw. * @param selection Selected vehicle that is dragged. + * @param chain Whether a whole chain is dragged. * @return The width of the highlight mark. */ -static int HighlightDragPosition(int px, int max_width, VehicleID selection) +static int HighlightDragPosition(int px, int max_width, VehicleID selection, bool chain) { bool rtl = _current_text_dir == TD_RTL; assert(selection != INVALID_VEHICLE); int dragged_width = WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT; - for (Train *t = Train::Get(selection); t != NULL; t = t->HasArticulatedPart() ? t->GetNextArticulatedPart() : NULL) { + for (Train *t = Train::Get(selection); t != NULL; t = chain ? t->Next() : (t->HasArticulatedPart() ? t->GetNextArticulatedPart() : NULL)) { dragged_width += t->GetDisplayImageWidth(NULL); } @@ -114,7 +115,7 @@ void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID select for (; v != NULL && (rtl ? px > 0 : px < max_width); v = v->Next()) { if (dragging && !drag_at_end_of_train && drag_dest == v->index) { /* Highlight the drag-and-drop destination inside the train. */ - int drag_hlight_width = HighlightDragPosition(px, max_width, selection); + int drag_hlight_width = HighlightDragPosition(px, max_width, selection, _cursor.vehchain); px += rtl ? -drag_hlight_width : drag_hlight_width; } @@ -146,7 +147,7 @@ void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID select if (dragging && drag_at_end_of_train) { /* Highlight the drag-and-drop destination at the end of the train. */ - HighlightDragPosition(px, max_width, selection); + HighlightDragPosition(px, max_width, selection, _cursor.vehchain); } if (highlight_l != highlight_r) { |