mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Iterate group vehicle list for CmdRemoveAllVehiclesGroup
parent
b492a7b53d
commit
e1f07a56ee
|
@ -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());
|
||||||
|
|
Loading…
Reference in New Issue