diff options
author | Michael Lutz <michi@icosahedron.de> | 2021-11-02 22:58:40 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2021-12-16 22:28:32 +0100 |
commit | 211c630cbe4185a2adf8b8cd8f52ca58f8bf17ed (patch) | |
tree | 89290b522a2852d71e9a71c43b6d581fb8d1d36d /src/script/api | |
parent | de45a8729c0f1ab965e4adf4e6ad7095a4a678c8 (diff) | |
download | openttd-211c630cbe4185a2adf8b8cd8f52ca58f8bf17ed.tar.xz |
Codechange: Un-bitstuff order commands.
Diffstat (limited to 'src/script/api')
-rw-r--r-- | src/script/api/script_order.cpp | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/src/script/api/script_order.cpp b/src/script/api/script_order.cpp index 8faec672f..e2ee1e608 100644 --- a/src/script/api/script_order.cpp +++ b/src/script/api/script_order.cpp @@ -380,7 +380,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr EnforcePrecondition(false, order_position != ORDER_CURRENT && IsConditionalOrder(vehicle_id, order_position)); EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, jump_to) && jump_to != ORDER_CURRENT); - return ScriptObject::Command<CMD_MODIFY_ORDER>::Do(0, vehicle_id | (order_position << 20), MOF_COND_DESTINATION | (jump_to << 4), {}); + return ScriptObject::Command<CMD_MODIFY_ORDER>::Do(0, vehicle_id, order_position, MOF_COND_DESTINATION, jump_to); } /* static */ bool ScriptOrder::SetOrderCondition(VehicleID vehicle_id, OrderPosition order_position, OrderCondition condition) @@ -390,7 +390,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 ScriptObject::Command<CMD_MODIFY_ORDER>::Do(0, vehicle_id | (order_pos << 20), MOF_COND_VARIABLE | (condition << 4), {}); + return ScriptObject::Command<CMD_MODIFY_ORDER>::Do(0, vehicle_id, order_pos, MOF_COND_VARIABLE, condition); } /* static */ bool ScriptOrder::SetOrderCompareFunction(VehicleID vehicle_id, OrderPosition order_position, CompareFunction compare) @@ -400,7 +400,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 ScriptObject::Command<CMD_MODIFY_ORDER>::Do(0, vehicle_id | (order_pos << 20), MOF_COND_COMPARATOR | (compare << 4), {}); + return ScriptObject::Command<CMD_MODIFY_ORDER>::Do(0, vehicle_id, order_pos, MOF_COND_COMPARATOR, compare); } /* static */ bool ScriptOrder::SetOrderCompareValue(VehicleID vehicle_id, OrderPosition order_position, int32 value) @@ -411,7 +411,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 ScriptObject::Command<CMD_MODIFY_ORDER>::Do(0, vehicle_id | (order_pos << 20), MOF_COND_VALUE | (value << 4), {}); + return ScriptObject::Command<CMD_MODIFY_ORDER>::Do(0, vehicle_id, order_pos, MOF_COND_VALUE, value); } /* static */ bool ScriptOrder::SetStopLocation(VehicleID vehicle_id, OrderPosition order_position, StopLocation stop_location) @@ -424,9 +424,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr order_position = ScriptOrder::ResolveOrderPosition(vehicle_id, order_position); int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position); - uint32 p1 = vehicle_id | (order_pos << 20); - uint32 p2 = MOF_STOP_LOCATION | (stop_location << 4); - return ScriptObject::Command<CMD_MODIFY_ORDER>::Do(0, p1, p2, {}); + return ScriptObject::Command<CMD_MODIFY_ORDER>::Do(0, vehicle_id, order_pos, MOF_STOP_LOCATION, stop_location); } /* static */ bool ScriptOrder::SetOrderRefit(VehicleID vehicle_id, OrderPosition order_position, CargoID refit_cargo) @@ -435,9 +433,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr EnforcePrecondition(false, IsGotoStationOrder(vehicle_id, order_position) || (IsGotoDepotOrder(vehicle_id, order_position) && refit_cargo != CT_AUTO_REFIT)); EnforcePrecondition(false, ScriptCargo::IsValidCargo(refit_cargo) || refit_cargo == CT_AUTO_REFIT || refit_cargo == CT_NO_REFIT); - uint32 p1 = vehicle_id; - uint32 p2 = refit_cargo | ScriptOrderPositionToRealOrderPosition(vehicle_id, ScriptOrder::ResolveOrderPosition(vehicle_id, order_position)) << 16; - return ScriptObject::Command<CMD_ORDER_REFIT>::Do(0, p1, p2, {}); + return ScriptObject::Command<CMD_ORDER_REFIT>::Do(0, vehicle_id, ScriptOrderPositionToRealOrderPosition(vehicle_id, ScriptOrder::ResolveOrderPosition(vehicle_id, order_position)), refit_cargo); } /* static */ bool ScriptOrder::AppendOrder(VehicleID vehicle_id, TileIndex destination, ScriptOrderFlags order_flags) @@ -507,7 +503,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr order.SetNonStopType((OrderNonStopFlags)GB(order_flags, 0, 2)); int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position); - return ScriptObject::Command<CMD_INSERT_ORDER>::Do(0, vehicle_id | (order_pos << 20), order.Pack(), {}); + return ScriptObject::Command<CMD_INSERT_ORDER>::Do(0, vehicle_id, order_pos, order); } /* static */ bool ScriptOrder::InsertConditionalOrder(VehicleID vehicle_id, OrderPosition order_position, OrderPosition jump_to) @@ -523,7 +519,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr order.MakeConditional(jump_to); int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position); - return ScriptObject::Command<CMD_INSERT_ORDER>::Do(0, vehicle_id | (order_pos << 20), order.Pack(), {}); + return ScriptObject::Command<CMD_INSERT_ORDER>::Do(0, vehicle_id, order_pos, order); } /* static */ bool ScriptOrder::RemoveOrder(VehicleID vehicle_id, OrderPosition order_position) @@ -533,7 +529,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, order_position)); int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position); - return ScriptObject::Command<CMD_DELETE_ORDER>::Do(0, vehicle_id, order_pos, {}); + return ScriptObject::Command<CMD_DELETE_ORDER>::Do(0, vehicle_id, order_pos); } /* static */ bool ScriptOrder::SkipToOrder(VehicleID vehicle_id, OrderPosition next_order) @@ -543,7 +539,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, next_order)); int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, next_order); - return ScriptObject::Command<CMD_SKIP_TO_ORDER>::Do(0, vehicle_id, order_pos, {}); + return ScriptObject::Command<CMD_SKIP_TO_ORDER>::Do(0, vehicle_id, order_pos); } /** @@ -587,7 +583,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 ScriptObject::Command<CMD_MODIFY_ORDER>::Do(&::_DoCommandReturnSetOrderFlags, 0, vehicle_id | (order_pos << 20), (order_flags & OF_NON_STOP_FLAGS) << 4 | MOF_NON_STOP, {}); + return ScriptObject::Command<CMD_MODIFY_ORDER>::Do(&::_DoCommandReturnSetOrderFlags, vehicle_id, order_pos, MOF_NON_STOP, order_flags & OF_NON_STOP_FLAGS); } switch (order->GetType()) { @@ -596,16 +592,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 ScriptObject::Command<CMD_MODIFY_ORDER>::Do(&::_DoCommandReturnSetOrderFlags, 0, vehicle_id | (order_pos << 20), (data << 4) | MOF_DEPOT_ACTION, {}); + return ScriptObject::Command<CMD_MODIFY_ORDER>::Do(&::_DoCommandReturnSetOrderFlags, vehicle_id, order_pos, MOF_DEPOT_ACTION, data); } break; case OT_GOTO_STATION: if ((current & OF_UNLOAD_FLAGS) != (order_flags & OF_UNLOAD_FLAGS)) { - return ScriptObject::Command<CMD_MODIFY_ORDER>::Do(&::_DoCommandReturnSetOrderFlags, 0, vehicle_id | (order_pos << 20), (order_flags & OF_UNLOAD_FLAGS) << 2 | MOF_UNLOAD, {}); + return ScriptObject::Command<CMD_MODIFY_ORDER>::Do(&::_DoCommandReturnSetOrderFlags, vehicle_id, order_pos, MOF_UNLOAD, (order_flags & OF_UNLOAD_FLAGS) >> 2); } if ((current & OF_LOAD_FLAGS) != (order_flags & OF_LOAD_FLAGS)) { - return ScriptObject::Command<CMD_MODIFY_ORDER>::Do(&::_DoCommandReturnSetOrderFlags, 0, vehicle_id | (order_pos << 20), (order_flags & OF_LOAD_FLAGS) >> 1 | MOF_LOAD, {}); + return ScriptObject::Command<CMD_MODIFY_ORDER>::Do(&::_DoCommandReturnSetOrderFlags, vehicle_id, order_pos, MOF_LOAD, (order_flags & OF_LOAD_FLAGS) >> 5); } break; @@ -639,7 +635,7 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance *instance) int order_pos_move = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position_move); int order_pos_target = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position_target); - return ScriptObject::Command<CMD_MOVE_ORDER>::Do(0, vehicle_id, order_pos_move | (order_pos_target << 16), {}); + return ScriptObject::Command<CMD_MOVE_ORDER>::Do(0, vehicle_id, order_pos_move, order_pos_target); } /* static */ bool ScriptOrder::CopyOrders(VehicleID vehicle_id, VehicleID main_vehicle_id) @@ -647,7 +643,7 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance *instance) EnforcePrecondition(false, ScriptVehicle::IsValidVehicle(vehicle_id)); EnforcePrecondition(false, ScriptVehicle::IsValidVehicle(main_vehicle_id)); - return ScriptObject::Command<CMD_CLONE_ORDER>::Do(0, vehicle_id | CO_COPY << 30, main_vehicle_id, {}); + return ScriptObject::Command<CMD_CLONE_ORDER>::Do(0, CO_COPY, vehicle_id, main_vehicle_id); } /* static */ bool ScriptOrder::ShareOrders(VehicleID vehicle_id, VehicleID main_vehicle_id) @@ -655,14 +651,14 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance *instance) EnforcePrecondition(false, ScriptVehicle::IsValidVehicle(vehicle_id)); EnforcePrecondition(false, ScriptVehicle::IsValidVehicle(main_vehicle_id)); - return ScriptObject::Command<CMD_CLONE_ORDER>::Do(0, vehicle_id | CO_SHARE << 30, main_vehicle_id, {}); + return ScriptObject::Command<CMD_CLONE_ORDER>::Do(0, CO_SHARE, vehicle_id, main_vehicle_id); } /* static */ bool ScriptOrder::UnshareOrders(VehicleID vehicle_id) { EnforcePrecondition(false, ScriptVehicle::IsValidVehicle(vehicle_id)); - return ScriptObject::Command<CMD_CLONE_ORDER>::Do(0, vehicle_id | CO_UNSHARE << 30, 0, {}); + return ScriptObject::Command<CMD_CLONE_ORDER>::Do(0, CO_UNSHARE, vehicle_id, 0); } /* static */ uint ScriptOrder::GetOrderDistance(ScriptVehicle::VehicleType vehicle_type, TileIndex origin_tile, TileIndex dest_tile) |