Codechange: Use range-for when iterating station speclists. (#12212)

This replaces indexed access.
This commit is contained in:
Peter Nelson
2024-03-03 16:41:02 +00:00
committed by GitHub
parent b2ca6e1ac8
commit 8172e25273
3 changed files with 14 additions and 20 deletions

View File

@@ -112,15 +112,13 @@ void AfterLoadStations()
{
/* Update the speclists of all stations to point to the currently loaded custom stations. */
for (BaseStation *st : BaseStation::Iterate()) {
for (uint i = 0; i < st->speclist.size(); i++) {
if (st->speclist[i].grfid == 0) continue;
st->speclist[i].spec = StationClass::GetByGrf(st->speclist[i].grfid, st->speclist[i].localidx, nullptr);
for (auto &sm : GetStationSpecList<StationSpec>(st)) {
if (sm.grfid == 0) continue;
sm.spec = StationClass::GetByGrf(sm.grfid, sm.localidx, nullptr);
}
for (uint i = 0; i < st->roadstop_speclist.size(); i++) {
if (st->roadstop_speclist[i].grfid == 0) continue;
st->roadstop_speclist[i].spec = RoadStopClass::GetByGrf(st->roadstop_speclist[i].grfid, st->roadstop_speclist[i].localidx, nullptr);
for (auto &sm : GetStationSpecList<RoadStopSpec>(st)) {
if (sm.grfid == 0) continue;
sm.spec = RoadStopClass::GetByGrf(sm.grfid, sm.localidx, nullptr);
}
if (Station::IsExpected(st)) {