@@ -69,9 +69,8 @@ ABMWithState::ABMWithState(ActiveBlockModifier *abm_):
69
69
70
70
void LBMContentMapping::deleteContents ()
71
71
{
72
- for (std::vector<LoadingBlockModifierDef *>::iterator it = lbm_list.begin ();
73
- it != lbm_list.end (); ++it) {
74
- delete *it;
72
+ for (auto &it : lbm_list) {
73
+ delete it;
75
74
}
76
75
}
77
76
@@ -83,24 +82,21 @@ void LBMContentMapping::addLBM(LoadingBlockModifierDef *lbm_def, IGameDef *gamed
83
82
84
83
lbm_list.push_back (lbm_def);
85
84
86
- for (std::set<std::string>::const_iterator it = lbm_def->trigger_contents .begin ();
87
- it != lbm_def->trigger_contents .end (); ++it) {
85
+ for (const std::string &nodeTrigger: lbm_def->trigger_contents ) {
88
86
std::set<content_t > c_ids;
89
- bool found = nodedef->getIds (*it , c_ids);
87
+ bool found = nodedef->getIds (nodeTrigger , c_ids);
90
88
if (!found) {
91
- content_t c_id = gamedef->allocateUnknownNodeId (*it );
89
+ content_t c_id = gamedef->allocateUnknownNodeId (nodeTrigger );
92
90
if (c_id == CONTENT_IGNORE) {
93
91
// Seems it can't be allocated.
94
- warningstream << " Could not internalize node name \" " << *it
92
+ warningstream << " Could not internalize node name \" " << nodeTrigger
95
93
<< " \" while loading LBM \" " << lbm_def->name << " \" ." << std::endl;
96
94
continue ;
97
95
}
98
96
c_ids.insert (c_id);
99
97
}
100
98
101
- for (std::set<content_t >::const_iterator iit =
102
- c_ids.begin (); iit != c_ids.end (); ++iit) {
103
- content_t c_id = *iit;
99
+ for (content_t c_id : c_ids) {
104
100
map[c_id].push_back (lbm_def);
105
101
}
106
102
}
@@ -120,13 +116,12 @@ LBMContentMapping::lookup(content_t c) const
120
116
121
117
LBMManager::~LBMManager ()
122
118
{
123
- for (std::map<std::string, LoadingBlockModifierDef *>::iterator it =
124
- m_lbm_defs.begin (); it != m_lbm_defs.end (); ++it) {
125
- delete it->second ;
119
+ for (auto &m_lbm_def : m_lbm_defs) {
120
+ delete m_lbm_def.second ;
126
121
}
127
- for (lbm_lookup_map::iterator it = m_lbm_lookup. begin ();
128
- it != m_lbm_lookup. end (); ++it ) {
129
- (it-> second ).deleteContents ();
122
+
123
+ for ( auto &it : m_lbm_lookup ) {
124
+ (it. second ).deleteContents ();
130
125
}
131
126
}
132
127
@@ -212,12 +207,11 @@ void LBMManager::loadIntroductionTimes(const std::string ×,
212
207
LBMContentMapping &lbms_we_introduce_now = m_lbm_lookup[now];
213
208
LBMContentMapping &lbms_running_always = m_lbm_lookup[U32_MAX];
214
209
215
- for (std::map<std::string, LoadingBlockModifierDef *>::iterator it =
216
- m_lbm_defs.begin (); it != m_lbm_defs.end (); ++it) {
217
- if (it->second ->run_at_every_load ) {
218
- lbms_running_always.addLBM (it->second , gamedef);
210
+ for (auto &m_lbm_def : m_lbm_defs) {
211
+ if (m_lbm_def.second ->run_at_every_load ) {
212
+ lbms_running_always.addLBM (m_lbm_def.second , gamedef);
219
213
} else {
220
- lbms_we_introduce_now.addLBM (it-> second , gamedef);
214
+ lbms_we_introduce_now.addLBM (m_lbm_def. second , gamedef);
221
215
}
222
216
}
223
217
@@ -233,18 +227,16 @@ std::string LBMManager::createIntroductionTimesString()
233
227
" attempted to query on non fully set up LBMManager" );
234
228
235
229
std::ostringstream oss;
236
- for (lbm_lookup_map::iterator it = m_lbm_lookup.begin ();
237
- it != m_lbm_lookup.end (); ++it) {
238
- u32 time = it->first ;
239
- std::vector<LoadingBlockModifierDef *> &lbm_list = it->second .lbm_list ;
240
- for (std::vector<LoadingBlockModifierDef *>::iterator iit = lbm_list.begin ();
241
- iit != lbm_list.end (); ++iit) {
230
+ for (const auto &it : m_lbm_lookup) {
231
+ u32 time = it.first ;
232
+ const std::vector<LoadingBlockModifierDef *> &lbm_list = it.second .lbm_list ;
233
+ for (const auto &lbm_def : lbm_list) {
242
234
// Don't add if the LBM runs at every load,
243
235
// then introducement time is hardcoded
244
236
// and doesn't need to be stored
245
- if ((*iit) ->run_at_every_load )
237
+ if (lbm_def ->run_at_every_load )
246
238
continue ;
247
- oss << (*iit) ->name << " ~" << time << " ;" ;
239
+ oss << lbm_def ->name << " ~" << time << " ;" ;
248
240
}
249
241
}
250
242
return oss.str ();
@@ -272,9 +264,8 @@ void LBMManager::applyLBMs(ServerEnvironment *env, MapBlock *block, u32 stamp)
272
264
iit->second .lookup (c);
273
265
if (!lbm_list)
274
266
continue ;
275
- for (std::vector<LoadingBlockModifierDef *>::const_iterator iit =
276
- lbm_list->begin (); iit != lbm_list->end (); ++iit) {
277
- (*iit)->trigger (env, pos + pos_of_block, n);
267
+ for (auto lbmdef : *lbm_list) {
268
+ lbmdef->trigger (env, pos + pos_of_block, n);
278
269
}
279
270
}
280
271
}
0 commit comments