1
0
Fork 0

Codechange: Iterate train group list for CcBuildWagon

pull/10548/head
SamuXarick 2024-01-02 22:28:38 +00:00
parent 8c17fad1e0
commit bbb7941cd7
1 changed files with 3 additions and 1 deletions

View File

@ -32,7 +32,9 @@ void CcBuildWagon(Commands, const CommandCost &result, VehicleID new_veh_id, uin
/* find a locomotive in the depot. */
const Vehicle *found = nullptr;
for (const Train *t : Train::Iterate()) {
const VehicleList &vehicle_list = Company::Get(GetTileOwner(tile))->group_all[VEH_TRAIN].vehicle_list;
for (const Vehicle *v : vehicle_list) {
const Train *t = Train::From(v);
if (t->IsFrontEngine() && t->tile == tile && t->IsStoppedInDepot()) {
if (found != nullptr) return; // must be exactly one.
found = t;