summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lang/english.txt2
-rw-r--r--src/order_cmd.cpp4
-rw-r--r--src/order_gui.cpp7
-rw-r--r--src/timetable_cmd.cpp8
-rw-r--r--src/timetable_gui.cpp27
5 files changed, 32 insertions, 16 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 92f3a8121..b33e313bc 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -2738,9 +2738,11 @@ STR_CONDITIONAL_UNCONDITIONAL :Jump to order {
STR_CONDITIONAL_NUM :Jump to order {COMMA} when {STRING} {STRING} {COMMA}
STR_CONDITIONAL_TRUE_FALSE :Jump to order {COMMA} when {STRING} {STRING}
+STR_TIMETABLE_NO_TRAVEL :{SETX 30}No travel
STR_TIMETABLE_TRAVEL_NOT_TIMETABLED :{SETX 30}Travel (not timetabled)
STR_TIMETABLE_TRAVEL_FOR :{SETX 30}Travel for {STRING1}
STR_TIMETABLE_STAY_FOR :and stay for {STRING1}
+STR_TIMETABLE_AND_TRAVEL_FOR :and travel for {STRING1}
STR_TIMETABLE_DAYS :{COMMA} day{P "" s}
STR_TIMETABLE_TICKS :{COMMA} tick{P "" s}
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index b8bc5dd64..ac806225c 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -1694,10 +1694,12 @@ static bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_dept
case OT_CONDITIONAL: {
VehicleOrderID next_order = ProcessConditionalOrder(order, v);
- UpdateVehicleTimetable(v, true);
if (next_order != INVALID_VEH_ORDER_ID) {
+ UpdateVehicleTimetable(v, false);
v->cur_order_index = next_order;
+ v->current_order_time += GetVehicleOrder(v, next_order)->travel_time;
} else {
+ UpdateVehicleTimetable(v, true);
v->cur_order_index++;
}
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index c2ed05d8a..b52efac7a 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -251,6 +251,13 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
SetDParam(5, value);
}
+
+ if (timetable && order->wait_time > 0) {
+ SetDParam(6, STR_TIMETABLE_AND_TRAVEL_FOR);
+ SetTimetableParams(7, 8, order->wait_time);
+ } else {
+ SetDParam(6, STR_EMPTY);
+ }
break;
default: NOT_REACHED();
diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp
index 49384b03d..98c13a609 100644
--- a/src/timetable_cmd.cpp
+++ b/src/timetable_cmd.cpp
@@ -69,8 +69,10 @@ CommandCost CmdChangeTimetable(TileIndex tile, uint32 flags, uint32 p1, uint32 p
bool packed_time = HasBit(p1, 25);
bool is_journey = HasBit(p1, 24) || packed_time;
if (!is_journey) {
- if (!order->IsType(OT_GOTO_STATION)) return_cmd_error(STR_TIMETABLE_ONLY_WAIT_AT_STATIONS);
+ if (!order->IsType(OT_GOTO_STATION) && !order->IsType(OT_CONDITIONAL)) return_cmd_error(STR_TIMETABLE_ONLY_WAIT_AT_STATIONS);
if (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) return_cmd_error(STR_TIMETABLE_NOT_STOPPING_HERE);
+ } else {
+ if (order->IsType(OT_CONDITIONAL)) return CMD_ERROR;
}
if (flags & DC_EXEC) {
@@ -175,7 +177,9 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling)
* adjusted later by people who aren't. */
time_taken = (((time_taken - 1) / DAY_TICKS) + 1) * DAY_TICKS;
- ChangeTimetable(v, v->cur_order_index, time_taken, travelling);
+ if (!v->current_order.IsType(OT_CONDITIONAL)) {
+ ChangeTimetable(v, v->cur_order_index, time_taken, travelling);
+ }
return;
} else if (v->cur_order_index == 0) {
/* Otherwise if we're at the beginning and it already has a value,
diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp
index 14bb663ea..f39aed8ed 100644
--- a/src/timetable_gui.cpp
+++ b/src/timetable_gui.cpp
@@ -84,20 +84,19 @@ struct TimetableWindow : Window {
SetVScrollCount(this, v->num_orders * 2);
if (v->owner == _local_player) {
- if (selected == -1) {
- this->DisableWidget(TTV_CHANGE_TIME);
- this->DisableWidget(TTV_CLEAR_TIME);
- } else if (selected % 2 == 1) {
- this->EnableWidget(TTV_CHANGE_TIME);
- this->EnableWidget(TTV_CLEAR_TIME);
- } else {
+ bool disable = true;
+ if (selected != -1) {
const Order *order = GetVehicleOrder(v, (selected + 1) / 2);
- bool disable = order == NULL || !order->IsType(OT_GOTO_STATION) || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION);
-
- this->SetWidgetDisabledState(TTV_CHANGE_TIME, disable);
- this->SetWidgetDisabledState(TTV_CLEAR_TIME, disable);
+ if (selected % 2 == 1) {
+ disable = order != NULL && order->IsType(OT_CONDITIONAL);
+ } else {
+ disable = order == NULL || ((!order->IsType(OT_GOTO_STATION) || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION)) && !order->IsType(OT_CONDITIONAL));
+ }
}
+ this->SetWidgetDisabledState(TTV_CHANGE_TIME, disable);
+ this->SetWidgetDisabledState(TTV_CLEAR_TIME, disable);
+
this->EnableWidget(TTV_RESET_LATENESS);
this->EnableWidget(TTV_AUTOFILL);
} else {
@@ -137,7 +136,9 @@ struct TimetableWindow : Window {
} else {
StringID string;
- if (order->travel_time == 0) {
+ if (order->IsType(OT_CONDITIONAL)) {
+ string = STR_TIMETABLE_NO_TRAVEL;
+ } else if (order->travel_time == 0) {
string = STR_TIMETABLE_TRAVEL_NOT_TIMETABLED;
} else {
SetTimetableParams(0, 1, order->travel_time);
@@ -161,7 +162,7 @@ struct TimetableWindow : Window {
for (const Order *order = GetVehicleOrder(v, 0); order != NULL; order = order->next) {
total_time += order->travel_time + order->wait_time;
- if (order->travel_time == 0) complete = false;
+ if (order->travel_time == 0 && !order->IsType(OT_CONDITIONAL)) complete = false;
if (order->wait_time == 0 && order->IsType(OT_GOTO_STATION) && !(order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION)) complete = false;
}