summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lang/english.txt6
-rw-r--r--src/order_cmd.cpp26
-rw-r--r--src/order_gui.cpp56
-rw-r--r--src/order_type.h12
-rw-r--r--src/vehicle.cpp6
-rw-r--r--src/vehicle_gui.cpp2
6 files changed, 94 insertions, 14 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index cb892842c..63cd073ec 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -2754,6 +2754,10 @@ STR_GO_TO_DEPOT :{STRING} {TOWN}
STR_GO_TO_NEAREST_DEPOT :{STRING} {STRING} {STRING}
STR_GO_TO_HANGAR :{STRING} {STATION} Hangar
+STR_ORDER_DROP_GO_ALWAYS_DEPOT :Always go
+STR_ORDER_DROP_SERVICE_DEPOT :Service if needed
+STR_ORDER_DROP_HALT_DEPOT :Stop
+
STR_ORDER_CONDITIONAL :Conditional order jump
STR_ORDER_CONDITIONAL_VARIABLE_TOOLTIP :{BLACK}Vehicle data to base jumping on
STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP :{BLACK}How to compare the vehicle data to the given value
@@ -2824,6 +2828,8 @@ STR_8826_GO_TO :{BLACK}Go To
STR_REFIT :{BLACK}Refit
STR_REFIT_TIP :{BLACK}Select what cargo type to refit to in this order. Control click to remove refit instruction
STR_REFIT_ORDER :(Refit to {STRING})
+STR_REFIT_STOP_ORDER :(Refit to {STRING} and stop)
+STR_STOP_ORDER :(Stop)
STR_TIMETABLE_VIEW :{BLACK}Timetable
STR_TIMETABLE_VIEW_TOOLTIP :{BLACK}Switch to the timetable view
STR_ORDER_VIEW :{BLACK}Orders
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index cca67c8fd..6e67d7e83 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -906,7 +906,7 @@ CommandCost CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
break;
case MOF_DEPOT_ACTION:
- if (data != 0) return CMD_ERROR;
+ if (data >= DA_END) return CMD_ERROR;
break;
case MOF_COND_VARIABLE:
@@ -969,9 +969,27 @@ CommandCost CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
}
break;
- case MOF_DEPOT_ACTION:
- order->SetDepotOrderType((OrderDepotTypeFlags)(order->GetDepotOrderType() ^ ODTFB_SERVICE));
- break;
+ case MOF_DEPOT_ACTION: {
+ switch (data) {
+ case DA_ALWAYS_GO:
+ order->SetDepotOrderType((OrderDepotTypeFlags)(order->GetDepotOrderType() & ~ODTFB_SERVICE));
+ order->SetDepotActionType((OrderDepotActionFlags)(order->GetDepotActionType() & ~ODATFB_HALT));
+ break;
+
+ case DA_SERVICE:
+ order->SetDepotOrderType((OrderDepotTypeFlags)(order->GetDepotOrderType() | ODTFB_SERVICE));
+ order->SetDepotActionType((OrderDepotActionFlags)(order->GetDepotActionType() & ~ODATFB_HALT));
+ break;
+
+ case DA_STOP:
+ order->SetDepotOrderType((OrderDepotTypeFlags)(order->GetDepotOrderType() & ~ODTFB_SERVICE));
+ order->SetDepotActionType((OrderDepotActionFlags)(order->GetDepotActionType() | ODATFB_HALT));
+ break;
+
+ default:
+ NOT_REACHED();
+ }
+ } break;
case MOF_COND_VARIABLE: {
order->SetConditionVariable((OrderConditionVariable)data);
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index 9a60c4509..df6c91eb6 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -53,6 +53,7 @@ enum OrderWindowWidgets {
ORDER_WIDGET_UNLOAD_DROPDOWN,
ORDER_WIDGET_UNLOAD,
ORDER_WIDGET_REFIT,
+ ORDER_WIDGET_SERVICE_DROPDOWN,
ORDER_WIDGET_SERVICE,
ORDER_WIDGET_COND_VARIABLE,
ORDER_WIDGET_COND_COMPARATOR,
@@ -162,6 +163,23 @@ static const StringID _order_conditional_condition[] = {
extern uint ConvertSpeedToDisplaySpeed(uint speed);
extern uint ConvertDisplaySpeedToSpeed(uint speed);
+static const StringID _order_depot_action_dropdown[] = {
+ STR_ORDER_DROP_GO_ALWAYS_DEPOT,
+ STR_ORDER_DROP_SERVICE_DEPOT,
+ STR_ORDER_DROP_HALT_DEPOT,
+ INVALID_STRING_ID
+};
+
+static int DepotActionStringIndex(const Order *order)
+{
+ if (order->GetDepotActionType() & ODATFB_HALT) {
+ return DA_STOP;
+ } else if (order->GetDepotOrderType() & ODTFB_SERVICE) {
+ return DA_SERVICE;
+ } else {
+ return DA_ALWAYS_GO;
+ }
+}
void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int y, bool selected, bool timetable, int width)
{
@@ -227,8 +245,12 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
SetDParam(2, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_ORDER_GO_NON_STOP_TO : STR_ORDER_GO_TO);
}
+ if (!timetable && (order->GetDepotActionType() & ODATFB_HALT)) {
+ SetDParam(6, STR_STOP_ORDER);
+ }
+
if (!timetable && order->IsRefit()) {
- SetDParam(6, STR_REFIT_ORDER);
+ SetDParam(6, (order->GetDepotActionType() & ODATFB_HALT) ? STR_REFIT_STOP_ORDER : STR_REFIT_ORDER);
SetDParam(7, GetCargo(order->GetRefitCargo())->name);
}
break;
@@ -466,7 +488,14 @@ private:
*/
static void OrderClick_Service(OrdersWindow *w, int i)
{
- DoCommandP(w->vehicle->tile, w->vehicle->index + (w->OrderGetSel() << 16), MOF_DEPOT_ACTION, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
+ VehicleOrderID sel_ord = w->OrderGetSel();
+
+ if (i < 0) {
+ const Order *order = GetVehicleOrder(w->vehicle, sel_ord);
+ if (order == NULL) return;
+ i = (order->GetDepotOrderType() & ODTFB_SERVICE) ? DA_ALWAYS_GO : DA_SERVICE;
+ }
+ DoCommandP(w->vehicle->tile, w->vehicle->index + (sel_ord << 16), MOF_DEPOT_ACTION | (i << 4), NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
}
/**
@@ -690,9 +719,11 @@ public:
/* Disable list of vehicles with the same shared orders if there is no list */
this->SetWidgetDisabledState(ORDER_WIDGET_SHARED_ORDER_LIST, !shared_orders);
this->SetWidgetDisabledState(ORDER_WIDGET_REFIT, order == NULL); // Refit
- this->SetWidgetDisabledState(ORDER_WIDGET_SERVICE, order == NULL); // Refit
+ this->SetWidgetDisabledState(ORDER_WIDGET_SERVICE, order == NULL); // Service
+ this->SetWidgetDisabledState(ORDER_WIDGET_SERVICE_DROPDOWN, order == NULL); // Service
this->HideWidget(ORDER_WIDGET_REFIT); // Refit
this->HideWidget(ORDER_WIDGET_SERVICE); // Service
+ this->HideWidget(ORDER_WIDGET_SERVICE_DROPDOWN); // Service
this->HideWidget(ORDER_WIDGET_COND_VARIABLE);
this->HideWidget(ORDER_WIDGET_COND_COMPARATOR);
@@ -709,6 +740,7 @@ public:
this->RaiseWidget(ORDER_WIDGET_NON_STOP);
this->RaiseWidget(ORDER_WIDGET_FULL_LOAD);
this->RaiseWidget(ORDER_WIDGET_UNLOAD);
+ this->RaiseWidget(ORDER_WIDGET_SERVICE);
if (order != NULL) {
this->SetWidgetLoweredState(ORDER_WIDGET_NON_STOP, order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
@@ -735,6 +767,7 @@ public:
this->HideWidget(ORDER_WIDGET_FULL_LOAD_DROPDOWN);
this->HideWidget(ORDER_WIDGET_FULL_LOAD);
this->ShowWidget(ORDER_WIDGET_REFIT);
+ this->ShowWidget(ORDER_WIDGET_SERVICE_DROPDOWN);
this->ShowWidget(ORDER_WIDGET_SERVICE);
this->SetWidgetLoweredState(ORDER_WIDGET_SERVICE, order->GetDepotOrderType() & ODTFB_SERVICE);
break;
@@ -888,7 +921,11 @@ public:
break;
case ORDER_WIDGET_SERVICE:
- OrderClick_Service(this, 0);
+ OrderClick_Service(this, -1);
+ break;
+
+ case ORDER_WIDGET_SERVICE_DROPDOWN:
+ ShowDropDownMenu(this, _order_depot_action_dropdown, DepotActionStringIndex(GetVehicleOrder(this->vehicle, this->OrderGetSel())), ORDER_WIDGET_SERVICE_DROPDOWN, 0, 0);
break;
case ORDER_WIDGET_TIMETABLE_VIEW:
@@ -964,6 +1001,10 @@ public:
}
break;
+ case ORDER_WIDGET_SERVICE_DROPDOWN:
+ OrderClick_Service(this, index);
+ break;
+
case ORDER_WIDGET_COND_VARIABLE:
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 16), MOF_COND_VARIABLE | index << 4, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
break;
@@ -1115,7 +1156,8 @@ static const Widget _orders_train_widgets[] = {
{ WWT_DROPDOWN, RESIZE_TB, COLOUR_GREY, 248, 371, 76, 87, STR_NULL, STR_ORDER_TOOLTIP_UNLOAD}, // ORDER_WIDGET_UNLOAD_DROPDOWN
{ WWT_TEXTBTN, RESIZE_TB, COLOUR_GREY, 248, 359, 76, 87, STR_ORDER_TOGGLE_UNLOAD, STR_ORDER_TOOLTIP_UNLOAD}, // ORDER_WIDGET_UNLOAD
{ WWT_PUSHTXTBTN, RESIZE_TB, COLOUR_GREY, 124, 247, 76, 87, STR_REFIT, STR_REFIT_TIP}, // ORDER_WIDGET_REFIT
- { WWT_PUSHTXTBTN, RESIZE_TB, COLOUR_GREY, 248, 371, 76, 87, STR_SERVICE, STR_SERVICE_HINT}, // ORDER_WIDGET_SERVICE
+ { WWT_DROPDOWN, RESIZE_TB, COLOUR_GREY, 248, 371, 76, 87, STR_NULL, STR_SERVICE_HINT}, // ORDER_WIDGET_SERVICE_DROPDOWN
+ { WWT_TEXTBTN, RESIZE_TB, COLOUR_GREY, 248, 359, 76, 87, STR_SERVICE, STR_SERVICE_HINT}, // ORDER_WIDGET_SERVICE
{ WWT_DROPDOWN, RESIZE_TB, COLOUR_GREY, 0, 123, 76, 87, STR_NULL, STR_ORDER_CONDITIONAL_VARIABLE_TOOLTIP}, // ORDER_WIDGET_COND_VARIABLE
{ WWT_DROPDOWN, RESIZE_TB, COLOUR_GREY, 124, 247, 76, 87, STR_NULL, STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP}, // ORDER_WIDGET_COND_COMPARATOR
@@ -1158,7 +1200,8 @@ static const Widget _orders_widgets[] = {
{ WWT_DROPDOWN, RESIZE_TB, COLOUR_GREY, 186, 371, 76, 87, STR_NULL, STR_ORDER_TOOLTIP_UNLOAD}, // ORDER_WIDGET_UNLOAD_DROPDOWN
{ WWT_TEXTBTN, RESIZE_TB, COLOUR_GREY, 186, 359, 76, 87, STR_ORDER_TOGGLE_UNLOAD, STR_ORDER_TOOLTIP_UNLOAD}, // ORDER_WIDGET_UNLOAD
{ WWT_PUSHTXTBTN, RESIZE_TB, COLOUR_GREY, 0, 185, 76, 87, STR_REFIT, STR_REFIT_TIP}, // ORDER_WIDGET_REFIT
- { WWT_PUSHTXTBTN, RESIZE_TB, COLOUR_GREY, 186, 371, 76, 87, STR_SERVICE, STR_SERVICE_HINT}, // ORDER_WIDGET_SERVICE
+ { WWT_DROPDOWN, RESIZE_TB, COLOUR_GREY, 186, 371, 76, 87, STR_NULL, STR_SERVICE_HINT}, // ORDER_WIDGET_SERVICE_DROPDOWN
+ { WWT_TEXTBTN, RESIZE_TB, COLOUR_GREY, 186, 359, 76, 87, STR_SERVICE, STR_SERVICE_HINT}, // ORDER_WIDGET_SERVICE
{ WWT_DROPDOWN, RESIZE_TB, COLOUR_GREY, 0, 123, 76, 87, STR_NULL, STR_ORDER_CONDITIONAL_VARIABLE_TOOLTIP}, // ORDER_WIDGET_COND_VARIABLE
{ WWT_DROPDOWN, RESIZE_TB, COLOUR_GREY, 124, 247, 76, 87, STR_NULL, STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP}, // ORDER_WIDGET_COND_COMPARATOR
@@ -1201,6 +1244,7 @@ static const Widget _other_orders_widgets[] = {
{ WWT_EMPTY, RESIZE_NONE, COLOUR_GREY, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_UNLOAD_DROPDOWN
{ WWT_EMPTY, RESIZE_NONE, COLOUR_GREY, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_UNLOAD
{ WWT_EMPTY, RESIZE_NONE, COLOUR_GREY, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_REFIT
+ { WWT_EMPTY, RESIZE_NONE, COLOUR_GREY, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_SERVICE_DROPDOWN
{ WWT_EMPTY, RESIZE_NONE, COLOUR_GREY, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_SERVICE
{ WWT_EMPTY, RESIZE_NONE, COLOUR_GREY, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_COND_VARIABLE
diff --git a/src/order_type.h b/src/order_type.h
index 5ac9f89a1..3ffbdb6f1 100644
--- a/src/order_type.h
+++ b/src/order_type.h
@@ -122,7 +122,7 @@ enum ModifyOrderFlags {
MOF_NON_STOP, ///< Passes a OrderNonStopFlags.
MOF_UNLOAD, ///< Passes an OrderUnloadType.
MOF_LOAD, ///< Passes an OrderLoadType
- MOF_DEPOT_ACTION, ///< Toggle the 'service' if needed flag.
+ MOF_DEPOT_ACTION, ///< Selects the OrderDepotAction
MOF_COND_VARIABLE, ///< A conditional variable changes.
MOF_COND_COMPARATOR, ///< A comparator changes.
MOF_COND_VALUE, ///< The value to set the condition to.
@@ -130,6 +130,16 @@ enum ModifyOrderFlags {
MOF_END
};
+/**
+ * Depot action to switch to when doing a MOF_DEPOT_ACTION.
+ */
+enum OrderDepotAction {
+ DA_ALWAYS_GO, ///< Always go to the depot
+ DA_SERVICE, ///< Service only if needed
+ DA_STOP, ///< Go to the depot and stop there
+ DA_END
+};
+
/* Possible clone options */
enum {
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 1d1a5c4bf..f69951e89 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -725,9 +725,10 @@ void VehicleEnteredDepotThisTick(Vehicle *v)
{
/* We need to set v->leave_depot_instantly as we have no control of it's contents at this time.
* Vehicle should stop in the depot if it was in 'stopping' state - train intered depot while slowing down. */
- if (((v->current_order.GetDepotActionType() & ODATFB_HALT) && !(v->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS) && v->current_order.IsType(OT_GOTO_DEPOT)) ||
+ if (((v->current_order.GetDepotActionType() & ODATFB_HALT) && v->current_order.IsType(OT_GOTO_DEPOT)) ||
(v->vehstatus & VS_STOPPED)) {
/* we keep the vehicle in the depot since the user ordered it to stay */
+ v->vehstatus |= VS_STOPPED; // needed for refitting
v->leave_depot_instantly = false;
} else {
/* the vehicle do not plan on stopping in the depot, so we stop it to ensure that it will not reserve the path
@@ -1623,7 +1624,8 @@ void VehicleEnterDepot(Vehicle *v)
/* Part of orders */
UpdateVehicleTimetable(v, true);
v->cur_order_index++;
- } else if (t.GetDepotActionType() & ODATFB_HALT) {
+ }
+ if (t.GetDepotActionType() & ODATFB_HALT) {
/* Force depot visit */
v->vehstatus |= VS_STOPPED;
if (v->owner == _local_company) {
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index fb45c0901..5d913da1b 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -1913,7 +1913,7 @@ struct VehicleViewWindow : Window {
SetDParam(0, depot->town_index);
SetDParam(1, v->GetDisplaySpeed());
}
- if ((v->current_order.GetDepotActionType() & ODATFB_HALT) && !(v->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS)) {
+ if (v->current_order.GetDepotActionType() & ODATFB_HALT) {
str = _heading_for_depot_strings[v->type] + _settings_client.gui.vehicle_speed;
} else {
str = _heading_for_depot_service_strings[v->type] + _settings_client.gui.vehicle_speed;