Codechange: Use iterators and/or range-for on cargo related loops.

This commit is contained in:
Peter Nelson
2023-10-18 20:49:01 +01:00
committed by Peter Nelson
parent 2a88e0fab3
commit 9602de474d
16 changed files with 79 additions and 89 deletions

View File

@@ -1300,11 +1300,11 @@ static void CheckCaches()
for (Industry *ind : Industry::Iterate()) old_industry_stations_near.push_back(ind->stations_near);
for (Station *st : Station::Iterate()) {
for (CargoID c = 0; c < NUM_CARGO; c++) {
for (GoodsEntry &ge : st->goods) {
byte buff[sizeof(StationCargoList)];
memcpy(buff, &st->goods[c].cargo, sizeof(StationCargoList));
st->goods[c].cargo.InvalidateCache();
assert(memcmp(&st->goods[c].cargo, buff, sizeof(StationCargoList)) == 0);
memcpy(buff, &ge.cargo, sizeof(StationCargoList));
ge.cargo.InvalidateCache();
assert(memcmp(&ge.cargo, buff, sizeof(StationCargoList)) == 0);
}
/* Check docking tiles */