summaryrefslogtreecommitdiff
path: root/src/train_gui.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2017-12-10 13:45:53 +0000
committerfrosch <frosch@openttd.org>2017-12-10 13:45:53 +0000
commit6f36c52736d28a5aaf8e8066111a2a5421fe2cf5 (patch)
tree3cad865a123bb23737ae95b30c949feef0739206 /src/train_gui.cpp
parentc722cb26b8bc61d720c8a7a037e3c8639851599c (diff)
downloadopenttd-6f36c52736d28a5aaf8e8066111a2a5421fe2cf5.tar.xz
(svn r27936) -Fix: When moving wagons in the depot, the drag highlight did not exactly match the length of the dragged wagon chain.
Diffstat (limited to 'src/train_gui.cpp')
-rw-r--r--src/train_gui.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/train_gui.cpp b/src/train_gui.cpp
index 4724fb98a..51e772b52 100644
--- a/src/train_gui.cpp
+++ b/src/train_gui.cpp
@@ -64,14 +64,14 @@ static int HighlightDragPosition(int px, int max_width, VehicleID selection, boo
bool rtl = _current_text_dir == TD_RTL;
assert(selection != INVALID_VEHICLE);
- int dragged_width = WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
+ int dragged_width = 0;
for (Train *t = Train::Get(selection); t != NULL; t = chain ? t->Next() : (t->HasArticulatedPart() ? t->GetNextArticulatedPart() : NULL)) {
dragged_width += t->GetDisplayImageWidth(NULL);
}
- int drag_hlight_left = rtl ? max(px -dragged_width, 0) : px;
- int drag_hlight_right = rtl ? px : min(px + dragged_width, max_width);
- int drag_hlight_width = max(drag_hlight_right - drag_hlight_left, 0);
+ int drag_hlight_left = rtl ? max(px - dragged_width + 1, 0) : px;
+ int drag_hlight_right = rtl ? px : min(px + dragged_width, max_width) - 1;
+ int drag_hlight_width = max(drag_hlight_right - drag_hlight_left + 1, 0);
if (drag_hlight_width > 0) {
GfxFillRect(drag_hlight_left + WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP + 1,