diff --git a/src/station_gui.cpp b/src/station_gui.cpp index a4ec6cfc98..b6308ddb03 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -1399,12 +1399,18 @@ struct StationViewWindow : public Window { this->vscroll->SetCount(cargo.GetNumChildren()); // update scrollbar + byte have_veh_types = 0; + IterateOrderRefcountMapForDestinationID(st->index, [&](CompanyID cid, OrderType order_type, VehicleType veh_type, uint32 refcount) { + SetBit(have_veh_types, veh_type); + return true; + }); + /* disable some buttons */ this->SetWidgetDisabledState(WID_SV_RENAME, st->owner != _local_company); - this->SetWidgetDisabledState(WID_SV_TRAINS, !(st->facilities & FACIL_TRAIN)); - this->SetWidgetDisabledState(WID_SV_ROADVEHS, !(st->facilities & FACIL_TRUCK_STOP) && !(st->facilities & FACIL_BUS_STOP)); - this->SetWidgetDisabledState(WID_SV_SHIPS, !(st->facilities & FACIL_DOCK)); - this->SetWidgetDisabledState(WID_SV_PLANES, !(st->facilities & FACIL_AIRPORT)); + this->SetWidgetDisabledState(WID_SV_TRAINS, !(st->facilities & FACIL_TRAIN) && !HasBit(have_veh_types, VEH_TRAIN)); + this->SetWidgetDisabledState(WID_SV_ROADVEHS, !(st->facilities & FACIL_TRUCK_STOP) && !(st->facilities & FACIL_BUS_STOP) && !HasBit(have_veh_types, VEH_ROAD)); + this->SetWidgetDisabledState(WID_SV_SHIPS, !(st->facilities & FACIL_DOCK) && !HasBit(have_veh_types, VEH_SHIP)); + this->SetWidgetDisabledState(WID_SV_PLANES, !(st->facilities & FACIL_AIRPORT) && !HasBit(have_veh_types, VEH_AIRCRAFT)); this->SetWidgetDisabledState(WID_SV_CLOSE_AIRPORT, !(st->facilities & FACIL_AIRPORT) || st->owner != _local_company || st->owner == OWNER_NONE); // Also consider SE, where _local_company == OWNER_NONE this->SetWidgetLoweredState(WID_SV_CLOSE_AIRPORT, (st->facilities & FACIL_AIRPORT) && (st->airport.flags & AIRPORT_CLOSED_block) != 0);