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.
This commit is contained in:
rubidium42
2021-05-26 21:27:28 +02:00
committed by rubidium42
parent b9797a81c0
commit b280f16316
2 changed files with 6 additions and 6 deletions

View File

@@ -211,13 +211,13 @@ struct TimetableWindow : Window {
int GetOrderFromTimetableWndPt(int y, const Vehicle *v)
{
int sel = (y - this->GetWidget<NWidgetBase>(WID_VT_TIMETABLE_PANEL)->pos_y - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL;
uint sel = (y - this->GetWidget<NWidgetBase>(WID_VT_TIMETABLE_PANEL)->pos_y - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL;
if ((uint)sel >= this->vscroll->GetCapacity()) return INVALID_ORDER;
if (sel >= this->vscroll->GetCapacity()) return INVALID_ORDER;
sel += this->vscroll->GetPosition();
return (sel < v->GetNumOrders() * 2 && sel >= 0) ? sel : INVALID_ORDER;
return (sel < v->GetNumOrders() * 2u) ? sel : INVALID_ORDER;
}
/**