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,14 +645,11 @@ 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;
const VehicleList vehicle_list = g->statistics.vehicle_list;
for (const Vehicle *v : vehicle_list) {
/* 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());
}