mirror of https://github.com/OpenTTD/OpenTTD
(svn r12595) -Codechange: hide Order's flags in the last few cases.
parent
c0a5fa9eea
commit
d90a041230
|
@ -28,6 +28,7 @@ private:
|
||||||
friend const struct SaveLoad *GetOrderDescription(); ///< Saving and loading of orders.
|
friend const struct SaveLoad *GetOrderDescription(); ///< Saving and loading of orders.
|
||||||
|
|
||||||
OrderTypeByte type; ///< The type of order
|
OrderTypeByte type; ///< The type of order
|
||||||
|
uint8 flags; ///< 'Sub'type of order
|
||||||
DestinationID dest; ///< The destination of the order.
|
DestinationID dest; ///< The destination of the order.
|
||||||
|
|
||||||
CargoID refit_cargo; ///< Refit CargoID
|
CargoID refit_cargo; ///< Refit CargoID
|
||||||
|
@ -36,8 +37,6 @@ private:
|
||||||
public:
|
public:
|
||||||
Order *next; ///< Pointer to next order. If NULL, end of list
|
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 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.
|
uint16 travel_time; ///< How long in ticks the journey to this destination should take.
|
||||||
|
|
||||||
|
|
|
@ -302,10 +302,12 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
default: return CMD_ERROR;
|
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:
|
/* Order flags can be any of the following for stations:
|
||||||
* [full-load | unload] [+ transfer] [+ non-stop]
|
* [full-load | unload] [+ transfer] [+ non-stop]
|
||||||
* non-stop orders (if any) are only valid for trains */
|
* non-stop orders (if any) are only valid for trains */
|
||||||
switch (new_order.flags) {
|
switch (new_order.GetLoadType() | new_order.GetUnloadType()) {
|
||||||
case 0:
|
case 0:
|
||||||
case OFB_FULL_LOAD:
|
case OFB_FULL_LOAD:
|
||||||
case OFB_FULL_LOAD | OFB_TRANSFER:
|
case OFB_FULL_LOAD | OFB_TRANSFER:
|
||||||
|
@ -314,15 +316,6 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
case OFB_TRANSFER:
|
case OFB_TRANSFER:
|
||||||
break;
|
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;
|
default: return CMD_ERROR;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -364,19 +357,16 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 flags can be any of the following for depots:
|
||||||
* order [+ halt] [+ non-stop]
|
* order [+ halt] [+ non-stop]
|
||||||
* non-stop orders (if any) are only valid for trains */
|
* 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:
|
||||||
case OFB_PART_OF_ORDERS | OFB_HALT_IN_DEPOT:
|
case OFB_PART_OF_ORDERS | OFB_HALT_IN_DEPOT:
|
||||||
break;
|
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;
|
default: return CMD_ERROR;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -769,18 +759,22 @@ CommandCost CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
switch (p2) {
|
switch (p2) {
|
||||||
case OF_FULL_LOAD:
|
case OF_FULL_LOAD:
|
||||||
ToggleBit(order->flags, OF_FULL_LOAD);
|
if (order->IsType(OT_GOTO_DEPOT)) {
|
||||||
if (!order->IsType(OT_GOTO_DEPOT)) ClrBit(order->flags, OF_UNLOAD);
|
order->SetDepotOrderType(order->GetDepotOrderType() ^ OFB_SERVICE_IF_NEEDED);
|
||||||
|
} else {
|
||||||
|
order->SetLoadType(order->GetUnloadType() ^ OFB_FULL_LOAD);
|
||||||
|
order->SetUnloadType(order->GetUnloadType() & ~OFB_UNLOAD);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case OF_UNLOAD:
|
case OF_UNLOAD:
|
||||||
ToggleBit(order->flags, OF_UNLOAD);
|
order->SetUnloadType(order->GetUnloadType() ^ OFB_UNLOAD);
|
||||||
ClrBit(order->flags, OF_FULL_LOAD);
|
order->SetLoadType(0);
|
||||||
break;
|
break;
|
||||||
case OF_NON_STOP:
|
case OF_NON_STOP:
|
||||||
ToggleBit(order->flags, OF_NON_STOP);
|
order->SetNonStopType(order->GetNonStopType() ^ OFB_NON_STOP);
|
||||||
break;
|
break;
|
||||||
case OF_TRANSFER:
|
case OF_TRANSFER:
|
||||||
ToggleBit(order->flags, OF_TRANSFER);
|
order->SetUnloadType(order->GetUnloadType() ^ OFB_TRANSFER);
|
||||||
break;
|
break;
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,22 +91,22 @@ static int GetOrderFromOrderWndPt(Window *w, int y, const Vehicle *v)
|
||||||
return (sel <= v->num_orders && sel >= 0) ? sel : INVALID_ORDER;
|
return (sel <= v->num_orders && sel >= 0) ? sel : INVALID_ORDER;
|
||||||
}
|
}
|
||||||
|
|
||||||
static StringID StationOrderStrings[] = {
|
static StringID _station_order_strings[][7] = {
|
||||||
|
{
|
||||||
STR_8806_GO_TO,
|
STR_8806_GO_TO,
|
||||||
STR_GO_TO_TRANSFER,
|
STR_GO_TO_TRANSFER,
|
||||||
STR_8807_GO_TO_UNLOAD,
|
STR_8807_GO_TO_UNLOAD,
|
||||||
STR_GO_TO_TRANSFER_UNLOAD,
|
STR_GO_TO_TRANSFER_UNLOAD,
|
||||||
STR_8808_GO_TO_LOAD,
|
STR_8808_GO_TO_LOAD,
|
||||||
STR_GO_TO_TRANSFER_LOAD,
|
STR_GO_TO_TRANSFER_LOAD
|
||||||
STR_NULL,
|
}, {
|
||||||
STR_NULL,
|
|
||||||
STR_880A_GO_NON_STOP_TO,
|
STR_880A_GO_NON_STOP_TO,
|
||||||
STR_GO_TO_NON_STOP_TRANSFER,
|
STR_GO_TO_NON_STOP_TRANSFER,
|
||||||
STR_880B_GO_NON_STOP_TO_UNLOAD,
|
STR_880B_GO_NON_STOP_TO_UNLOAD,
|
||||||
STR_GO_TO_NON_STOP_TRANSFER_UNLOAD,
|
STR_GO_TO_NON_STOP_TRANSFER_UNLOAD,
|
||||||
STR_880C_GO_NON_STOP_TO_LOAD,
|
STR_880C_GO_NON_STOP_TO_LOAD,
|
||||||
STR_GO_TO_NON_STOP_TRANSFER_LOAD,
|
STR_GO_TO_NON_STOP_TRANSFER_LOAD
|
||||||
STR_NULL
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static void DrawOrdersWindow(Window *w)
|
static void DrawOrdersWindow(Window *w)
|
||||||
|
@ -201,7 +201,7 @@ static void DrawOrdersWindow(Window *w)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OT_GOTO_STATION:
|
case OT_GOTO_STATION:
|
||||||
SetDParam(1, StationOrderStrings[order->flags]);
|
SetDParam(1, _station_order_strings[!!order->GetNonStopType()][order->GetLoadType() | order->GetUnloadType()]);
|
||||||
SetDParam(2, order->GetDestination());
|
SetDParam(2, order->GetDestination());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue