diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp index d2ea1b25de..d42cc5e51d 100644 --- a/src/timetable_cmd.cpp +++ b/src/timetable_cmd.cpp @@ -667,6 +667,8 @@ CommandCost CmdTimetableSeparation(TileIndex tile, DoCommandFlag flags, uint32_t CommandCost ret = CheckOwnership(v->owner); if (ret.Failed()) return ret; + if (HasBit(p2, 0) && (HasBit(v->vehicle_flags, VF_SCHEDULED_DISPATCH) || v->HasUnbunchingOrder())) return CommandCost(STR_ERROR_SEPARATION_MUTUALLY_EXCLUSIVE); + if (flags & DC_EXEC) { for (Vehicle *v2 = v->FirstShared(); v2 != nullptr; v2 = v2->NextShared()) { if (HasBit(p2, 0)) { diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 510db28482..960b7f10de 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -568,7 +568,7 @@ struct TimetableWindow : GeneralVehicleWindow { this->SetWidgetDisabledState(WID_VT_START_DATE, v->orders == nullptr || HasBit(v->vehicle_flags, VF_TIMETABLE_SEPARATION) || HasBit(v->vehicle_flags, VF_SCHEDULED_DISPATCH)); this->SetWidgetDisabledState(WID_VT_RESET_LATENESS, v->orders == nullptr); this->SetWidgetDisabledState(WID_VT_AUTOFILL, v->orders == nullptr || HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE)); - this->SetWidgetDisabledState(WID_VT_AUTO_SEPARATION, HasBit(v->vehicle_flags, VF_SCHEDULED_DISPATCH)); + this->SetWidgetDisabledState(WID_VT_AUTO_SEPARATION, HasBit(v->vehicle_flags, VF_SCHEDULED_DISPATCH) || v->HasUnbunchingOrder()); this->EnableWidget(WID_VT_AUTOMATE); this->EnableWidget(WID_VT_ADD_VEH_GROUP); this->SetWidgetDisabledState(WID_VT_LOCK_ORDER_TIME, !wait_lockable); @@ -643,6 +643,21 @@ struct TimetableWindow : GeneralVehicleWindow { } return false; } + case WID_VT_AUTO_SEPARATION: { + if (HasBit(this->vehicle->vehicle_flags, VF_SCHEDULED_DISPATCH)) { + SetDParam(0, STR_TIMETABLE_AUTO_SEPARATION_TOOLTIP); + SetDParam(1, STR_CANNOT_ENABLE_BECAUSE_SCHED_DISPATCH); + GuiShowTooltips(this, STR_TOOLTIP_SEPARATION_CANNOT_ENABLE, close_cond, 2); + } else if (this->vehicle->HasUnbunchingOrder()) { + SetDParam(0, STR_TIMETABLE_AUTO_SEPARATION_TOOLTIP); + SetDParam(1, STR_CANNOT_ENABLE_BECAUSE_UNBUNCHING); + GuiShowTooltips(this, STR_TOOLTIP_SEPARATION_CANNOT_ENABLE, close_cond, 2); + } else { + GuiShowTooltips(this, STR_TIMETABLE_AUTO_SEPARATION_TOOLTIP, close_cond); + } + return true; + } + default: return false; } @@ -1206,7 +1221,7 @@ static constexpr NWidgetPart _nested_timetable_widgets[] = { EndContainer(), NWidget(NWID_VERTICAL, NC_EQUALSIZE), NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_VT_AUTOMATE), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_TIMETABLE_AUTOMATE, STR_TIMETABLE_AUTOMATE_TOOLTIP), - NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_VT_AUTO_SEPARATION), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_TIMETABLE_AUTO_SEPARATION, STR_TIMETABLE_AUTO_SEPARATION_TOOLTIP), + NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_VT_AUTO_SEPARATION), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_TIMETABLE_AUTO_SEPARATION, STR_NULL), NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_VT_EXTRA), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_TIMETABLE_EXTRA_DROP_DOWN, STR_TIMETABLE_EXTRA_DROP_DOWN_TOOLTIP), EndContainer(), NWidget(NWID_VERTICAL, NC_EQUALSIZE),