diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index b289663a55..7d4d1b2103 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -1730,14 +1730,14 @@ CommandCost CmdReverseOrderList(TileIndex tile, DoCommandFlag flags, uint32 p1, * @param tile unused * @param flags operation to perform * @param p1 various bitstuffed elements - * - p1 = (bit 0 - 19) - ID of the vehicle + * - p1 = (bit 0 - 19) - ID of the vehicle * @param p2 various bitstuffed elements - * - p2 = (bit 0 - 3) - what data to modify (@see ModifyOrderFlags) - * - 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 0 - 7) - what data to modify (@see ModifyOrderFlags) + * - p2 = (bit 8 - 23) - the data to modify + * - p2 = (bit 24 - 31) - 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 + * - 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 */ @@ -1745,9 +1745,9 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 { VehicleOrderID sel_ord = GB(p3, 0, 16); VehicleID veh = GB(p1, 0, 20); - ModifyOrderFlags mof = Extract(p2); - uint16 data = GB(p2, 4, 16); - CargoID cargo_id = (mof == MOF_CARGO_TYPE_UNLOAD || mof == MOF_CARGO_TYPE_LOAD) ? (CargoID) GB(p2, 20, 8) : (CargoID) CT_INVALID; + ModifyOrderFlags mof = Extract(p2); + uint16 data = GB(p2, 8, 16); + CargoID cargo_id = (mof == MOF_CARGO_TYPE_UNLOAD || mof == MOF_CARGO_TYPE_LOAD) ? (CargoID) GB(p2, 24, 8) : (CargoID) CT_INVALID; if (mof >= MOF_END) return CMD_ERROR; diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 0499fe92f8..c8509a992c 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -255,12 +255,12 @@ public: if (action_type == order_action_type) return; - ModifyOrder(this->vehicle, this->order_id, mof | (action_type << 4) | (cargo_id << 20)); + ModifyOrder(this->vehicle, this->order_id, mof | (action_type << 8) | (cargo_id << 24)); this->GetWidget(widget)->SetDataTip(this->cargo_type_order_dropdown[this->GetOrderActionTypeForCargo(cargo_id)], STR_CARGO_TYPE_LOAD_ORDERS_DROP_TOOLTIP + this->variant); this->SetWidgetDirty(widget); } else if (widget == WID_CTO_SET_TO_ALL_DROPDOWN) { - ModifyOrder(this->vehicle, this->order_id, mof | (action_type << 4) | (CT_INVALID << 20)); + ModifyOrder(this->vehicle, this->order_id, mof | (action_type << 8) | (CT_INVALID << 24)); for (int i = 0; i < (int)_sorted_standard_cargo_specs.size(); i++) { const CargoSpec *cs = _sorted_cargo_specs[i]; @@ -1486,7 +1486,7 @@ private: load_type = OLF_LOAD_IF_POSSIBLE; // reset to 'default' } if (order->GetLoadType() != load_type) { - this->ModifyOrder(sel_ord, MOF_LOAD | (load_type << 4)); + this->ModifyOrder(sel_ord, MOF_LOAD | (load_type << 8)); } if (load_type == OLFB_CARGO_TYPE_LOAD) ShowCargoTypeOrdersWindow(this->vehicle, this, sel_ord, CTOWV_LOAD); @@ -1504,7 +1504,7 @@ private: if (order == nullptr) return; i = (order->GetDepotOrderType() & ODTFB_SERVICE) ? DA_ALWAYS_GO : DA_SERVICE; } - this->ModifyOrder(sel_ord, MOF_DEPOT_ACTION | (i << 4)); + this->ModifyOrder(sel_ord, MOF_DEPOT_ACTION | (i << 8)); } /** @@ -1553,12 +1553,12 @@ private: if (order->GetUnloadType() == unload_type && unload_type != OUFB_CARGO_TYPE_UNLOAD) return; // If we still match, do nothing if (order->GetUnloadType() != unload_type) { - this->ModifyOrder(sel_ord, MOF_UNLOAD | (unload_type << 4)); + this->ModifyOrder(sel_ord, MOF_UNLOAD | (unload_type << 8)); } if (unload_type == OUFB_TRANSFER || unload_type == OUFB_UNLOAD) { /* Transfer and unload orders with leave empty as default */ - this->ModifyOrder(sel_ord, MOF_LOAD | (OLFB_NO_LOAD << 4), false); + this->ModifyOrder(sel_ord, MOF_LOAD | (OLFB_NO_LOAD << 8), false); this->SetWidgetDirty(WID_O_FULL_LOAD); } else if (unload_type == OUFB_CARGO_TYPE_UNLOAD) { ShowCargoTypeOrdersWindow(this->vehicle, this, sel_ord, CTOWV_UNLOAD); @@ -1587,7 +1587,7 @@ private: } this->SetWidgetDirty(WID_O_NON_STOP); - this->ModifyOrder(sel_ord, MOF_NON_STOP | non_stop << 4); + this->ModifyOrder(sel_ord, MOF_NON_STOP | non_stop << 8); } /** @@ -2416,7 +2416,7 @@ public: if (this->goto_type == OPOS_CONDITIONAL_RETARGET) { VehicleOrderID order_id = this->GetOrderFromPt(_cursor.pos.y - this->top); if (order_id != INVALID_VEH_ORDER_ID) { - this->ModifyOrder(this->OrderGetSel(), MOF_COND_DESTINATION | (order_id << 4)); + this->ModifyOrder(this->OrderGetSel(), MOF_COND_DESTINATION | (order_id << 8)); } ResetObjectToPlace(); break; @@ -2452,14 +2452,14 @@ public: } } } - this->ModifyOrder(sel, MOF_STOP_LOCATION | osl << 4); + this->ModifyOrder(sel, MOF_STOP_LOCATION | osl << 8); } if (this->vehicle->type == VEH_ROAD && sel < this->vehicle->GetNumOrders() && _settings_game.pf.pathfinder_for_roadvehs == VPF_YAPF) { DiagDirection current = this->vehicle->GetOrder(sel)->GetRoadVehTravelDirection(); if (_settings_client.gui.show_adv_load_mode_features || current != INVALID_DIAGDIR) { uint dir = (current + 1) & 0xFF; if (dir >= DIAGDIR_END) dir = INVALID_DIAGDIR; - this->ModifyOrder(sel, MOF_RV_TRAVEL_DIR | dir << 4); + this->ModifyOrder(sel, MOF_RV_TRAVEL_DIR | dir << 8); } } } else { @@ -2640,7 +2640,7 @@ public: if (order == nullptr) break; - this->ModifyOrder(sel_ord, MOF_WAYPOINT_FLAGS | (order->GetWaypointFlags() ^ OWF_REVERSE) << 4); + this->ModifyOrder(sel_ord, MOF_WAYPOINT_FLAGS | (order->GetWaypointFlags() ^ OWF_REVERSE) << 8); break; } @@ -2660,7 +2660,7 @@ public: if (this->goto_type != OPOS_NONE) { ResetObjectToPlace(); } else if (GB(this->vehicle->GetOrder(this->OrderGetSel())->GetXData(), 16, 16) != 0) { - this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE_3 | NEW_STATION << 4); + this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE_3 | NEW_STATION << 8); } else { this->OrderClick_Goto(OPOS_COND_VIA); } @@ -2823,7 +2823,7 @@ public: value = Clamp(value, 0, 2047); break; } - this->ModifyOrder(sel, MOF_COND_VALUE | value << 4); + this->ModifyOrder(sel, MOF_COND_VALUE | value << 8); } if (this->query_text_widget == WID_O_ADD_VEH_GROUP) { @@ -2866,58 +2866,58 @@ public: break; case WID_O_COND_VARIABLE: - this->ModifyOrder(this->OrderGetSel(), MOF_COND_VARIABLE | index << 4); + this->ModifyOrder(this->OrderGetSel(), MOF_COND_VARIABLE | index << 8); break; case WID_O_COND_COMPARATOR: if (index >= 0x100) { const Order *o = this->vehicle->GetOrder(this->OrderGetSel()); if (o == nullptr || o->GetConditionVariable() != OCV_DISPATCH_SLOT) return; - this->ModifyOrder(this->OrderGetSel(), MOF_COND_COMPARATOR | ((index & 1) ? OCC_IS_FALSE : OCC_IS_TRUE) << 4); - this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE_2 | ((o->GetConditionValue() & 2) | ((index & 2) >> 1)) << 4); + this->ModifyOrder(this->OrderGetSel(), MOF_COND_COMPARATOR | ((index & 1) ? OCC_IS_FALSE : OCC_IS_TRUE) << 8); + this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE_2 | ((o->GetConditionValue() & 2) | ((index & 2) >> 1)) << 8); } else { - this->ModifyOrder(this->OrderGetSel(), MOF_COND_COMPARATOR | index << 4); + this->ModifyOrder(this->OrderGetSel(), MOF_COND_COMPARATOR | index << 8); } break; case WID_O_COND_CARGO: - this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE | index << 4); + this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE | index << 8); break; case WID_O_COND_AUX_CARGO: - this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE_2 | index << 4); + this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE_2 | index << 8); break; case WID_O_COND_SLOT: - this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE | index << 4); + this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE | index << 8); break; case WID_O_COND_COUNTER: - this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE_2 | index << 4); + this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE_2 | index << 8); break; case WID_O_COND_TIME_DATE: - this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE_2 | index << 4); + this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE_2 | index << 8); break; case WID_O_COND_TIMETABLE: - this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE_2 | index << 4); + this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE_2 | index << 8); break; case WID_O_COND_SCHED_SELECT: - this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE | index << 4); + this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE | index << 8); break; case WID_O_COND_SCHED_TEST: { const Order *o = this->vehicle->GetOrder(this->OrderGetSel()); if (o == nullptr) return; index = (index * 2) | (o->GetConditionValue() & 1); - this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE_2 | index << 4); + this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE_2 | index << 8); break; } case WID_O_RELEASE_SLOT: - this->ModifyOrder(this->OrderGetSel(), MOF_SLOT | index << 4); + this->ModifyOrder(this->OrderGetSel(), MOF_SLOT | index << 8); break; case WID_O_MANAGE_LIST: @@ -3026,7 +3026,7 @@ public: st = in->neutral_station; } if (st != nullptr && IsInfraUsageAllowed(this->vehicle->type, this->vehicle->owner, st->owner)) { - if (this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE_3 | st->index << 4)) { + if (this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE_3 | st->index << 8)) { ResetObjectToPlace(); } } diff --git a/src/order_type.h b/src/order_type.h index 6cab66acaf..eb915d1445 100644 --- a/src/order_type.h +++ b/src/order_type.h @@ -200,7 +200,7 @@ enum ModifyOrderFlags { MOF_RV_TRAVEL_DIR, ///< Change the road vehicle travel direction. MOF_END }; -template <> struct EnumPropsT : MakeEnumPropsT {}; +template <> struct EnumPropsT : MakeEnumPropsT {}; /** * Depot action to switch to when doing a #MOF_DEPOT_ACTION. diff --git a/src/script/api/script_order.cpp b/src/script/api/script_order.cpp index ae34b68fbd..dc9cbdc21a 100644 --- a/src/script/api/script_order.cpp +++ b/src/script/api/script_order.cpp @@ -385,7 +385,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, jump_to) && jump_to != ORDER_CURRENT); int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position); - return ScriptOrderModifyOrder(vehicle_id, order_pos, MOF_COND_DESTINATION | (jump_to << 4)); + return ScriptOrderModifyOrder(vehicle_id, order_pos, MOF_COND_DESTINATION | (jump_to << 8)); } /* static */ bool ScriptOrder::SetOrderCondition(VehicleID vehicle_id, OrderPosition order_position, OrderCondition condition) @@ -395,7 +395,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr EnforcePrecondition(false, condition >= OC_LOAD_PERCENTAGE && condition <= OC_REMAINING_LIFETIME); int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position); - return ScriptOrderModifyOrder(vehicle_id, order_pos, MOF_COND_VARIABLE | (condition << 4)); + return ScriptOrderModifyOrder(vehicle_id, order_pos, MOF_COND_VARIABLE | (condition << 8)); } /* static */ bool ScriptOrder::SetOrderCompareFunction(VehicleID vehicle_id, OrderPosition order_position, CompareFunction compare) @@ -405,7 +405,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr EnforcePrecondition(false, compare >= CF_EQUALS && compare <= CF_IS_FALSE); int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position); - return ScriptOrderModifyOrder(vehicle_id, order_pos, MOF_COND_COMPARATOR | (compare << 4)); + return ScriptOrderModifyOrder(vehicle_id, order_pos, MOF_COND_COMPARATOR | (compare << 8)); } /* static */ bool ScriptOrder::SetOrderCompareValue(VehicleID vehicle_id, OrderPosition order_position, int32 value) @@ -416,7 +416,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr if (GetOrderCondition(vehicle_id, order_position) == OC_MAX_SPEED) value = value * 10 / 16; int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position); - return ScriptOrderModifyOrder(vehicle_id, order_pos, MOF_COND_VALUE | (value << 4)); + return ScriptOrderModifyOrder(vehicle_id, order_pos, MOF_COND_VALUE | (value << 8)); } /* static */ bool ScriptOrder::SetStopLocation(VehicleID vehicle_id, OrderPosition order_position, StopLocation stop_location) @@ -429,7 +429,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr order_position = ScriptOrder::ResolveOrderPosition(vehicle_id, order_position); int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position); - return ScriptOrderModifyOrder(vehicle_id, order_pos, MOF_STOP_LOCATION | (stop_location << 4)); + return ScriptOrderModifyOrder(vehicle_id, order_pos, MOF_STOP_LOCATION | (stop_location << 8)); } /* static */ bool ScriptOrder::SetOrderRefit(VehicleID vehicle_id, OrderPosition order_position, CargoID refit_cargo) @@ -591,7 +591,7 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance *instance) 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)) { - return ScriptOrderModifyOrder(vehicle_id, order_pos, (order_flags & OF_NON_STOP_FLAGS) << 4 | MOF_NON_STOP, &::_DoCommandReturnSetOrderFlags); + return ScriptOrderModifyOrder(vehicle_id, order_pos, (order_flags & OF_NON_STOP_FLAGS) << 8 | MOF_NON_STOP, &::_DoCommandReturnSetOrderFlags); } switch (order->GetType()) { @@ -600,16 +600,16 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance *instance) uint data = DA_ALWAYS_GO; if (order_flags & OF_SERVICE_IF_NEEDED) data = DA_SERVICE; if (order_flags & OF_STOP_IN_DEPOT) data = DA_STOP; - return ScriptOrderModifyOrder(vehicle_id, order_pos, (data << 4) | MOF_DEPOT_ACTION, &::_DoCommandReturnSetOrderFlags); + return ScriptOrderModifyOrder(vehicle_id, order_pos, (data << 8) | MOF_DEPOT_ACTION, &::_DoCommandReturnSetOrderFlags); } break; case OT_GOTO_STATION: if ((current & OF_UNLOAD_FLAGS) != (order_flags & OF_UNLOAD_FLAGS)) { - return ScriptOrderModifyOrder(vehicle_id, order_pos, (order_flags & OF_UNLOAD_FLAGS) << 2 | MOF_UNLOAD, &::_DoCommandReturnSetOrderFlags); + return ScriptOrderModifyOrder(vehicle_id, order_pos, (order_flags & OF_UNLOAD_FLAGS) << 6 | MOF_UNLOAD, &::_DoCommandReturnSetOrderFlags); } if ((current & OF_LOAD_FLAGS) != (order_flags & OF_LOAD_FLAGS)) { - return ScriptOrderModifyOrder(vehicle_id, order_pos, (order_flags & OF_LOAD_FLAGS) >> 1 | MOF_LOAD, &::_DoCommandReturnSetOrderFlags); + return ScriptOrderModifyOrder(vehicle_id, order_pos, (order_flags & OF_LOAD_FLAGS) << 3 | MOF_LOAD, &::_DoCommandReturnSetOrderFlags); } break;