summaryrefslogtreecommitdiff
path: root/src/order_gui.cpp
diff options
context:
space:
mode:
authorrubidium42 <rubidium@openttd.org>2021-05-26 21:27:28 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-05-27 18:30:56 +0200
commitb280f163168f6c1036d7a3b0dee552ac68abddf4 (patch)
treebde5bf974f143d8245863b4d022d741d1b3e739d /src/order_gui.cpp
parentb9797a81c055c62c97d1838649466abd3a517a08 (diff)
downloadopenttd-b280f163168f6c1036d7a3b0dee552ac68abddf4.tar.xz
Codechange: remove unneeded comparison and casts
Division by resize_y is already yielding an unsigned number, so when clicking in the WD_FRAMERECT_TOP you would already get a huge value, so sel would never be negative. So, leave sel an unsigned number and remove the <= check.
Diffstat (limited to 'src/order_gui.cpp')
-rw-r--r--src/order_gui.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index bd1165622..8504ee16f 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -548,13 +548,13 @@ private:
VehicleOrderID GetOrderFromPt(int y)
{
NWidgetBase *nwid = this->GetWidget<NWidgetBase>(WID_O_ORDER_LIST);
- int sel = (y - nwid->pos_y - WD_FRAMERECT_TOP) / nwid->resize_y; // Selected line in the WID_O_ORDER_LIST panel.
+ uint sel = (y - nwid->pos_y - WD_FRAMERECT_TOP) / nwid->resize_y; // Selected line in the WID_O_ORDER_LIST panel.
- if ((uint)sel >= this->vscroll->GetCapacity()) return INVALID_VEH_ORDER_ID;
+ if (sel >= this->vscroll->GetCapacity()) return INVALID_VEH_ORDER_ID;
sel += this->vscroll->GetPosition();
- return (sel <= vehicle->GetNumOrders() && sel >= 0) ? sel : INVALID_VEH_ORDER_ID;
+ return (sel <= vehicle->GetNumOrders()) ? sel : INVALID_VEH_ORDER_ID;
}
/**