MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / CmdMassStartStopVehicle

Function CmdMassStartStopVehicle

src/vehicle_cmd.cpp:666–691  ·  view source on GitHub ↗

* Starts or stops a lot of vehicles * @param flags type of operation * @param tile Tile of the depot where the vehicles are started/stopped (only used for depots) * @param do_start set = start vehicles, unset = stop vehicles * @param vehicle_list_window if set, then it's a vehicle list window, not a depot and Tile is ignored in this case * @param vli VehicleListIdentifier * @return the cost

Source from the content-addressed store, hash-verified

664 * @return the cost of this operation or an error
665 */
666CommandCost CmdMassStartStopVehicle(DoCommandFlags flags, TileIndex tile, bool do_start, bool vehicle_list_window, const VehicleListIdentifier &vli)
667{
668 VehicleList list;
669
670 if (!vli.Valid()) return CMD_ERROR;
671 if (!IsCompanyBuildableVehicleType(vli.vtype)) return CMD_ERROR;
672
673 if (vehicle_list_window) {
674 if (!GenerateVehicleSortList(&list, vli)) return CMD_ERROR;
675 } else {
676 if (!IsDepotTile(tile) || !IsTileOwner(tile, _current_company)) return CMD_ERROR;
677 /* Get the list of vehicles in the depot */
678 BuildDepotVehicleList(vli.vtype, tile, &list, nullptr);
679 }
680
681 for (const Vehicle *v : list) {
682 if (v->vehstatus.Test(VehState::Stopped) != do_start) continue;
683
684 if (!vehicle_list_window && !v->IsChainInDepot()) continue;
685
686 /* Just try and don't care if some vehicle's can't be stopped. */
687 Command<CMD_START_STOP_VEHICLE>::Do(flags, v->index, false);
688 }
689
690 return CommandCost();
691}
692
693/**
694 * Sells all vehicles in a depot

Callers

nothing calls this directly

Calls 9

GenerateVehicleSortListFunction · 0.85
IsDepotTileFunction · 0.85
IsTileOwnerFunction · 0.85
BuildDepotVehicleListFunction · 0.85
CommandCostClass · 0.85
ValidMethod · 0.80
TestMethod · 0.80
IsChainInDepotMethod · 0.45

Tested by

no test coverage detected