mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Iterate train group lists for CheckTrainsLengths
parent
e9a4f865b0
commit
8c17fad1e0
|
@ -77,7 +77,10 @@ void CheckTrainsLengths()
|
||||||
{
|
{
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
|
||||||
for (const Train *v : Train::Iterate()) {
|
for (const Company *c : Company::Iterate()) {
|
||||||
|
const VehicleList &vehicle_list = c->group_all[VEH_TRAIN].vehicle_list;
|
||||||
|
for (const Vehicle *vehicle : vehicle_list) {
|
||||||
|
const Train *v = Train::From(vehicle);
|
||||||
if (v->First() == v && !(v->vehstatus & VS_CRASHED)) {
|
if (v->First() == v && !(v->vehstatus & VS_CRASHED)) {
|
||||||
for (const Train *u = v, *w = v->Next(); w != nullptr; u = w, w = w->Next()) {
|
for (const Train *u = v, *w = v->Next(); w != nullptr; u = w, w = w->Next()) {
|
||||||
if (u->track != TRACK_BIT_DEPOT) {
|
if (u->track != TRACK_BIT_DEPOT) {
|
||||||
|
@ -100,6 +103,7 @@ void CheckTrainsLengths()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recalculates the cached stuff of a train. Should be called each time a vehicle is added
|
* Recalculates the cached stuff of a train. Should be called each time a vehicle is added
|
||||||
|
|
Loading…
Reference in New Issue