* Get a list of free wagons in a depot. * @param tile Tile of depot. * @return List of free wagons, sorted by vehicle index. */
| 612 | * @return List of free wagons, sorted by vehicle index. |
| 613 | */ |
| 614 | static 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. |
no test coverage detected