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

Function GetFreeWagonsInDepot

src/train_cmd.cpp:614–629  ·  view source on GitHub ↗

* Get a list of free wagons in a depot. * @param tile Tile of depot. * @return List of free wagons, sorted by vehicle index. */

Source from the content-addressed store, hash-verified

612 * @return List of free wagons, sorted by vehicle index.
613 */
614static std::vector<VehicleID> GetFreeWagonsInDepot(TileIndex tile)
615{
616 std::vector<VehicleID> free_wagons;
617
618 for (Vehicle *v : VehiclesOnTile(tile)) {
619 if (v->type != VEH_TRAIN) continue;
620 if (v->vehstatus.Test(VehState::Crashed)) continue;
621 if (!Train::From(v)->IsFreeWagon()) continue;
622
623 free_wagons.push_back(v->index);
624 }
625
626 /* Sort by vehicle index for consistency across clients. */
627 std::ranges::sort(free_wagons);
628 return free_wagons;
629}
630
631/**
632 * Build a railroad wagon.

Callers 3

CmdBuildRailWagonFunction · 0.85
NormalizeTrainVehInDepotFunction · 0.85
FindGoodVehiclePosFunction · 0.85

Calls 4

VehiclesOnTileClass · 0.85
TestMethod · 0.80
IsFreeWagonMethod · 0.80
push_backMethod · 0.80

Tested by

no test coverage detected