@@ -396,36 +396,62 @@ ServerEnvironment::ServerEnvironment(ServerMap *map,
396
396
// Determine which database backend to use
397
397
std::string conf_path = path_world + DIR_DELIM + " world.mt" ;
398
398
Settings conf;
399
+
400
+ std::string player_backend_name = " sqlite3" ;
401
+ std::string auth_backend_name = " sqlite3" ;
402
+
399
403
bool succeeded = conf.readConfigFile (conf_path.c_str ());
400
- if (!succeeded || !conf.exists (" player_backend" )) {
401
- // fall back to files
402
- conf.set (" player_backend" , " files" );
403
- warningstream << " /!\\ You are using old player file backend. "
404
- << " This backend is deprecated and will be removed in next release /!\\ "
405
- << std::endl << " Switching to SQLite3 or PostgreSQL is advised, "
406
- << " please read http://wiki.minetest.net/Database_backends." << std::endl;
407
404
408
- if (!conf.updateConfigFile (conf_path.c_str ())) {
409
- errorstream << " ServerEnvironment::ServerEnvironment(): "
410
- << " Failed to update world.mt!" << std::endl;
405
+ // If we open world.mt read the backend configurations.
406
+ if (succeeded) {
407
+ // Read those values before setting defaults
408
+ bool player_backend_exists = conf.exists (" player_backend" );
409
+ bool auth_backend_exists = conf.exists (" auth_backend" );
410
+
411
+ // player backend is not set, assume it's legacy file backend.
412
+ if (!player_backend_exists) {
413
+ // fall back to files
414
+ conf.set (" player_backend" , " files" );
415
+ player_backend_name = " files" ;
416
+
417
+ if (!conf.updateConfigFile (conf_path.c_str ())) {
418
+ errorstream << " ServerEnvironment::ServerEnvironment(): "
419
+ << " Failed to update world.mt!" << std::endl;
420
+ }
421
+ } else {
422
+ conf.getNoEx (" player_backend" , player_backend_name);
411
423
}
412
- }
413
424
414
- std::string name;
415
- conf.getNoEx (" player_backend" , name);
416
- m_player_database = openPlayerDatabase (name, path_world, conf);
425
+ // auth backend is not set, assume it's legacy file backend.
426
+ if (!auth_backend_exists) {
427
+ conf.set (" auth_backend" , " files" );
428
+ auth_backend_name = " files" ;
417
429
418
- std::string auth_name = " files" ;
419
- if (conf.exists (" auth_backend" )) {
420
- conf.getNoEx (" auth_backend" , auth_name);
421
- } else {
422
- conf.set (" auth_backend" , " files" );
423
- if (!conf.updateConfigFile (conf_path.c_str ())) {
424
- errorstream << " ServerEnvironment::ServerEnvironment(): "
425
- << " Failed to update world.mt!" << std::endl;
430
+ if (!conf.updateConfigFile (conf_path.c_str ())) {
431
+ errorstream << " ServerEnvironment::ServerEnvironment(): "
432
+ << " Failed to update world.mt!" << std::endl;
433
+ }
434
+ } else {
435
+ conf.getNoEx (" auth_backend" , auth_backend_name);
426
436
}
427
437
}
428
- m_auth_database = openAuthDatabase (auth_name, path_world, conf);
438
+
439
+ if (player_backend_name == " files" ) {
440
+ warningstream << " /!\\ You are using old player file backend. "
441
+ << " This backend is deprecated and will be removed in a future release /!\\ "
442
+ << std::endl << " Switching to SQLite3 or PostgreSQL is advised, "
443
+ << " please read http://wiki.minetest.net/Database_backends." << std::endl;
444
+ }
445
+
446
+ if (auth_backend_name == " files" ) {
447
+ warningstream << " /!\\ You are using old auth file backend. "
448
+ << " This backend is deprecated and will be removed in a future release /!\\ "
449
+ << std::endl << " Switching to SQLite3 is advised, "
450
+ << " please read http://wiki.minetest.net/Database_backends." << std::endl;
451
+ }
452
+
453
+ m_player_database = openPlayerDatabase (player_backend_name, path_world, conf);
454
+ m_auth_database = openAuthDatabase (auth_backend_name, path_world, conf);
429
455
}
430
456
431
457
ServerEnvironment::~ServerEnvironment ()
0 commit comments