From e1f07a56ee6524f1d0710640b016999076d466a6 Mon Sep 17 00:00:00 2001 From: SamuXarick <43006711+SamuXarick@users.noreply.github.com> Date: Sat, 30 Dec 2023 20:14:39 +0000 Subject: [PATCH] Codechange: Iterate group vehicle list for CmdRemoveAllVehiclesGroup --- src/group_cmd.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp index b5ad3546f5..0f56c893cd 100644 --- a/src/group_cmd.cpp +++ b/src/group_cmd.cpp @@ -645,13 +645,10 @@ CommandCost CmdRemoveAllVehiclesGroup(DoCommandFlag flags, GroupID group_id) if (flags & DC_EXEC) { /* Find each Vehicle that belongs to the group old_g and add it to the default group */ - for (const Vehicle *v : Vehicle::Iterate()) { - if (v->IsPrimaryVehicle()) { - if (v->group_id != group_id) continue; - - /* Add The Vehicle to the default group */ - Command::Do(flags, DEFAULT_GROUP, v->index, false, VehicleListIdentifier{}); - } + const VehicleList vehicle_list = g->statistics.vehicle_list; + for (const Vehicle *v : vehicle_list) { + /* Add The Vehicle to the default group */ + Command::Do(flags, DEFAULT_GROUP, v->index, false, VehicleListIdentifier{}); } InvalidateWindowData(GetWindowClassForVehicleType(g->vehicle_type), VehicleListIdentifier(VL_GROUP_LIST, g->vehicle_type, _current_company).Pack());