Use p3 for order indices which don't fit into p1
Fix insert/modify order overflowing p1 Don't use text field for change timetable
This commit is contained in:
@@ -98,10 +98,10 @@ CommandProc CmdForceTrainProceed;
|
|||||||
CommandProc CmdReverseTrainDirection;
|
CommandProc CmdReverseTrainDirection;
|
||||||
|
|
||||||
CommandProc CmdClearOrderBackup;
|
CommandProc CmdClearOrderBackup;
|
||||||
CommandProc CmdModifyOrder;
|
CommandProcEx CmdModifyOrder;
|
||||||
CommandProc CmdSkipToOrder;
|
CommandProc CmdSkipToOrder;
|
||||||
CommandProc CmdDeleteOrder;
|
CommandProc CmdDeleteOrder;
|
||||||
CommandProc CmdInsertOrder;
|
CommandProcEx CmdInsertOrder;
|
||||||
CommandProc CmdMassChangeOrder;
|
CommandProc CmdMassChangeOrder;
|
||||||
CommandProc CmdChangeServiceInt;
|
CommandProc CmdChangeServiceInt;
|
||||||
|
|
||||||
|
@@ -944,17 +944,17 @@ uint GetOrderDistance(const Order *prev, const Order *cur, const Vehicle *v, int
|
|||||||
* @param flags operation to perform
|
* @param flags operation to perform
|
||||||
* @param p1 various bitstuffed elements
|
* @param p1 various bitstuffed elements
|
||||||
* - p1 = (bit 0 - 19) - ID of the vehicle
|
* - p1 = (bit 0 - 19) - ID of the vehicle
|
||||||
* - p1 = (bit 20 - 35) - the selected order (if any). If the last order is given,
|
|
||||||
* the order will be inserted before that one
|
|
||||||
* the maximum vehicle order id is 254.
|
|
||||||
* @param p2 packed order to insert
|
* @param p2 packed order to insert
|
||||||
|
* @param p3 various bitstuffed elements
|
||||||
|
* - p3 = (bit 0 - 15) - the selected order (if any). If the last order is given,
|
||||||
|
* the order will be inserted before that one
|
||||||
* @param text unused
|
* @param text unused
|
||||||
* @return the cost of this operation or an error
|
* @return the cost of this operation or an error
|
||||||
*/
|
*/
|
||||||
CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, uint32 binary_length)
|
||||||
{
|
{
|
||||||
VehicleID veh = GB(p1, 0, 20);
|
VehicleID veh = GB(p1, 0, 20);
|
||||||
VehicleOrderID sel_ord = GB(p1, 20, 16);
|
VehicleOrderID sel_ord = GB(p3, 0, 16);
|
||||||
Order new_order(p2);
|
Order new_order(p2);
|
||||||
|
|
||||||
return CmdInsertOrderIntl(flags, Vehicle::GetIfValid(veh), sel_ord, new_order, false);
|
return CmdInsertOrderIntl(flags, Vehicle::GetIfValid(veh), sel_ord, new_order, false);
|
||||||
@@ -1580,18 +1580,19 @@ CommandCost CmdMoveOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|||||||
* @param flags operation to perform
|
* @param flags operation to perform
|
||||||
* @param p1 various bitstuffed elements
|
* @param p1 various bitstuffed elements
|
||||||
* - p1 = (bit 0 - 19) - ID of the vehicle
|
* - p1 = (bit 0 - 19) - ID of the vehicle
|
||||||
* - p1 = (bit 20 - 35) - the selected order (if any). If the last order is given,
|
|
||||||
* the order will be inserted before that one.
|
|
||||||
* @param p2 various bitstuffed elements
|
* @param p2 various bitstuffed elements
|
||||||
* - p2 = (bit 0 - 3) - what data to modify (@see ModifyOrderFlags)
|
* - p2 = (bit 0 - 3) - what data to modify (@see ModifyOrderFlags)
|
||||||
* - p2 = (bit 4 - 19) - the data to modify
|
* - p2 = (bit 4 - 19) - the data to modify
|
||||||
* - p2 = (bit 20 - 27) - a CargoID for cargo type orders (MOF_CARGO_TYPE_UNLOAD or MOF_CARGO_TYPE_LOAD)
|
* - p2 = (bit 20 - 27) - a CargoID for cargo type orders (MOF_CARGO_TYPE_UNLOAD or MOF_CARGO_TYPE_LOAD)
|
||||||
|
* @param p3 various bitstuffed elements
|
||||||
|
* - p3 = (bit 0 - 15) - the selected order (if any). If the last order is given,
|
||||||
|
* the order will be inserted before that one
|
||||||
* @param text unused
|
* @param text unused
|
||||||
* @return the cost of this operation or an error
|
* @return the cost of this operation or an error
|
||||||
*/
|
*/
|
||||||
CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, uint32 binary_length)
|
||||||
{
|
{
|
||||||
VehicleOrderID sel_ord = GB(p1, 20, 16);
|
VehicleOrderID sel_ord = GB(p3, 0, 16);
|
||||||
VehicleID veh = GB(p1, 0, 20);
|
VehicleID veh = GB(p1, 0, 20);
|
||||||
ModifyOrderFlags mof = Extract<ModifyOrderFlags, 0, 4>(p2);
|
ModifyOrderFlags mof = Extract<ModifyOrderFlags, 0, 4>(p2);
|
||||||
uint16 data = GB(p2, 4, 16);
|
uint16 data = GB(p2, 4, 16);
|
||||||
|
@@ -67,6 +67,11 @@ static const uint32 _cargo_type_unload_order_drowdown_hidden_mask = 0x8; // 0100
|
|||||||
DropDownList GetSlotDropDownList(Owner owner, TraceRestrictSlotID slot_id, int &selected);
|
DropDownList GetSlotDropDownList(Owner owner, TraceRestrictSlotID slot_id, int &selected);
|
||||||
DropDownList GetCounterDropDownList(Owner owner, TraceRestrictCounterID ctr_id, int &selected);
|
DropDownList GetCounterDropDownList(Owner owner, TraceRestrictCounterID ctr_id, int &selected);
|
||||||
|
|
||||||
|
static bool ModifyOrder(const Vehicle *v, VehicleOrderID order_id, uint32 p2, bool error_msg = true)
|
||||||
|
{
|
||||||
|
return DoCommandPEx(v->tile, v->index, p2, order_id, CMD_MODIFY_ORDER | (error_msg ? CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER) : 0), nullptr, nullptr, 0);
|
||||||
|
}
|
||||||
|
|
||||||
struct CargoTypeOrdersWindow : public Window {
|
struct CargoTypeOrdersWindow : public Window {
|
||||||
private:
|
private:
|
||||||
CargoTypeOrdersWindowVariant variant;
|
CargoTypeOrdersWindowVariant variant;
|
||||||
@@ -249,12 +254,12 @@ public:
|
|||||||
|
|
||||||
if (action_type == order_action_type) return;
|
if (action_type == order_action_type) return;
|
||||||
|
|
||||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->order_id << 20), mof | (action_type << 4) | (cargo_id << 20), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
ModifyOrder(this->vehicle, this->order_id, mof | (action_type << 4) | (cargo_id << 20));
|
||||||
|
|
||||||
this->GetWidget<NWidgetCore>(widget)->SetDataTip(this->cargo_type_order_dropdown[this->GetOrderActionTypeForCargo(cargo_id)], STR_CARGO_TYPE_LOAD_ORDERS_DROP_TOOLTIP + this->variant);
|
this->GetWidget<NWidgetCore>(widget)->SetDataTip(this->cargo_type_order_dropdown[this->GetOrderActionTypeForCargo(cargo_id)], STR_CARGO_TYPE_LOAD_ORDERS_DROP_TOOLTIP + this->variant);
|
||||||
this->SetWidgetDirty(widget);
|
this->SetWidgetDirty(widget);
|
||||||
} else if (widget == WID_CTO_SET_TO_ALL_DROPDOWN) {
|
} else if (widget == WID_CTO_SET_TO_ALL_DROPDOWN) {
|
||||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->order_id << 20), mof | (action_type << 4) | (CT_INVALID << 20), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
ModifyOrder(this->vehicle, this->order_id, mof | (action_type << 4) | (CT_INVALID << 20));
|
||||||
|
|
||||||
for (int i = 0; i < _sorted_standard_cargo_specs_size; i++) {
|
for (int i = 0; i < _sorted_standard_cargo_specs_size; i++) {
|
||||||
const CargoSpec *cs = _sorted_cargo_specs[i];
|
const CargoSpec *cs = _sorted_cargo_specs[i];
|
||||||
@@ -1285,6 +1290,16 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InsertNewOrder(uint32 order_pack)
|
||||||
|
{
|
||||||
|
return DoCommandPEx(this->vehicle->tile, this->vehicle->index, order_pack, this->OrderGetSel(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER), nullptr, nullptr, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ModifyOrder(VehicleOrderID sel_ord, uint32 p2, bool error_msg = true)
|
||||||
|
{
|
||||||
|
return ::ModifyOrder(this->vehicle, sel_ord, p2, error_msg);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the click on the goto button.
|
* Handle the click on the goto button.
|
||||||
*/
|
*/
|
||||||
@@ -1319,7 +1334,7 @@ private:
|
|||||||
load_type = order->GetLoadType() == OLF_LOAD_IF_POSSIBLE ? OLF_FULL_LOAD_ANY : OLF_LOAD_IF_POSSIBLE;
|
load_type = order->GetLoadType() == OLF_LOAD_IF_POSSIBLE ? OLF_FULL_LOAD_ANY : OLF_LOAD_IF_POSSIBLE;
|
||||||
}
|
}
|
||||||
if (order->GetLoadType() != load_type) {
|
if (order->GetLoadType() != load_type) {
|
||||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_LOAD | (load_type << 4), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
this->ModifyOrder(sel_ord, MOF_LOAD | (load_type << 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (load_type == OLFB_CARGO_TYPE_LOAD) ShowCargoTypeOrdersWindow(this->vehicle, this, sel_ord, CTOWV_LOAD);
|
if (load_type == OLFB_CARGO_TYPE_LOAD) ShowCargoTypeOrdersWindow(this->vehicle, this, sel_ord, CTOWV_LOAD);
|
||||||
@@ -1345,7 +1360,7 @@ private:
|
|||||||
if (order == nullptr) return;
|
if (order == nullptr) return;
|
||||||
i = (order->GetDepotOrderType() & ODTFB_SERVICE) ? DA_ALWAYS_GO : DA_SERVICE;
|
i = (order->GetDepotOrderType() & ODTFB_SERVICE) ? DA_ALWAYS_GO : DA_SERVICE;
|
||||||
}
|
}
|
||||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_DEPOT_ACTION | (i << 4), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
this->ModifyOrder(sel_ord, MOF_DEPOT_ACTION | (i << 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1360,7 +1375,7 @@ private:
|
|||||||
(_settings_client.gui.new_nonstop || _settings_game.order.nonstop_only) && this->vehicle->IsGroundVehicle() ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
|
(_settings_client.gui.new_nonstop || _settings_game.order.nonstop_only) && this->vehicle->IsGroundVehicle() ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
|
||||||
order.SetDepotActionType(ODATFB_NEAREST_DEPOT);
|
order.SetDepotActionType(ODATFB_NEAREST_DEPOT);
|
||||||
|
|
||||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), order.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER));
|
this->InsertNewOrder(order.Pack());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1378,12 +1393,12 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (order->GetUnloadType() != unload_type) {
|
if (order->GetUnloadType() != unload_type) {
|
||||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_UNLOAD | (unload_type << 4), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
this->ModifyOrder(sel_ord, MOF_UNLOAD | (unload_type << 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unload_type == OUFB_TRANSFER) {
|
if (unload_type == OUFB_TRANSFER) {
|
||||||
/* Transfer orders with leave empty as default */
|
/* Transfer orders with leave empty as default */
|
||||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_LOAD | (OLFB_NO_LOAD << 4), CMD_MODIFY_ORDER);
|
this->ModifyOrder(sel_ord, MOF_LOAD | (OLFB_NO_LOAD << 4), false);
|
||||||
this->SetWidgetDirty(WID_O_FULL_LOAD);
|
this->SetWidgetDirty(WID_O_FULL_LOAD);
|
||||||
} else if(unload_type == OUFB_CARGO_TYPE_UNLOAD) {
|
} else if(unload_type == OUFB_CARGO_TYPE_UNLOAD) {
|
||||||
ShowCargoTypeOrdersWindow(this->vehicle, this, sel_ord, CTOWV_UNLOAD);
|
ShowCargoTypeOrdersWindow(this->vehicle, this, sel_ord, CTOWV_UNLOAD);
|
||||||
@@ -1425,7 +1440,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->SetWidgetDirty(WID_O_NON_STOP);
|
this->SetWidgetDirty(WID_O_NON_STOP);
|
||||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_NON_STOP | non_stop << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
this->ModifyOrder(sel_ord, MOF_NON_STOP | non_stop << 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2103,7 +2118,7 @@ public:
|
|||||||
order.index = 0;
|
order.index = 0;
|
||||||
order.MakeConditional(order_id);
|
order.MakeConditional(order_id);
|
||||||
|
|
||||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), order.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER));
|
this->InsertNewOrder(order.Pack());
|
||||||
}
|
}
|
||||||
ResetObjectToPlace();
|
ResetObjectToPlace();
|
||||||
break;
|
break;
|
||||||
@@ -2139,9 +2154,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (sel << 20),
|
this->ModifyOrder(sel, MOF_STOP_LOCATION | osl << 4);
|
||||||
MOF_STOP_LOCATION | osl << 4,
|
|
||||||
CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Select clicked order */
|
/* Select clicked order */
|
||||||
@@ -2259,8 +2272,7 @@ public:
|
|||||||
|
|
||||||
if (order == nullptr) break;
|
if (order == nullptr) break;
|
||||||
|
|
||||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_WAYPOINT_FLAGS | (order->GetWaypointFlags() ^ OWF_REVERSE) << 4,
|
this->ModifyOrder(sel_ord, MOF_WAYPOINT_FLAGS | (order->GetWaypointFlags() ^ OWF_REVERSE) << 4);
|
||||||
CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2280,7 +2292,7 @@ public:
|
|||||||
if (this->goto_type != OPOS_NONE) {
|
if (this->goto_type != OPOS_NONE) {
|
||||||
ResetObjectToPlace();
|
ResetObjectToPlace();
|
||||||
} else if (GB(this->vehicle->GetOrder(this->OrderGetSel())->GetXData(), 16, 16) != 0) {
|
} else if (GB(this->vehicle->GetOrder(this->OrderGetSel())->GetXData(), 16, 16) != 0) {
|
||||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_VALUE_3 | NEW_STATION << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE_3 | NEW_STATION << 4);
|
||||||
} else {
|
} else {
|
||||||
this->OrderClick_Goto(OPOS_COND_VIA);
|
this->OrderClick_Goto(OPOS_COND_VIA);
|
||||||
}
|
}
|
||||||
@@ -2407,7 +2419,7 @@ public:
|
|||||||
value = Clamp(value, 0, 2047);
|
value = Clamp(value, 0, 2047);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (sel << 20), MOF_COND_VALUE | value << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
this->ModifyOrder(sel, MOF_COND_VALUE | value << 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->query_text_widget == WID_O_ADD_VEH_GROUP) {
|
if (this->query_text_widget == WID_O_ADD_VEH_GROUP) {
|
||||||
@@ -2449,27 +2461,27 @@ public:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_O_COND_VARIABLE:
|
case WID_O_COND_VARIABLE:
|
||||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_VARIABLE | index << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
this->ModifyOrder(this->OrderGetSel(), MOF_COND_VARIABLE | index << 4);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_O_COND_COMPARATOR:
|
case WID_O_COND_COMPARATOR:
|
||||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_COMPARATOR | index << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
this->ModifyOrder(this->OrderGetSel(), MOF_COND_COMPARATOR | index << 4);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_O_COND_CARGO:
|
case WID_O_COND_CARGO:
|
||||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_VALUE | index << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE | index << 4);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_O_COND_AUX_CARGO:
|
case WID_O_COND_AUX_CARGO:
|
||||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_VALUE_2 | index << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE_2 | index << 4);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_O_COND_SLOT:
|
case WID_O_COND_SLOT:
|
||||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_VALUE | index << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE | index << 4);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_O_COND_COUNTER:
|
case WID_O_COND_COUNTER:
|
||||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_VALUE_2 | index << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE_2 | index << 4);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2534,7 +2546,7 @@ public:
|
|||||||
const Order cmd = GetOrderCmdFromTile(this->vehicle, tile);
|
const Order cmd = GetOrderCmdFromTile(this->vehicle, tile);
|
||||||
if (cmd.IsType(OT_NOTHING)) return;
|
if (cmd.IsType(OT_NOTHING)) return;
|
||||||
|
|
||||||
if (DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), cmd.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER))) {
|
if (this->InsertNewOrder(cmd.Pack())) {
|
||||||
/* With quick goto the Go To button stays active */
|
/* With quick goto the Go To button stays active */
|
||||||
if (!_settings_client.gui.quick_goto) ResetObjectToPlace();
|
if (!_settings_client.gui.quick_goto) ResetObjectToPlace();
|
||||||
}
|
}
|
||||||
@@ -2549,7 +2561,7 @@ public:
|
|||||||
st = in->neutral_station;
|
st = in->neutral_station;
|
||||||
}
|
}
|
||||||
if (st != nullptr && IsInfraUsageAllowed(this->vehicle->type, this->vehicle->owner, st->owner)) {
|
if (st != nullptr && IsInfraUsageAllowed(this->vehicle->type, this->vehicle->owner, st->owner)) {
|
||||||
if (DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_VALUE_3 | st->index << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER))) {
|
if (this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE_3 | st->index << 4)) {
|
||||||
ResetObjectToPlace();
|
ResetObjectToPlace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -101,6 +101,11 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */ bool ScriptOrder::ScriptOrderModifyOrder(VehicleID vehicle_id, VehicleOrderID order_position, uint32 p2, Script_SuspendCallbackProc *callback)
|
||||||
|
{
|
||||||
|
return ScriptObject::DoCommandEx(0, vehicle_id, p2, order_position, CMD_MODIFY_ORDER, nullptr, 0, callback);
|
||||||
|
}
|
||||||
|
|
||||||
/* static */ bool ScriptOrder::IsGotoStationOrder(VehicleID vehicle_id, OrderPosition order_position)
|
/* static */ bool ScriptOrder::IsGotoStationOrder(VehicleID vehicle_id, OrderPosition order_position)
|
||||||
{
|
{
|
||||||
if (!IsValidVehicleOrder(vehicle_id, order_position)) return false;
|
if (!IsValidVehicleOrder(vehicle_id, order_position)) return false;
|
||||||
@@ -379,7 +384,8 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
|||||||
EnforcePrecondition(false, order_position != ORDER_CURRENT && IsConditionalOrder(vehicle_id, order_position));
|
EnforcePrecondition(false, order_position != ORDER_CURRENT && IsConditionalOrder(vehicle_id, order_position));
|
||||||
EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, jump_to) && jump_to != ORDER_CURRENT);
|
EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, jump_to) && jump_to != ORDER_CURRENT);
|
||||||
|
|
||||||
return ScriptObject::DoCommand(0, vehicle_id | (order_position << 20), MOF_COND_DESTINATION | (jump_to << 4), CMD_MODIFY_ORDER);
|
int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position);
|
||||||
|
return ScriptOrderModifyOrder(vehicle_id, order_pos, MOF_COND_DESTINATION | (jump_to << 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool ScriptOrder::SetOrderCondition(VehicleID vehicle_id, OrderPosition order_position, OrderCondition condition)
|
/* static */ bool ScriptOrder::SetOrderCondition(VehicleID vehicle_id, OrderPosition order_position, OrderCondition condition)
|
||||||
@@ -389,7 +395,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
|||||||
EnforcePrecondition(false, condition >= OC_LOAD_PERCENTAGE && condition <= OC_REMAINING_LIFETIME);
|
EnforcePrecondition(false, condition >= OC_LOAD_PERCENTAGE && condition <= OC_REMAINING_LIFETIME);
|
||||||
|
|
||||||
int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position);
|
int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position);
|
||||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), MOF_COND_VARIABLE | (condition << 4), CMD_MODIFY_ORDER);
|
return ScriptOrderModifyOrder(vehicle_id, order_pos, MOF_COND_VARIABLE | (condition << 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool ScriptOrder::SetOrderCompareFunction(VehicleID vehicle_id, OrderPosition order_position, CompareFunction compare)
|
/* static */ bool ScriptOrder::SetOrderCompareFunction(VehicleID vehicle_id, OrderPosition order_position, CompareFunction compare)
|
||||||
@@ -399,7 +405,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
|||||||
EnforcePrecondition(false, compare >= CF_EQUALS && compare <= CF_IS_FALSE);
|
EnforcePrecondition(false, compare >= CF_EQUALS && compare <= CF_IS_FALSE);
|
||||||
|
|
||||||
int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position);
|
int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position);
|
||||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), MOF_COND_COMPARATOR | (compare << 4), CMD_MODIFY_ORDER);
|
return ScriptOrderModifyOrder(vehicle_id, order_pos, MOF_COND_COMPARATOR | (compare << 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool ScriptOrder::SetOrderCompareValue(VehicleID vehicle_id, OrderPosition order_position, int32 value)
|
/* static */ bool ScriptOrder::SetOrderCompareValue(VehicleID vehicle_id, OrderPosition order_position, int32 value)
|
||||||
@@ -410,7 +416,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
|||||||
if (GetOrderCondition(vehicle_id, order_position) == OC_MAX_SPEED) value = value * 10 / 16;
|
if (GetOrderCondition(vehicle_id, order_position) == OC_MAX_SPEED) value = value * 10 / 16;
|
||||||
|
|
||||||
int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position);
|
int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position);
|
||||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), MOF_COND_VALUE | (value << 4), CMD_MODIFY_ORDER);
|
return ScriptOrderModifyOrder(vehicle_id, order_pos, MOF_COND_VALUE | (value << 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool ScriptOrder::SetStopLocation(VehicleID vehicle_id, OrderPosition order_position, StopLocation stop_location)
|
/* static */ bool ScriptOrder::SetStopLocation(VehicleID vehicle_id, OrderPosition order_position, StopLocation stop_location)
|
||||||
@@ -423,9 +429,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
|||||||
order_position = ScriptOrder::ResolveOrderPosition(vehicle_id, order_position);
|
order_position = ScriptOrder::ResolveOrderPosition(vehicle_id, order_position);
|
||||||
|
|
||||||
int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position);
|
int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position);
|
||||||
uint32 p1 = vehicle_id | (order_pos << 20);
|
return ScriptOrderModifyOrder(vehicle_id, order_pos, MOF_STOP_LOCATION | (stop_location << 4));
|
||||||
uint32 p2 = MOF_STOP_LOCATION | (stop_location << 4);
|
|
||||||
return ScriptObject::DoCommand(0, p1, p2, CMD_MODIFY_ORDER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool ScriptOrder::SetOrderRefit(VehicleID vehicle_id, OrderPosition order_position, CargoID refit_cargo)
|
/* static */ bool ScriptOrder::SetOrderRefit(VehicleID vehicle_id, OrderPosition order_position, CargoID refit_cargo)
|
||||||
@@ -505,8 +509,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
|||||||
|
|
||||||
order.SetNonStopType((OrderNonStopFlags)(GB(order_flags, 0, 2) | ((_settings_game.order.nonstop_only && ::Vehicle::Get(vehicle_id)->IsGroundVehicle()) ? OF_NON_STOP_INTERMEDIATE : 0)));
|
order.SetNonStopType((OrderNonStopFlags)(GB(order_flags, 0, 2) | ((_settings_game.order.nonstop_only && ::Vehicle::Get(vehicle_id)->IsGroundVehicle()) ? OF_NON_STOP_INTERMEDIATE : 0)));
|
||||||
|
|
||||||
int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position);
|
return ScriptObject::DoCommandEx(0, vehicle_id, order.Pack(), ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position), CMD_INSERT_ORDER);
|
||||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), order.Pack(), CMD_INSERT_ORDER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool ScriptOrder::InsertConditionalOrder(VehicleID vehicle_id, OrderPosition order_position, OrderPosition jump_to)
|
/* static */ bool ScriptOrder::InsertConditionalOrder(VehicleID vehicle_id, OrderPosition order_position, OrderPosition jump_to)
|
||||||
@@ -521,8 +524,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
|||||||
Order order;
|
Order order;
|
||||||
order.MakeConditional(jump_to);
|
order.MakeConditional(jump_to);
|
||||||
|
|
||||||
int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position);
|
return ScriptObject::DoCommandEx(0, vehicle_id, order.Pack(), ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position), CMD_INSERT_ORDER);
|
||||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), order.Pack(), CMD_INSERT_ORDER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool ScriptOrder::RemoveOrder(VehicleID vehicle_id, OrderPosition order_position)
|
/* static */ bool ScriptOrder::RemoveOrder(VehicleID vehicle_id, OrderPosition order_position)
|
||||||
@@ -587,7 +589,7 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance *instance)
|
|||||||
EnforcePrecondition(false, (order_flags & OF_GOTO_NEAREST_DEPOT) == (current & OF_GOTO_NEAREST_DEPOT));
|
EnforcePrecondition(false, (order_flags & OF_GOTO_NEAREST_DEPOT) == (current & OF_GOTO_NEAREST_DEPOT));
|
||||||
|
|
||||||
if ((current & OF_NON_STOP_FLAGS) != (order_flags & OF_NON_STOP_FLAGS)) {
|
if ((current & OF_NON_STOP_FLAGS) != (order_flags & OF_NON_STOP_FLAGS)) {
|
||||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), (order_flags & OF_NON_STOP_FLAGS) << 4 | MOF_NON_STOP, CMD_MODIFY_ORDER, nullptr, &::_DoCommandReturnSetOrderFlags);
|
return ScriptOrderModifyOrder(vehicle_id, order_pos, (order_flags & OF_NON_STOP_FLAGS) << 4 | MOF_NON_STOP, &::_DoCommandReturnSetOrderFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (order->GetType()) {
|
switch (order->GetType()) {
|
||||||
@@ -596,16 +598,16 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance *instance)
|
|||||||
uint data = DA_ALWAYS_GO;
|
uint data = DA_ALWAYS_GO;
|
||||||
if (order_flags & OF_SERVICE_IF_NEEDED) data = DA_SERVICE;
|
if (order_flags & OF_SERVICE_IF_NEEDED) data = DA_SERVICE;
|
||||||
if (order_flags & OF_STOP_IN_DEPOT) data = DA_STOP;
|
if (order_flags & OF_STOP_IN_DEPOT) data = DA_STOP;
|
||||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), (data << 4) | MOF_DEPOT_ACTION, CMD_MODIFY_ORDER, nullptr, &::_DoCommandReturnSetOrderFlags);
|
return ScriptOrderModifyOrder(vehicle_id, order_pos, (data << 4) | MOF_DEPOT_ACTION, &::_DoCommandReturnSetOrderFlags);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OT_GOTO_STATION:
|
case OT_GOTO_STATION:
|
||||||
if ((current & OF_UNLOAD_FLAGS) != (order_flags & OF_UNLOAD_FLAGS)) {
|
if ((current & OF_UNLOAD_FLAGS) != (order_flags & OF_UNLOAD_FLAGS)) {
|
||||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), (order_flags & OF_UNLOAD_FLAGS) << 2 | MOF_UNLOAD, CMD_MODIFY_ORDER, nullptr, &::_DoCommandReturnSetOrderFlags);
|
return ScriptOrderModifyOrder(vehicle_id, order_pos, (order_flags & OF_UNLOAD_FLAGS) << 2 | MOF_UNLOAD, &::_DoCommandReturnSetOrderFlags);
|
||||||
}
|
}
|
||||||
if ((current & OF_LOAD_FLAGS) != (order_flags & OF_LOAD_FLAGS)) {
|
if ((current & OF_LOAD_FLAGS) != (order_flags & OF_LOAD_FLAGS)) {
|
||||||
return ScriptObject::DoCommand(0, vehicle_id | (order_pos << 20), (order_flags & OF_LOAD_FLAGS) >> 1 | MOF_LOAD, CMD_MODIFY_ORDER, nullptr, &::_DoCommandReturnSetOrderFlags);
|
return ScriptOrderModifyOrder(vehicle_id, order_pos, (order_flags & OF_LOAD_FLAGS) >> 1 | MOF_LOAD, &::_DoCommandReturnSetOrderFlags);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@@ -600,6 +600,9 @@ public:
|
|||||||
* @see ScriptEngine::GetMaximumOrderDistance and ScriptVehicle::GetMaximumOrderDistance
|
* @see ScriptEngine::GetMaximumOrderDistance and ScriptVehicle::GetMaximumOrderDistance
|
||||||
*/
|
*/
|
||||||
static uint GetOrderDistance(ScriptVehicle::VehicleType vehicle_type, TileIndex origin_tile, TileIndex dest_tile);
|
static uint GetOrderDistance(ScriptVehicle::VehicleType vehicle_type, TileIndex origin_tile, TileIndex dest_tile);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static bool ScriptOrderModifyOrder(VehicleID vehicle_id, VehicleOrderID order_position, uint32 p2, Script_SuspendCallbackProc *callback = nullptr);
|
||||||
};
|
};
|
||||||
DECLARE_ENUM_AS_BIT_SET(ScriptOrder::ScriptOrderFlags)
|
DECLARE_ENUM_AS_BIT_SET(ScriptOrder::ScriptOrderFlags)
|
||||||
|
|
||||||
|
@@ -19,7 +19,6 @@
|
|||||||
#include "company_base.h"
|
#include "company_base.h"
|
||||||
#include "settings_type.h"
|
#include "settings_type.h"
|
||||||
#include "scope.h"
|
#include "scope.h"
|
||||||
#include "core/endian_func.hpp"
|
|
||||||
|
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
|
|
||||||
@@ -140,7 +139,10 @@ static void ChangeTimetable(Vehicle *v, VehicleOrderID order_number, uint32 val,
|
|||||||
* @param p2 The amount of time to wait.
|
* @param p2 The amount of time to wait.
|
||||||
* - p2 = - The data to modify as specified by p1 bits 28-30.
|
* - p2 = - The data to modify as specified by p1 bits 28-30.
|
||||||
* 0 to clear times, UINT16_MAX to clear speed limit.
|
* 0 to clear times, UINT16_MAX to clear speed limit.
|
||||||
* @param text LE uint16 Order index to modify.
|
* @param p3 various bitstuffed elements
|
||||||
|
* - p3 = (bit 0 - 15) - the selected order (if any). If the last order is given,
|
||||||
|
* the order will be inserted before that one
|
||||||
|
* @param text unused
|
||||||
* @return the cost of this operation or an error
|
* @return the cost of this operation or an error
|
||||||
*/
|
*/
|
||||||
CommandCost CmdChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, uint32 binary_length)
|
CommandCost CmdChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, uint32 binary_length)
|
||||||
@@ -153,9 +155,7 @@ CommandCost CmdChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, u
|
|||||||
CommandCost ret = CheckOwnership(v->owner);
|
CommandCost ret = CheckOwnership(v->owner);
|
||||||
if (ret.Failed()) return ret;
|
if (ret.Failed()) return ret;
|
||||||
|
|
||||||
if (binary_length != 2) return CMD_ERROR;
|
VehicleOrderID order_number = GB(p3, 0, 16);
|
||||||
VehicleOrderID order_number = FROM_LE16(*reinterpret_cast<const uint16 *>(text));
|
|
||||||
|
|
||||||
Order *order = v->GetOrder(order_number);
|
Order *order = v->GetOrder(order_number);
|
||||||
if (order == nullptr || order->IsType(OT_IMPLICIT)) return CMD_ERROR;
|
if (order == nullptr || order->IsType(OT_IMPLICIT)) return CMD_ERROR;
|
||||||
|
|
||||||
@@ -311,9 +311,7 @@ CommandCost CmdBulkChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32 p
|
|||||||
// Exclude waypoints from set all wait times command
|
// Exclude waypoints from set all wait times command
|
||||||
if (Extract<ModifyTimetableFlags, 28, 3>(p1) == MTF_WAIT_TIME && GB(p1, 31, 1) == 0 && order->IsType(OT_GOTO_WAYPOINT)) continue;
|
if (Extract<ModifyTimetableFlags, 28, 3>(p1) == MTF_WAIT_TIME && GB(p1, 31, 1) == 0 && order->IsType(OT_GOTO_WAYPOINT)) continue;
|
||||||
|
|
||||||
char text[2];
|
DoCommandEx(tile, p1, p2, order_number, flags, CMD_CHANGE_TIMETABLE);
|
||||||
*reinterpret_cast<uint16 *>(&text) = TO_LE16(order_number);
|
|
||||||
DoCommandEx(tile, p1, p2, 0, flags, CMD_CHANGE_TIMETABLE, text, 2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -25,7 +25,6 @@
|
|||||||
#include "viewport_func.h"
|
#include "viewport_func.h"
|
||||||
#include "schdispatch.h"
|
#include "schdispatch.h"
|
||||||
#include "vehiclelist.h"
|
#include "vehiclelist.h"
|
||||||
#include "core/endian_func.hpp"
|
|
||||||
|
|
||||||
#include "widgets/timetable_widget.h"
|
#include "widgets/timetable_widget.h"
|
||||||
|
|
||||||
@@ -714,9 +713,7 @@ struct TimetableWindow : Window {
|
|||||||
if (bulk) {
|
if (bulk) {
|
||||||
DoCommandP(0, p1, p2, CMD_BULK_CHANGE_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE));
|
DoCommandP(0, p1, p2, CMD_BULK_CHANGE_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE));
|
||||||
} else {
|
} else {
|
||||||
char text[2];
|
DoCommandPEx(0, p1, p2, order_number, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE), nullptr, nullptr, 0);
|
||||||
*reinterpret_cast<uint16 *>(&text) = TO_LE16(order_number);
|
|
||||||
DoCommandPEx(0, p1, p2, 0, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE), nullptr, text, 2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user