Codechange: Use range-for iteration.
This commit is contained in:
@@ -283,9 +283,9 @@ static void InitializeWindowsAndCaches()
|
||||
}
|
||||
}
|
||||
for (Town *t : Town::Iterate()) {
|
||||
for (std::list<PersistentStorage *>::iterator it = t->psa_list.begin(); it != t->psa_list.end(); ++it) {
|
||||
(*it)->feature = GSF_FAKE_TOWNS;
|
||||
(*it)->tile = t->xy;
|
||||
for (auto &it : t->psa_list) {
|
||||
it->feature = GSF_FAKE_TOWNS;
|
||||
it->tile = t->xy;
|
||||
}
|
||||
}
|
||||
for (RoadVehicle *rv : RoadVehicle::Iterate()) {
|
||||
@@ -2157,13 +2157,11 @@ bool AfterLoadGame()
|
||||
* add cargopayment for the vehicles that don't have it.
|
||||
*/
|
||||
for (Station *st : Station::Iterate()) {
|
||||
std::list<Vehicle *>::iterator iter;
|
||||
for (iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end(); ++iter) {
|
||||
for (Vehicle *v : st->loading_vehicles) {
|
||||
/* There are always as many CargoPayments as Vehicles. We need to make the
|
||||
* assert() in Pool::GetNew() happy by calling CanAllocateItem(). */
|
||||
static_assert(CargoPaymentPool::MAX_SIZE == VehiclePool::MAX_SIZE);
|
||||
assert(CargoPayment::CanAllocateItem());
|
||||
Vehicle *v = *iter;
|
||||
if (v->cargo_payment == nullptr) v->cargo_payment = new CargoPayment(v);
|
||||
}
|
||||
}
|
||||
|
@@ -310,22 +310,22 @@ public:
|
||||
|
||||
void Save(GoodsEntry *ge) const override
|
||||
{
|
||||
uint32 num_flows = 0;
|
||||
for (FlowStatMap::const_iterator it(ge->flows.begin()); it != ge->flows.end(); ++it) {
|
||||
num_flows += (uint32)it->second.GetShares()->size();
|
||||
size_t num_flows = 0;
|
||||
for (const auto &it : ge->flows) {
|
||||
num_flows += it.second.GetShares()->size();
|
||||
}
|
||||
SlSetStructListLength(num_flows);
|
||||
|
||||
for (FlowStatMap::const_iterator outer_it(ge->flows.begin()); outer_it != ge->flows.end(); ++outer_it) {
|
||||
const FlowStat::SharesMap *shares = outer_it->second.GetShares();
|
||||
for (const auto &outer_it : ge->flows) {
|
||||
const FlowStat::SharesMap *shares = outer_it.second.GetShares();
|
||||
uint32 sum_shares = 0;
|
||||
FlowSaveLoad flow;
|
||||
flow.source = outer_it->first;
|
||||
for (FlowStat::SharesMap::const_iterator inner_it(shares->begin()); inner_it != shares->end(); ++inner_it) {
|
||||
flow.via = inner_it->second;
|
||||
flow.share = inner_it->first - sum_shares;
|
||||
flow.restricted = inner_it->first > outer_it->second.GetUnrestricted();
|
||||
sum_shares = inner_it->first;
|
||||
flow.source = outer_it.first;
|
||||
for (auto &inner_it : *shares) {
|
||||
flow.via = inner_it.second;
|
||||
flow.share = inner_it.first - sum_shares;
|
||||
flow.restricted = inner_it.first > outer_it.second.GetUnrestricted();
|
||||
sum_shares = inner_it.first;
|
||||
assert(flow.share > 0);
|
||||
SlObject(&flow, this->GetDescription());
|
||||
}
|
||||
|
Reference in New Issue
Block a user