Fix manual setting of conditional order jump taken travel times

This commit is contained in:
Jonathan G Rennison
2022-01-15 15:33:34 +00:00
parent 1ac6326306
commit 91ed26415e
4 changed files with 14 additions and 7 deletions

View File

@@ -477,7 +477,7 @@ public:
/** Set if the wait time is fixed */ /** Set if the wait time is fixed */
inline void SetWaitFixed(bool fixed) inline void SetWaitFixed(bool fixed)
{ {
if (!this->IsType(OT_CONDITIONAL) && fixed != this->IsWaitFixed()) SB(this->GetXFlagsRef(), 1, 1, fixed ? 1 : 0); if (fixed != this->IsWaitFixed()) SB(this->GetXFlagsRef(), 1, 1, fixed ? 1 : 0);
} }
/** Does this order have a fixed travel time? */ /** Does this order have a fixed travel time? */

View File

@@ -1029,7 +1029,7 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
} }
} }
if (timetable && order->GetWaitTime() > 0) { if (timetable && (order->IsWaitTimetabled() || order->GetWaitTime() > 0)) {
SetDParam(7, order->IsWaitTimetabled() ? STR_TIMETABLE_AND_TRAVEL_FOR : STR_TIMETABLE_AND_TRAVEL_FOR_ESTIMATED); SetDParam(7, order->IsWaitTimetabled() ? STR_TIMETABLE_AND_TRAVEL_FOR : STR_TIMETABLE_AND_TRAVEL_FOR_ESTIMATED);
SetTimetableParams(8, order->GetWaitTime()); SetTimetableParams(8, order->GetWaitTime());
} else { } else {
@@ -1064,7 +1064,7 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
edge = DrawString(rtl ? left : edge + 3, rtl ? edge - 3 : right, y, str, colour); edge = DrawString(rtl ? left : edge + 3, rtl ? edge - 3 : right, y, str, colour);
} }
if (timetable && timetable_wait_time_valid && order->IsWaitFixed() && edge != 0) { if (timetable && (timetable_wait_time_valid || order->IsType(OT_CONDITIONAL)) && order->IsWaitFixed() && edge != 0) {
Dimension lock_d = GetSpriteSize(SPR_LOCK); Dimension lock_d = GetSpriteSize(SPR_LOCK);
DrawPixelInfo tmp_dpi; DrawPixelInfo tmp_dpi;
if (FillDrawPixelInfo(&tmp_dpi, rtl ? left : middle, y, rtl ? middle - left : right - middle, lock_d.height)) { if (FillDrawPixelInfo(&tmp_dpi, rtl ? left : middle, y, rtl ? middle - left : right - middle, lock_d.height)) {

View File

@@ -264,8 +264,8 @@ CommandCost CmdChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, u
} }
if (travel_time != order->GetTravelTime() && order->IsType(OT_CONDITIONAL)) return CMD_ERROR; if (travel_time != order->GetTravelTime() && order->IsType(OT_CONDITIONAL)) return CMD_ERROR;
if (travel_fixed != order->IsTravelFixed() && order->IsType(OT_CONDITIONAL)) return CMD_ERROR;
if (max_speed != order->GetMaxSpeed() && (order->IsType(OT_CONDITIONAL) || v->type == VEH_AIRCRAFT)) return CMD_ERROR; if (max_speed != order->GetMaxSpeed() && (order->IsType(OT_CONDITIONAL) || v->type == VEH_AIRCRAFT)) return CMD_ERROR;
if (wait_fixed != order->IsWaitFixed() && order->IsType(OT_CONDITIONAL)) return CMD_ERROR;
if (leave_type != order->GetLeaveType() && order->IsType(OT_CONDITIONAL)) return CMD_ERROR; if (leave_type != order->GetLeaveType() && order->IsType(OT_CONDITIONAL)) return CMD_ERROR;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {

View File

@@ -477,6 +477,7 @@ struct TimetableWindow : GeneralVehicleWindow {
if (v->owner == _local_company) { if (v->owner == _local_company) {
bool disable = true; bool disable = true;
bool disable_time = true;
bool wait_lockable = false; bool wait_lockable = false;
bool wait_locked = false; bool wait_locked = false;
bool clearable_when_wait_locked = false; bool clearable_when_wait_locked = false;
@@ -485,6 +486,7 @@ struct TimetableWindow : GeneralVehicleWindow {
if (selected % 2 == 1) { if (selected % 2 == 1) {
/* Travel time */ /* Travel time */
disable = order != nullptr && (order->IsType(OT_CONDITIONAL) || order->IsType(OT_IMPLICIT)); disable = order != nullptr && (order->IsType(OT_CONDITIONAL) || order->IsType(OT_IMPLICIT));
disable_time = disable;
wait_lockable = !disable; wait_lockable = !disable;
wait_locked = wait_lockable && order->IsTravelFixed(); wait_locked = wait_lockable && order->IsTravelFixed();
} else { } else {
@@ -492,24 +494,29 @@ struct TimetableWindow : GeneralVehicleWindow {
if (order != nullptr) { if (order != nullptr) {
if (order->IsType(OT_GOTO_WAYPOINT)) { if (order->IsType(OT_GOTO_WAYPOINT)) {
disable = false; disable = false;
disable_time = false;
clearable_when_wait_locked = true; clearable_when_wait_locked = true;
} else if (order->IsType(OT_CONDITIONAL)) { } else if (order->IsType(OT_CONDITIONAL)) {
disable = true; disable = true;
disable_time = false;
clearable_when_wait_locked = true;
} else { } else {
disable = (!(order->IsType(OT_GOTO_STATION) || (order->IsType(OT_GOTO_DEPOT) && !(order->GetDepotActionType() & ODATFB_HALT))) || disable = (!(order->IsType(OT_GOTO_STATION) || (order->IsType(OT_GOTO_DEPOT) && !(order->GetDepotActionType() & ODATFB_HALT))) ||
(order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION)); (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION));
disable_time = disable;
} }
} else { } else {
disable = true; disable = true;
disable_time = true;
} }
wait_lockable = !disable; wait_lockable = !disable_time;
wait_locked = wait_lockable && order->IsWaitFixed(); wait_locked = wait_lockable && order->IsWaitFixed();
} }
} }
bool disable_speed = disable || selected % 2 != 1 || v->type == VEH_AIRCRAFT; bool disable_speed = disable || selected % 2 != 1 || v->type == VEH_AIRCRAFT;
this->SetWidgetDisabledState(WID_VT_CHANGE_TIME, disable || (HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE) && !wait_locked)); this->SetWidgetDisabledState(WID_VT_CHANGE_TIME, disable_time || (HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE) && !wait_locked));
this->SetWidgetDisabledState(WID_VT_CLEAR_TIME, disable || (HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE) && !(wait_locked && clearable_when_wait_locked))); this->SetWidgetDisabledState(WID_VT_CLEAR_TIME, disable_time || (HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE) && !(wait_locked && clearable_when_wait_locked)));
this->SetWidgetDisabledState(WID_VT_CHANGE_SPEED, disable_speed); this->SetWidgetDisabledState(WID_VT_CHANGE_SPEED, disable_speed);
this->SetWidgetDisabledState(WID_VT_CLEAR_SPEED, disable_speed); this->SetWidgetDisabledState(WID_VT_CLEAR_SPEED, disable_speed);
this->SetWidgetDisabledState(WID_VT_SHARED_ORDER_LIST, !(v->IsOrderListShared() || _settings_client.gui.enable_single_veh_shared_order_gui)); this->SetWidgetDisabledState(WID_VT_SHARED_ORDER_LIST, !(v->IsOrderListShared() || _settings_client.gui.enable_single_veh_shared_order_gui));