# HG changeset patch # User Peter Nelson # Date 2024-02-27 18:18:57 # Node ID 9fe6b1220bd7ebf125d61976c99ee14f672f9c72 # Parent 78a91e5251d1475f269ecbfa1d1084980a545852 Codechange: Use range-for instead of indexed loop. (#12191) diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -670,9 +670,7 @@ CommandCost CmdMassStartStopVehicle(DoCo BuildDepotVehicleList(vli.vtype, tile, &list, nullptr); } - for (uint i = 0; i < list.size(); i++) { - const Vehicle *v = list[i]; - + for (const Vehicle *v : list) { if (!!(v->vehstatus & VS_STOPPED) != do_start) continue; if (!vehicle_list_window && !v->IsChainInDepot()) continue; @@ -705,8 +703,8 @@ CommandCost CmdDepotSellAllVehicles(DoCo CommandCost last_error = CMD_ERROR; bool had_success = false; - for (uint i = 0; i < list.size(); i++) { - CommandCost ret = Command::Do(flags, list[i]->index, true, false, INVALID_CLIENT_ID); + for (const Vehicle *v : list) { + CommandCost ret = Command::Do(flags, v->index, true, false, INVALID_CLIENT_ID); if (ret.Succeeded()) { cost.AddCost(ret); had_success = true; @@ -736,9 +734,7 @@ CommandCost CmdDepotMassAutoReplace(DoCo /* Get the list of vehicles in the depot */ BuildDepotVehicleList(vehicle_type, tile, &list, &list, true); - for (uint i = 0; i < list.size(); i++) { - const Vehicle *v = list[i]; - + for (const Vehicle *v : list) { /* Ensure that the vehicle completely in the depot */ if (!v->IsChainInDepot()) continue;