Mercurial > hg > openttd
changeset 8845:bb04cb5677d8 draft
(svn r12595) -Codechange: hide Order's flags in the last few cases.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sun, 06 Apr 2008 21:54:22 +0000 |
parents | 7827dedcad92 |
children | 838e1d6a0321 |
files | src/order_base.h src/order_cmd.cpp src/order_gui.cpp |
diffstat | 3 files changed, 43 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
--- a/src/order_base.h +++ b/src/order_base.h @@ -28,6 +28,7 @@ friend const struct SaveLoad *GetOrderDescription(); ///< Saving and loading of orders. OrderTypeByte type; ///< The type of order + uint8 flags; ///< 'Sub'type of order DestinationID dest; ///< The destination of the order. CargoID refit_cargo; ///< Refit CargoID @@ -36,8 +37,6 @@ public: Order *next; ///< Pointer to next order. If NULL, end of list - uint8 flags; ///< 'Sub'type of order - uint16 wait_time; ///< How long in ticks to wait at the destination. uint16 travel_time; ///< How long in ticks the journey to this destination should take.
--- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -302,10 +302,12 @@ default: return CMD_ERROR; } + if (new_order.GetNonStopType() != OFB_NO_NON_STOP && v->type != VEH_TRAIN) return CMD_ERROR; + /* Order flags can be any of the following for stations: * [full-load | unload] [+ transfer] [+ non-stop] * non-stop orders (if any) are only valid for trains */ - switch (new_order.flags) { + switch (new_order.GetLoadType() | new_order.GetUnloadType()) { case 0: case OFB_FULL_LOAD: case OFB_FULL_LOAD | OFB_TRANSFER: @@ -314,15 +316,6 @@ case OFB_TRANSFER: break; - case OFB_NON_STOP: - case OFB_NON_STOP | OFB_FULL_LOAD: - case OFB_NON_STOP | OFB_FULL_LOAD | OFB_TRANSFER: - case OFB_NON_STOP | OFB_UNLOAD: - case OFB_NON_STOP | OFB_UNLOAD | OFB_TRANSFER: - case OFB_NON_STOP | OFB_TRANSFER: - if (v->type != VEH_TRAIN) return CMD_ERROR; - break; - default: return CMD_ERROR; } break; @@ -364,19 +357,16 @@ } } + if (new_order.GetNonStopType() != OFB_NO_NON_STOP && v->type != VEH_TRAIN) return CMD_ERROR; + /* Order flags can be any of the following for depots: * order [+ halt] [+ non-stop] * non-stop orders (if any) are only valid for trains */ - switch (new_order.flags) { + switch (new_order.GetDepotOrderType() | new_order.GetDepotActionType()) { case OFB_PART_OF_ORDERS: case OFB_PART_OF_ORDERS | OFB_HALT_IN_DEPOT: break; - case OFB_NON_STOP | OFB_PART_OF_ORDERS: - case OFB_NON_STOP | OFB_PART_OF_ORDERS | OFB_HALT_IN_DEPOT: - if (v->type != VEH_TRAIN) return CMD_ERROR; - break; - default: return CMD_ERROR; } break; @@ -768,21 +758,25 @@ if (flags & DC_EXEC) { switch (p2) { - case OF_FULL_LOAD: - ToggleBit(order->flags, OF_FULL_LOAD); - if (!order->IsType(OT_GOTO_DEPOT)) ClrBit(order->flags, OF_UNLOAD); - break; - case OF_UNLOAD: - ToggleBit(order->flags, OF_UNLOAD); - ClrBit(order->flags, OF_FULL_LOAD); - break; - case OF_NON_STOP: - ToggleBit(order->flags, OF_NON_STOP); - break; - case OF_TRANSFER: - ToggleBit(order->flags, OF_TRANSFER); - break; - default: NOT_REACHED(); + case OF_FULL_LOAD: + if (order->IsType(OT_GOTO_DEPOT)) { + order->SetDepotOrderType(order->GetDepotOrderType() ^ OFB_SERVICE_IF_NEEDED); + } else { + order->SetLoadType(order->GetUnloadType() ^ OFB_FULL_LOAD); + order->SetUnloadType(order->GetUnloadType() & ~OFB_UNLOAD); + } + break; + case OF_UNLOAD: + order->SetUnloadType(order->GetUnloadType() ^ OFB_UNLOAD); + order->SetLoadType(0); + break; + case OF_NON_STOP: + order->SetNonStopType(order->GetNonStopType() ^ OFB_NON_STOP); + break; + case OF_TRANSFER: + order->SetUnloadType(order->GetUnloadType() ^ OFB_TRANSFER); + break; + default: NOT_REACHED(); } /* Update the windows and full load flags, also for vehicles that share the same order list */
--- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -91,22 +91,22 @@ return (sel <= v->num_orders && sel >= 0) ? sel : INVALID_ORDER; } -static StringID StationOrderStrings[] = { - STR_8806_GO_TO, - STR_GO_TO_TRANSFER, - STR_8807_GO_TO_UNLOAD, - STR_GO_TO_TRANSFER_UNLOAD, - STR_8808_GO_TO_LOAD, - STR_GO_TO_TRANSFER_LOAD, - STR_NULL, - STR_NULL, - STR_880A_GO_NON_STOP_TO, - STR_GO_TO_NON_STOP_TRANSFER, - STR_880B_GO_NON_STOP_TO_UNLOAD, - STR_GO_TO_NON_STOP_TRANSFER_UNLOAD, - STR_880C_GO_NON_STOP_TO_LOAD, - STR_GO_TO_NON_STOP_TRANSFER_LOAD, - STR_NULL +static StringID _station_order_strings[][7] = { + { + STR_8806_GO_TO, + STR_GO_TO_TRANSFER, + STR_8807_GO_TO_UNLOAD, + STR_GO_TO_TRANSFER_UNLOAD, + STR_8808_GO_TO_LOAD, + STR_GO_TO_TRANSFER_LOAD + }, { + STR_880A_GO_NON_STOP_TO, + STR_GO_TO_NON_STOP_TRANSFER, + STR_880B_GO_NON_STOP_TO_UNLOAD, + STR_GO_TO_NON_STOP_TRANSFER_UNLOAD, + STR_880C_GO_NON_STOP_TO_LOAD, + STR_GO_TO_NON_STOP_TRANSFER_LOAD + } }; static void DrawOrdersWindow(Window *w) @@ -201,7 +201,7 @@ break; case OT_GOTO_STATION: - SetDParam(1, StationOrderStrings[order->flags]); + SetDParam(1, _station_order_strings[!!order->GetNonStopType()][order->GetLoadType() | order->GetUnloadType()]); SetDParam(2, order->GetDestination()); break;