From 2cf99a57233fca9cdcaf3b2843ebcc8e01ac6722 Mon Sep 17 00:00:00 2001 From: Tyler Trahan Date: Tue, 20 Feb 2024 11:11:24 -0500 Subject: [PATCH] Codechange: Refactor unbunching checks in CmdModifyOrder() --- src/order_cmd.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index c124dbb0d6..ccedb8e31d 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -1313,12 +1313,10 @@ CommandCost CmdModifyOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID se if (data == DA_UNBUNCH) { /* Only one unbunching order is allowed in a vehicle's orders. If this order already has an unbunching action, no error is needed. */ if (v->HasUnbunchingOrder() && !(order->GetDepotActionType() & ODATFB_UNBUNCH)) return_cmd_error(STR_ERROR_UNBUNCHING_ONLY_ONE_ALLOWED); - for (Order *o : v->Orders()) { - /* We don't allow unbunching if the vehicle has a conditional order. */ - if (o->IsType(OT_CONDITIONAL)) return_cmd_error(STR_ERROR_UNBUNCHING_NO_UNBUNCHING_CONDITIONAL); - /* We don't allow unbunching if the vehicle has a full load order. */ - if (o->IsType(OT_GOTO_STATION) && o->GetLoadType() & (OLFB_FULL_LOAD | OLF_FULL_LOAD_ANY)) return_cmd_error(STR_ERROR_UNBUNCHING_NO_UNBUNCHING_FULL_LOAD); - } + /* We don't allow unbunching if the vehicle has a conditional order. */ + if (v->HasConditionalOrder()) return_cmd_error(STR_ERROR_UNBUNCHING_NO_UNBUNCHING_CONDITIONAL); + /* We don't allow unbunching if the vehicle has a full load order. */ + if (v->HasFullLoadOrder()) return_cmd_error(STR_ERROR_UNBUNCHING_NO_UNBUNCHING_FULL_LOAD); } break;