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

This replaces indexed access.
pull/678/head
Peter Nelson 2 months ago committed by GitHub
parent b2ca6e1ac8
commit 8172e25273
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -612,11 +612,9 @@ void RoadStopUpdateCachedTriggers(BaseStation *st)
/* Combine animation trigger bitmask for all road stop specs
* of this station. */
for (uint i = 0; i < st->roadstop_speclist.size(); i++) {
const RoadStopSpec *ss = st->roadstop_speclist[i].spec;
if (ss != nullptr) {
st->cached_roadstop_anim_triggers |= ss->animation.triggers;
st->cached_roadstop_cargo_triggers |= ss->cargo_triggers;
}
for (const auto &sm : GetStationSpecList<RoadStopSpec>(st)) {
if (sm.spec == nullptr) continue;
st->cached_roadstop_anim_triggers |= sm.spec->animation.triggers;
st->cached_roadstop_cargo_triggers |= sm.spec->cargo_triggers;
}
}

@ -1002,12 +1002,10 @@ void StationUpdateCachedTriggers(BaseStation *st)
/* Combine animation trigger bitmask for all station specs
* of this station. */
for (uint i = 0; i < st->speclist.size(); i++) {
const StationSpec *ss = st->speclist[i].spec;
if (ss != nullptr) {
st->cached_anim_triggers |= ss->animation.triggers;
st->cached_cargo_triggers |= ss->cargo_triggers;
}
for (const auto &sm : GetStationSpecList<StationSpec>(st)) {
if (sm.spec == nullptr) continue;
st->cached_anim_triggers |= sm.spec->animation.triggers;
st->cached_cargo_triggers |= sm.spec->cargo_triggers;
}
}

@ -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)) {

Loading…
Cancel
Save