1
0
Fork 0

Codechange: Iterate group vehicle list for CmdRemoveAllVehiclesGroup

pull/10548/head
SamuXarick 2023-12-30 20:14:39 +00:00
parent b492a7b53d
commit e1f07a56ee
1 changed files with 4 additions and 7 deletions

View File

@ -645,13 +645,10 @@ CommandCost CmdRemoveAllVehiclesGroup(DoCommandFlag flags, GroupID group_id)
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
/* Find each Vehicle that belongs to the group old_g and add it to the default group */ /* Find each Vehicle that belongs to the group old_g and add it to the default group */
for (const Vehicle *v : Vehicle::Iterate()) { const VehicleList vehicle_list = g->statistics.vehicle_list;
if (v->IsPrimaryVehicle()) { for (const Vehicle *v : vehicle_list) {
if (v->group_id != group_id) continue; /* Add The Vehicle to the default group */
Command<CMD_ADD_VEHICLE_GROUP>::Do(flags, DEFAULT_GROUP, v->index, false, VehicleListIdentifier{});
/* Add The Vehicle to the default group */
Command<CMD_ADD_VEHICLE_GROUP>::Do(flags, DEFAULT_GROUP, v->index, false, VehicleListIdentifier{});
}
} }
InvalidateWindowData(GetWindowClassForVehicleType(g->vehicle_type), VehicleListIdentifier(VL_GROUP_LIST, g->vehicle_type, _current_company).Pack()); InvalidateWindowData(GetWindowClassForVehicleType(g->vehicle_type), VehicleListIdentifier(VL_GROUP_LIST, g->vehicle_type, _current_company).Pack());