Merge remote-tracking branch 'upstream/master'

This commit is contained in:
dP
2021-08-16 01:58:47 +03:00
699 changed files with 41188 additions and 22618 deletions

View File

@@ -668,13 +668,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;
}
/**
@@ -763,6 +763,8 @@ private:
DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_UNLOAD | (unload_type << 4), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
/* Transfer and unload orders with leave empty as default */
if (unload_type == OUFB_TRANSFER || unload_type == OUFB_UNLOAD) {
bool set_no_load = false;
if (unload_type == OUFB_TRANSFER){
set_no_load = _settings_client.gui.auto_noload_on_transfer;
@@ -970,7 +972,7 @@ public:
/* Removed / replaced all orders (after deleting / sharing) */
if (this->selected_order == -1) break;
this->DeleteChildWindows();
this->CloseChildWindows();
HideDropDownMenu(this);
this->selected_order = -1;
break;
@@ -1002,7 +1004,7 @@ public:
/* Now we are modifying the selected order */
if (to == INVALID_VEH_ORDER_ID) {
/* Deleting selected order */
this->DeleteChildWindows();
this->CloseChildWindows();
HideDropDownMenu(this);
this->selected_order = -1;
break;
@@ -1301,7 +1303,7 @@ public:
}
/* This order won't be selected any more, close all child windows and dropdowns */
this->DeleteChildWindows();
this->CloseChildWindows();
HideDropDownMenu(this);
if (sel == INVALID_VEH_ORDER_ID || this->vehicle->owner != _local_company) {
@@ -1850,12 +1852,12 @@ static WindowDesc _other_orders_desc(
void ShowOrdersWindow(const Vehicle *v)
{
DeleteWindowById(WC_VEHICLE_DETAILS, v->index, false);
DeleteWindowById(WC_VEHICLE_TIMETABLE, v->index, false);
CloseWindowById(WC_VEHICLE_DETAILS, v->index, false);
CloseWindowById(WC_VEHICLE_TIMETABLE, v->index, false);
if (BringWindowToFrontById(WC_VEHICLE_ORDERS, v->index) != nullptr) return;
/* Using a different WindowDescs for _local_company causes problems.
* Due to this we have to close order windows in ChangeWindowOwner/DeleteCompanyWindows,
* Due to this we have to close order windows in ChangeWindowOwner/CloseCompanyWindows,
* because we cannot change switch the WindowDescs and keeping the old WindowDesc results
* in crashed due to missing widges.
* TODO Rewrite the order GUI to not use different WindowDescs.