@@ -211,7 +211,7 @@ int main(int argc, char *argv[])
211
211
#endif
212
212
213
213
// Update configuration file
214
- if (g_settings_path != " " )
214
+ if (!g_settings_path. empty () )
215
215
g_settings->updateConfigFile (g_settings_path.c_str ());
216
216
217
217
print_modified_quicktune_values ();
@@ -306,17 +306,16 @@ static void print_help(const OptionList &allowed_options)
306
306
307
307
static void print_allowed_options (const OptionList &allowed_options)
308
308
{
309
- for (OptionList::const_iterator i = allowed_options.begin ();
310
- i != allowed_options.end (); ++i) {
309
+ for (const auto &allowed_option : allowed_options) {
311
310
std::ostringstream os1 (std::ios::binary);
312
- os1 << " --" << i-> first ;
313
- if (i-> second .type != VALUETYPE_FLAG)
311
+ os1 << " --" << allowed_option. first ;
312
+ if (allowed_option. second .type != VALUETYPE_FLAG)
314
313
os1 << _ (" <value>" );
315
314
316
315
std::cout << padStringRight (os1.str (), 30 );
317
316
318
- if (i-> second .help )
319
- std::cout << i-> second .help ;
317
+ if (allowed_option. second .help )
318
+ std::cout << allowed_option. second .help ;
320
319
321
320
std::cout << std::endl;
322
321
}
@@ -335,9 +334,8 @@ static void print_version()
335
334
static void list_game_ids ()
336
335
{
337
336
std::set<std::string> gameids = getAvailableGameIds ();
338
- for (std::set<std::string>::const_iterator i = gameids.begin ();
339
- i != gameids.end (); ++i)
340
- std::cout << (*i) <<std::endl;
337
+ for (const std::string &gameid : gameids)
338
+ std::cout << gameid <<std::endl;
341
339
}
342
340
343
341
static void list_worlds ()
@@ -350,10 +348,10 @@ static void list_worlds()
350
348
static void print_worldspecs (const std::vector<WorldSpec> &worldspecs,
351
349
std::ostream &os)
352
350
{
353
- for (size_t i = 0 ; i < worldspecs. size (); i++ ) {
354
- std::string name = worldspecs[i] .name ;
355
- std::string path = worldspecs[i] .path ;
356
- if (name.find (" " ) != std::string::npos)
351
+ for (const WorldSpec &worldspec : worldspecs) {
352
+ std::string name = worldspec .name ;
353
+ std::string path = worldspec .path ;
354
+ if (name.find (' ' ) != std::string::npos)
357
355
name = std::string (" '" ) + name + " '" ;
358
356
path = std::string (" '" ) + path + " '" ;
359
357
name = padStringRight (name, 14 );
@@ -366,15 +364,15 @@ static void print_modified_quicktune_values()
366
364
bool header_printed = false ;
367
365
std::vector<std::string> names = getQuicktuneNames ();
368
366
369
- for (u32 i = 0 ; i < names. size (); i++ ) {
370
- QuicktuneValue val = getQuicktuneValue (names[i] );
367
+ for (const std::string &name : names) {
368
+ QuicktuneValue val = getQuicktuneValue (name );
371
369
if (!val.modified )
372
370
continue ;
373
371
if (!header_printed) {
374
372
dstream << " Modified quicktune values:" << std::endl;
375
373
header_printed = true ;
376
374
}
377
- dstream << names[i] << " = " << val.getString () << std::endl;
375
+ dstream << name << " = " << val.getString () << std::endl;
378
376
}
379
377
}
380
378
@@ -485,16 +483,16 @@ static bool read_config_file(const Settings &cmd_args)
485
483
DIR_DELIM + " .." + DIR_DELIM + " .." + DIR_DELIM + " minetest.conf" );
486
484
#endif
487
485
488
- for (size_t i = 0 ; i < filenames. size (); i++ ) {
489
- bool r = g_settings->readConfigFile (filenames[i] .c_str ());
486
+ for (const std::string &filename : filenames) {
487
+ bool r = g_settings->readConfigFile (filename .c_str ());
490
488
if (r) {
491
- g_settings_path = filenames[i] ;
489
+ g_settings_path = filename ;
492
490
break ;
493
491
}
494
492
}
495
493
496
494
// If no path found, use the first one (menu creates the file)
497
- if (g_settings_path == " " )
495
+ if (g_settings_path. empty () )
498
496
g_settings_path = filenames[0 ];
499
497
}
500
498
@@ -540,7 +538,7 @@ static void init_log_streams(const Settings &cmd_args)
540
538
541
539
verbosestream << " log_filename = " << log_filename << std::endl;
542
540
543
- file_log_output.open (log_filename. c_str () );
541
+ file_log_output.open (log_filename);
544
542
g_logger.addOutputMaxLevel (&file_log_output, log_level);
545
543
}
546
544
@@ -573,6 +571,7 @@ static bool game_configure_world(GameParams *game_params, const Settings &cmd_ar
573
571
{
574
572
if (get_world_from_cmdline (game_params, cmd_args))
575
573
return true ;
574
+
576
575
if (get_world_from_config (game_params, cmd_args))
577
576
return true ;
578
577
@@ -581,24 +580,24 @@ static bool game_configure_world(GameParams *game_params, const Settings &cmd_ar
581
580
582
581
static bool get_world_from_cmdline (GameParams *game_params, const Settings &cmd_args)
583
582
{
584
- std::string commanded_world = " " ;
583
+ std::string commanded_world;
585
584
586
585
// World name
587
- std::string commanded_worldname = " " ;
586
+ std::string commanded_worldname;
588
587
if (cmd_args.exists (" worldname" ))
589
588
commanded_worldname = cmd_args.get (" worldname" );
590
589
591
590
// If a world name was specified, convert it to a path
592
- if (commanded_worldname != " " ) {
591
+ if (!commanded_worldname. empty () ) {
593
592
// Get information about available worlds
594
593
std::vector<WorldSpec> worldspecs = getAvailableWorlds ();
595
594
bool found = false ;
596
- for (u32 i = 0 ; i < worldspecs. size (); i++ ) {
597
- std::string name = worldspecs[i] .name ;
595
+ for (const WorldSpec &worldspec : worldspecs) {
596
+ std::string name = worldspec .name ;
598
597
if (name == commanded_worldname) {
599
598
dstream << _ (" Using world specified by --worldname on the "
600
599
" command line" ) << std::endl;
601
- commanded_world = worldspecs[i] .path ;
600
+ commanded_world = worldspec .path ;
602
601
found = true ;
603
602
break ;
604
603
}
@@ -611,7 +610,7 @@ static bool get_world_from_cmdline(GameParams *game_params, const Settings &cmd_
611
610
}
612
611
613
612
game_params->world_path = get_clean_world_path (commanded_world);
614
- return commanded_world != " " ;
613
+ return !commanded_world. empty () ;
615
614
}
616
615
617
616
if (cmd_args.exists (" world" ))
@@ -622,20 +621,20 @@ static bool get_world_from_cmdline(GameParams *game_params, const Settings &cmd_
622
621
commanded_world = cmd_args.get (" nonopt0" );
623
622
624
623
game_params->world_path = get_clean_world_path (commanded_world);
625
- return commanded_world != " " ;
624
+ return !commanded_world. empty () ;
626
625
}
627
626
628
627
static bool get_world_from_config (GameParams *game_params, const Settings &cmd_args)
629
628
{
630
629
// World directory
631
- std::string commanded_world = " " ;
630
+ std::string commanded_world;
632
631
633
632
if (g_settings->exists (" map-dir" ))
634
633
commanded_world = g_settings->get (" map-dir" );
635
634
636
635
game_params->world_path = get_clean_world_path (commanded_world);
637
636
638
- return commanded_world != " " ;
637
+ return !commanded_world. empty () ;
639
638
}
640
639
641
640
static bool auto_select_world (GameParams *game_params)
@@ -729,8 +728,8 @@ static bool determine_subgame(GameParams *game_params)
729
728
730
729
verbosestream << _ (" Determining gameid/gamespec" ) << std::endl;
731
730
// If world doesn't exist
732
- if (game_params->world_path != " "
733
- && !getWorldExists (game_params->world_path )) {
731
+ if (! game_params->world_path . empty ()
732
+ && !getWorldExists (game_params->world_path )) {
734
733
// Try to take gamespec from command line
735
734
if (game_params->game_spec .isValid ()) {
736
735
gamespec = game_params->game_spec ;
@@ -810,7 +809,8 @@ static bool run_dedicated_server(const GameParams &game_params, const Settings &
810
809
// Database migration
811
810
if (cmd_args.exists (" migrate" ))
812
811
return migrate_map_database (game_params, cmd_args);
813
- else if (cmd_args.exists (" migrate-players" ))
812
+
813
+ if (cmd_args.exists (" migrate-players" ))
814
814
return ServerEnvironment::migratePlayersDatabase (game_params, cmd_args);
815
815
816
816
if (cmd_args.exists (" terminal" )) {
0 commit comments