summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/economy.cpp6
-rw-r--r--src/lang/english.txt4
-rw-r--r--src/order_cmd.cpp21
-rw-r--r--src/order_gui.cpp52
-rw-r--r--src/order_type.h1
5 files changed, 70 insertions, 14 deletions
diff --git a/src/economy.cpp b/src/economy.cpp
index 53115d448..34448af5f 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -1473,7 +1473,7 @@ void VehiclePayment(Vehicle *front_v)
for (Vehicle *v = front_v; v != NULL; v = v->Next()) {
/* No cargo to unload */
- if (v->cargo_cap == 0 || v->cargo.Empty()) continue;
+ if (v->cargo_cap == 0 || v->cargo.Empty() || front_v->current_order.GetUnloadType() & OUFB_NO_UNLOAD) continue;
/* All cargo has already been paid for, no need to pay again */
if (!v->cargo.UnpaidCargo()) {
@@ -1599,7 +1599,7 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
GoodsEntry *ge = &st->goods[v->cargo_type];
- if (HasBit(v->vehicle_flags, VF_CARGO_UNLOADING)) {
+ if (HasBit(v->vehicle_flags, VF_CARGO_UNLOADING) && (u->current_order.GetUnloadType() & OUFB_NO_UNLOAD) == 0) {
uint cargo_count = v->cargo.Count();
uint amount_unloaded = _patches.gradual_loading ? min(cargo_count, load_amount) : cargo_count;
bool remaining; // Are there cargo entities in this vehicle that can still be unloaded here?
@@ -1638,7 +1638,7 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
}
/* Do not pick up goods that we unloaded */
- if (u->current_order.GetUnloadType() & OUFB_UNLOAD) continue;
+ if ((u->current_order.GetUnloadType() & OUFB_UNLOAD) || (u->current_order.GetLoadType() & OLFB_NO_LOAD)) continue;
/* update stats */
int t;
diff --git a/src/lang/english.txt b/src/lang/english.txt
index e6eabe2f7..91514e57e 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -2661,6 +2661,10 @@ STR_ORDER_GO_NON_STOP_VIA :Go non-stop via
STR_ORDER_DROP_LOAD_IF_POSSIBLE :Load if available
STR_ORDER_DROP_FULL_LOAD_ALL :Full load all cargo
STR_ORDER_DROP_FULL_LOAD_ANY :Full load any cargo
+STR_ORDER_DROP_NO_LOADING :No loading
+STR_ORDER_DROP_UNLOAD_IF_ACCEPTED :Unload if accepted
+STR_ORDER_DROP_UNLOAD :Unload all
+STR_ORDER_DROP_NO_UNLOADING :No unloading
STR_ORDER_UNLOAD :(Unload)
STR_ORDER_FULL_LOAD :(Full load)
STR_ORDER_FULL_LOAD_ANY :(Full load any cargo)
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index 60064fae0..f9a3b0618 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -796,12 +796,14 @@ CommandCost CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
break;
case MOF_UNLOAD:
- if ((data & ~(OUFB_UNLOAD | OUFB_TRANSFER)) != 0) return CMD_ERROR;
+ if ((data & ~(OUFB_UNLOAD | OUFB_TRANSFER | OUFB_NO_UNLOAD)) != 0) return CMD_ERROR;
+ /* Unload and no-unload are mutual exclusive and so are transfer and no unload. */
+ if (data != 0 && ((data & (OUFB_UNLOAD | OUFB_TRANSFER)) != 0) == ((data & OUFB_NO_UNLOAD) != 0)) return CMD_ERROR;
if (data == order->GetUnloadType()) return CMD_ERROR;
break;
case MOF_LOAD:
- if (data > OLF_FULL_LOAD_ANY || data == 1) return CMD_ERROR;
+ if (data > OLFB_NO_LOAD || data == 1) return CMD_ERROR;
if (data == order->GetLoadType()) return CMD_ERROR;
break;
@@ -822,6 +824,12 @@ CommandCost CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if ((data & OUFB_UNLOAD) != 0) {
order->SetLoadType((OrderLoadFlags)(order->GetLoadType() & ~(OLFB_FULL_LOAD | OLF_FULL_LOAD_ANY)));
}
+ if ((data & (OUFB_NO_UNLOAD | OUFB_TRANSFER)) != 0) {
+ if ((order->GetLoadType() & OLFB_NO_LOAD) != 0 && (data & OUFB_TRANSFER) != 0) {
+ order->SetUnloadType((OrderUnloadFlags)(data | OUFB_UNLOAD));
+ }
+ order->SetLoadType((OrderLoadFlags)(order->GetLoadType() & ~OLFB_NO_LOAD));
+ }
break;
case MOF_LOAD:
@@ -830,6 +838,15 @@ CommandCost CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if ((data & OLFB_FULL_LOAD) != 0) {
order->SetUnloadType((OrderUnloadFlags)(order->GetUnloadType() & ~OUFB_UNLOAD));
}
+ if ((data & OLFB_NO_LOAD) != 0) {
+ if ((order->GetUnloadType() & OUFB_TRANSFER) != 0) {
+ /* No load + transfer == unload + transfer */
+ order->SetUnloadType((OrderUnloadFlags)(order->GetUnloadType() | OUFB_UNLOAD));
+ order->SetLoadType((OrderLoadFlags)(data & ~OLFB_NO_LOAD));
+ } else {
+ order->SetUnloadType((OrderUnloadFlags)(order->GetUnloadType() & ~OUFB_NO_UNLOAD));
+ }
+ }
break;
case MOF_DEPOT_ACTION:
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index d82b8a902..54d837ecd 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -107,6 +107,12 @@ static const StringID _station_load_types[][5] = {
STR_ORDER_TRANSFER_FULL_LOAD,
STR_ORDER_TRANSFER_FULL_LOAD_ANY,
INVALID_STRING_ID,
+ }, {
+ STR_ORDER_NO_UNLOAD,
+ INVALID_STRING_ID,
+ STR_ORDER_NO_UNLOAD_FULL_LOAD,
+ STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY,
+ INVALID_STRING_ID,
}
};
@@ -412,7 +418,8 @@ static void OrderClick_FullLoad(Window *w, const Vehicle *v, int load_type)
switch (order->GetLoadType()) {
case OLF_LOAD_IF_POSSIBLE: load_type = OLFB_FULL_LOAD; break;
case OLFB_FULL_LOAD: load_type = OLF_FULL_LOAD_ANY; break;
- case OLF_FULL_LOAD_ANY: load_type = OLF_LOAD_IF_POSSIBLE; break;
+ case OLF_FULL_LOAD_ANY: load_type = OLFB_NO_LOAD; break;
+ case OLFB_NO_LOAD: load_type = OLF_LOAD_IF_POSSIBLE; break;
default: NOT_REACHED();
}
}
@@ -436,12 +443,24 @@ static void OrderClick_Service(Window *w, const Vehicle *v, int i)
* @param w current window
* @param v current vehicle
*/
-static void OrderClick_Unload(Window *w, const Vehicle *v, int i)
+static void OrderClick_Unload(Window *w, const Vehicle *v, int unload_type)
{
VehicleOrderID sel_ord = OrderGetSel(w);
const Order *order = GetVehicleOrder(v, sel_ord);
- DoCommandP(v->tile, v->index + (sel_ord << 16), MOF_UNLOAD | (order->GetUnloadType() ^ OUFB_UNLOAD) << 2, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
+ if (unload_type < 0) {
+ switch (order->GetUnloadType()) {
+ case OUF_UNLOAD_IF_POSSIBLE: unload_type = OUFB_UNLOAD; break;
+ case OUFB_UNLOAD: unload_type = OUFB_NO_UNLOAD; break;
+ case OUFB_NO_UNLOAD: unload_type = OUF_UNLOAD_IF_POSSIBLE; break;
+ default: NOT_REACHED();
+ }
+ }
+
+ if ((order->GetUnloadType() & OUFB_TRANSFER) != 0 && unload_type != OUFB_NO_UNLOAD) unload_type |= OUFB_TRANSFER;
+ if (order->GetUnloadType() == unload_type) return;
+
+ DoCommandP(v->tile, v->index + (sel_ord << 16), MOF_UNLOAD | (unload_type << 2), NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
}
/**
@@ -477,7 +496,7 @@ static void OrderClick_Transfer(Window *w, const Vehicle *v, int i)
VehicleOrderID sel_ord = OrderGetSel(w);
const Order *order = GetVehicleOrder(v, sel_ord);
- DoCommandP(v->tile, v->index + (sel_ord << 16), MOF_UNLOAD | (order->GetUnloadType() ^ OUFB_TRANSFER) << 2, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
+ DoCommandP(v->tile, v->index + (sel_ord << 16), MOF_UNLOAD | ((order->GetUnloadType() & ~OUFB_NO_UNLOAD) ^ OUFB_TRANSFER) << 2, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
}
/**
@@ -564,8 +583,19 @@ static const StringID _order_non_stop_drowdown[] = {
static const StringID _order_full_load_drowdown[] = {
STR_ORDER_DROP_LOAD_IF_POSSIBLE,
+ STR_EMPTY,
STR_ORDER_DROP_FULL_LOAD_ALL,
STR_ORDER_DROP_FULL_LOAD_ANY,
+ STR_ORDER_DROP_NO_LOADING,
+ INVALID_STRING_ID
+};
+
+static const StringID _order_unload_drowdown[] = {
+ STR_ORDER_DROP_UNLOAD_IF_ACCEPTED,
+ STR_ORDER_DROP_UNLOAD,
+ STR_EMPTY,
+ STR_EMPTY,
+ STR_ORDER_DROP_NO_UNLOADING,
INVALID_STRING_ID
};
@@ -664,11 +694,11 @@ static void OrdersWndProc(Window *w, WindowEvent *e)
break;
case ORDER_WIDGET_FULL_LOAD:
- ShowDropDownMenu(w, _order_full_load_drowdown, GetVehicleOrder(v, OrderGetSel(w))->GetLoadType() << 2, ORDER_WIDGET_FULL_LOAD, 0, 0, 124);
+ ShowDropDownMenu(w, _order_full_load_drowdown, GetVehicleOrder(v, OrderGetSel(w))->GetLoadType(), ORDER_WIDGET_FULL_LOAD, 0, 2, 124);
break;
case ORDER_WIDGET_UNLOAD:
- OrderClick_Unload(w, v, 0);
+ ShowDropDownMenu(w, _order_unload_drowdown, GetVehicleOrder(v, OrderGetSel(w))->GetUnloadType(), ORDER_WIDGET_UNLOAD, 0, 12, 124);
break;
case ORDER_WIDGET_REFIT:
@@ -700,7 +730,11 @@ static void OrdersWndProc(Window *w, WindowEvent *e)
break;
case ORDER_WIDGET_FULL_LOAD:
- OrderClick_FullLoad(w, v, e->we.dropdown.index == 0 ? 0 : e->we.dropdown.index + 1);
+ OrderClick_FullLoad(w, v, e->we.dropdown.index);
+ break;
+
+ case ORDER_WIDGET_UNLOAD:
+ OrderClick_Unload(w, v, e->we.dropdown.index);
break;
}
break;
@@ -810,7 +844,7 @@ static const Widget _orders_train_widgets[] = {
{ WWT_DROPDOWN, RESIZE_TB, 14, 0, 92, 76, 87, STR_8825_NON_STOP, STR_8855_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_NON_STOP
{ WWT_TEXTBTN, RESIZE_TB, 14, 248, 371, 88, 99, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE}, // ORDER_WIDGET_GOTO
{ WWT_DROPDOWN, RESIZE_TB, 14, 93, 185, 76, 87, STR_8827_FULL_LOAD, STR_8857_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_FULL_LOAD
- { WWT_PUSHTXTBTN, RESIZE_TB, 14, 186, 278, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_UNLOAD
+ { WWT_DROPDOWN, RESIZE_TB, 14, 186, 278, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_UNLOAD
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 186, 278, 76, 87, STR_REFIT, STR_REFIT_TIP}, // ORDER_WIDGET_REFIT
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 279, 371, 76, 87, STR_TRANSFER, STR_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_TRANSFER
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 279, 371, 76, 87, STR_SERVICE, STR_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_SERVICE
@@ -847,7 +881,7 @@ static const Widget _orders_widgets[] = {
{ WWT_EMPTY, RESIZE_TB, 14, 0, 0, 76, 87, 0x0, 0x0}, // ORDER_WIDGET_NON_STOP
{ WWT_TEXTBTN, RESIZE_TB, 14, 248, 371, 88, 99, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE}, // ORDER_WIDGET_GOTO
{ WWT_DROPDOWN, RESIZE_TB, 14, 0, 123, 76, 87, STR_8827_FULL_LOAD, STR_8857_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_FULL_LOAD
- { WWT_PUSHTXTBTN, RESIZE_TB, 14, 124, 247, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_UNLOAD
+ { WWT_DROPDOWN, RESIZE_TB, 14, 124, 247, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_UNLOAD
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 124, 247, 76, 87, STR_REFIT, STR_REFIT_TIP}, // ORDER_WIDGET_REFIT
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 248, 372, 76, 87, STR_TRANSFER, STR_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_TRANSFER
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 248, 372, 76, 87, STR_SERVICE, STR_NULL}, // ORDER_WIDGET_SERVICE
diff --git a/src/order_type.h b/src/order_type.h
index 24fd1fc20..b2d3ac67e 100644
--- a/src/order_type.h
+++ b/src/order_type.h
@@ -53,6 +53,7 @@ enum OrderLoadFlags {
OLF_LOAD_IF_POSSIBLE = 0, ///< Load as long as there is cargo that fits in the train.
OLFB_FULL_LOAD = 1 << 1, ///< Full load the complete the consist.
OLF_FULL_LOAD_ANY = 3, ///< Full load the a single cargo of the consist.
+ OLFB_NO_LOAD = 4, ///< Do not load anything.
};
/**