@@ -1169,17 +1169,13 @@ void ServerEnvironment::step(float dtime)
1169
1169
*/
1170
1170
{
1171
1171
ScopeProfiler sp (g_profiler, " SEnv: handle players avg" , SPT_AVG);
1172
- for (std::vector<RemotePlayer *>::iterator i = m_players.begin ();
1173
- i != m_players.end (); ++i) {
1174
- RemotePlayer *player = dynamic_cast <RemotePlayer *>(*i);
1175
- assert (player);
1176
-
1172
+ for (RemotePlayer *player : m_players) {
1177
1173
// Ignore disconnected players
1178
- if (player->peer_id == 0 )
1174
+ if (player->peer_id == 0 )
1179
1175
continue ;
1180
1176
1181
1177
// Move
1182
- player->move (dtime, this , 100 * BS);
1178
+ player->move (dtime, this , 100 * BS);
1183
1179
}
1184
1180
}
1185
1181
@@ -1192,21 +1188,16 @@ void ServerEnvironment::step(float dtime)
1192
1188
Get player block positions
1193
1189
*/
1194
1190
std::vector<v3s16> players_blockpos;
1195
- for (std::vector<RemotePlayer *>::iterator i = m_players.begin ();
1196
- i != m_players.end (); ++i) {
1197
- RemotePlayer *player = dynamic_cast <RemotePlayer *>(*i);
1198
- assert (player);
1199
-
1191
+ for (RemotePlayer *player: m_players) {
1200
1192
// Ignore disconnected players
1201
1193
if (player->peer_id == 0 )
1202
1194
continue ;
1203
1195
1204
1196
PlayerSAO *playersao = player->getPlayerSAO ();
1205
1197
assert (playersao);
1206
1198
1207
- v3s16 blockpos = getNodeBlockPos (
1208
- floatToInt (playersao->getBasePosition (), BS));
1209
- players_blockpos.push_back (blockpos);
1199
+ players_blockpos.push_back (
1200
+ getNodeBlockPos (floatToInt (playersao->getBasePosition (), BS)));
1210
1201
}
1211
1202
1212
1203
/*
@@ -1226,16 +1217,9 @@ void ServerEnvironment::step(float dtime)
1226
1217
// Convert active objects that are no more in active blocks to static
1227
1218
deactivateFarObjects (false );
1228
1219
1229
- for (std::set<v3s16>::iterator
1230
- i = blocks_removed.begin ();
1231
- i != blocks_removed.end (); ++i) {
1232
- v3s16 p = *i;
1233
-
1234
- /* infostream<<"Server: Block " << PP(p)
1235
- << " became inactive"<<std::endl; */
1236
-
1220
+ for (const v3s16 &p: blocks_removed) {
1237
1221
MapBlock *block = m_map->getBlockNoCreateNoEx (p);
1238
- if ( block== NULL )
1222
+ if (! block)
1239
1223
continue ;
1240
1224
1241
1225
// Set current time as timestamp (and let it set ChangedFlag)
@@ -1246,21 +1230,14 @@ void ServerEnvironment::step(float dtime)
1246
1230
Handle added blocks
1247
1231
*/
1248
1232
1249
- for (std::set<v3s16>::iterator
1250
- i = blocks_added.begin ();
1251
- i != blocks_added.end (); ++i)
1252
- {
1253
- v3s16 p = *i;
1254
-
1233
+ for (const v3s16 &p: blocks_added) {
1255
1234
MapBlock *block = m_map->getBlockOrEmerge (p);
1256
- if ( block== NULL ) {
1235
+ if (! block) {
1257
1236
m_active_blocks.m_list .erase (p);
1258
1237
continue ;
1259
1238
}
1260
1239
1261
1240
activateBlock (block);
1262
- /* infostream<<"Server: Block " << PP(p)
1263
- << " became active"<<std::endl; */
1264
1241
}
1265
1242
}
1266
1243
@@ -1272,17 +1249,9 @@ void ServerEnvironment::step(float dtime)
1272
1249
1273
1250
float dtime = m_cache_nodetimer_interval;
1274
1251
1275
- for (std::set<v3s16>::iterator
1276
- i = m_active_blocks.m_list .begin ();
1277
- i != m_active_blocks.m_list .end (); ++i)
1278
- {
1279
- v3s16 p = *i;
1280
-
1281
- /* infostream<<"Server: Block ("<<p.X<<","<<p.Y<<","<<p.Z
1282
- <<") being handled"<<std::endl;*/
1283
-
1252
+ for (const v3s16 &p: m_active_blocks.m_list ) {
1284
1253
MapBlock *block = m_map->getBlockNoCreateNoEx (p);
1285
- if ( block== NULL )
1254
+ if (! block)
1286
1255
continue ;
1287
1256
1288
1257
// Reset block usage timer
@@ -1297,26 +1266,25 @@ void ServerEnvironment::step(float dtime)
1297
1266
MOD_REASON_BLOCK_EXPIRED);
1298
1267
1299
1268
// Run node timers
1300
- std::vector<NodeTimer> elapsed_timers =
1301
- block->m_node_timers .step ((float )dtime);
1269
+ std::vector<NodeTimer> elapsed_timers = block->m_node_timers .step (dtime);
1302
1270
if (!elapsed_timers.empty ()) {
1303
1271
MapNode n;
1304
- for (std::vector<NodeTimer>::iterator i = elapsed_timers. begin () ;
1305
- i != elapsed_timers. end (); ++i ) {
1306
- n = block->getNodeNoEx (i-> position );
1307
- p = i-> position + block->getPosRelative ();
1308
- if (m_script->node_on_timer (p , n, i-> elapsed )) {
1272
+ v3s16 p2 ;
1273
+ for ( const NodeTimer &elapsed_timer: elapsed_timers ) {
1274
+ n = block->getNodeNoEx (elapsed_timer. position );
1275
+ p2 = elapsed_timer. position + block->getPosRelative ();
1276
+ if (m_script->node_on_timer (p2 , n, elapsed_timer. elapsed )) {
1309
1277
block->setNodeTimer (NodeTimer (
1310
- i-> timeout , 0 , i-> position ));
1278
+ elapsed_timer. timeout , 0 , elapsed_timer. position ));
1311
1279
}
1312
1280
}
1313
1281
}
1314
1282
}
1315
1283
}
1316
1284
1317
1285
if (m_active_block_modifier_interval.step (dtime, m_cache_abm_interval))
1318
- do { // breakable
1319
- if (m_active_block_interval_overload_skip > 0 ){
1286
+ do { // breakable
1287
+ if (m_active_block_interval_overload_skip > 0 ) {
1320
1288
ScopeProfiler sp (g_profiler, " SEnv: ABM overload skips" );
1321
1289
m_active_block_interval_overload_skip--;
1322
1290
break ;
@@ -1327,17 +1295,9 @@ void ServerEnvironment::step(float dtime)
1327
1295
// Initialize handling of ActiveBlockModifiers
1328
1296
ABMHandler abmhandler (m_abms, m_cache_abm_interval, this , true );
1329
1297
1330
- for (std::set<v3s16>::iterator
1331
- i = m_active_blocks.m_list .begin ();
1332
- i != m_active_blocks.m_list .end (); ++i)
1333
- {
1334
- v3s16 p = *i;
1335
-
1336
- /* infostream<<"Server: Block ("<<p.X<<","<<p.Y<<","<<p.Z
1337
- <<") being handled"<<std::endl;*/
1338
-
1298
+ for (const v3s16 &p : m_active_blocks.m_list ) {
1339
1299
MapBlock *block = m_map->getBlockNoCreateNoEx (p);
1340
- if ( block == NULL )
1300
+ if (! block)
1341
1301
continue ;
1342
1302
1343
1303
// Set current time as timestamp
@@ -1349,7 +1309,7 @@ void ServerEnvironment::step(float dtime)
1349
1309
1350
1310
u32 time_ms = timer.stop (true );
1351
1311
u32 max_time_ms = 200 ;
1352
- if (time_ms > max_time_ms){
1312
+ if (time_ms > max_time_ms) {
1353
1313
warningstream<<" active block modifiers took "
1354
1314
<<time_ms<<" ms (longer than "
1355
1315
<<max_time_ms<<" ms)" <<std::endl;
@@ -1401,8 +1361,7 @@ void ServerEnvironment::step(float dtime)
1401
1361
/*
1402
1362
Manage active objects
1403
1363
*/
1404
- if (m_object_management_interval.step (dtime, 0.5 ))
1405
- {
1364
+ if (m_object_management_interval.step (dtime, 0.5 )) {
1406
1365
ScopeProfiler sp (g_profiler, " SEnv: remove removed objs avg /.5s" , SPT_AVG);
1407
1366
/*
1408
1367
Remove objects that satisfy (m_removed && m_known_by_count==0)
@@ -1461,9 +1420,9 @@ u32 ServerEnvironment::addParticleSpawner(float exptime, u16 attached_id)
1461
1420
void ServerEnvironment::deleteParticleSpawner (u32 id, bool remove_from_object)
1462
1421
{
1463
1422
m_particle_spawners.erase (id);
1464
- std::unordered_map<u32, u16>::iterator it = m_particle_spawner_attachments.find (id);
1423
+ const auto & it = m_particle_spawner_attachments.find (id);
1465
1424
if (it != m_particle_spawner_attachments.end ()) {
1466
- u16 obj_id = (*it). second ;
1425
+ u16 obj_id = it-> second ;
1467
1426
ServerActiveObject *sao = getActiveObject (obj_id);
1468
1427
if (sao != NULL && remove_from_object) {
1469
1428
sao->detachParticleSpawner (id);
0 commit comments