Mercurial > hg > openttd
changeset 8883:23eea6824c4b draft
(svn r12650) -Feature: ability to force a vehicle to not load at a station.
-Feature: ability to force a vehicle to not unload at a station.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Thu, 10 Apr 2008 10:18:03 +0000 |
parents | 1e7420035d21 |
children | a91183e5f458 |
files | src/economy.cpp src/lang/english.txt src/order_cmd.cpp src/order_gui.cpp src/order_type.h |
diffstat | 5 files changed, 70 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/economy.cpp +++ b/src/economy.cpp @@ -1473,7 +1473,7 @@ 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 @@ 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 @@ } /* 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;
--- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -2661,6 +2661,10 @@ 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)
--- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -796,12 +796,14 @@ 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 @@ 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 @@ 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:
--- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -107,6 +107,12 @@ 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 @@ 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 @@ * @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 @@ 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_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 @@ 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 @@ 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 @@ { 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 @@ { 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
--- a/src/order_type.h +++ b/src/order_type.h @@ -53,6 +53,7 @@ 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. }; /**