1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-29 17:39:09 +00:00

Codechange: Iterate group vehicle lists for SettingsDisableElrail

This commit is contained in:
SamuXarick
2024-01-01 18:10:22 +00:00
parent 71e96fd8a6
commit f786477c6d

View File

@@ -625,10 +625,13 @@ void SettingsDisableElrail(int32_t new_value)
}
}
/* Fix the total power and acceleration for trains */
for (Train *t : Train::Iterate()) {
/* power and acceleration is cached only for front engines */
if (t->IsFrontEngine()) {
for (const Company *c : Company::Iterate()) {
/* Fix the total power and acceleration for trains.
* These values are only cached for front engines which
* is what the collection enumerates. */
const VehicleList &vehicle_list = c->group_all[VEH_TRAIN].vehicle_list;
for (const Vehicle *v : vehicle_list) {
Train *t = Train::From(Vehicle::Get(v->index));
t->ConsistChanged(CCF_TRACK);
}
}