diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index c634ce4582..8cb6c9af96 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -3338,6 +3338,10 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth, bool } if (v->current_order.GetDepotActionType() & ODATFB_NEAREST_DEPOT) { + /* If the vehicle can't find its destination, delay its next search. + * In case many vehicles are in this state, use the vehicle index to spread out pathfinder calls. */ + if (v->dest_tile == 0 && (_scaled_tick_counter & 0x3F) != (v->index & 0x3F)) break; + /* We need to search for the nearest depot (hangar). */ ClosestDepot closestDepot = v->FindClosestDepot(); diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index d92fb47919..941cda8a16 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -156,9 +156,9 @@ static const int CTMN_SPECTATOR = -3; ///< Show a company window as spectator * Pop up a generic company list menu. * @param w The toolbar window. * @param widget The button widget id. - * @param grey A bitbask of which items to mark as disabled. + * @param grey A bitmask of which companies to mark as disabled. */ -static void PopupMainCompanyToolbMenu(Window *w, WidgetID widget, int grey = 0) +static void PopupMainCompanyToolbMenu(Window *w, WidgetID widget, CompanyMask grey = 0) { DropDownList list; @@ -753,10 +753,10 @@ static CallBackFunction MenuClickIndustry(int index) static void ToolbarVehicleClick(Window *w, VehicleType veh) { - int dis = ~0; + CompanyMask dis = 0; - for (const Vehicle *v : Vehicle::Iterate()) { - if (v->type == veh && v->IsPrimaryVehicle()) ClrBit(dis, v->owner); + for (const Company *c : Company::Iterate()) { + if (c->group_all[veh].num_vehicle == 0) SetBit(dis, c->index); } PopupMainCompanyToolbMenu(w, WID_TN_VEHICLE_START + veh, dis); }