bool loadGameConfAndInitWorld(const std::string &path, const SubgameSpec &gamespec) { // Override defaults with those provided by the game. // We clear and reload the defaults because the defaults // might have been overridden by other subgame config // files that were loaded before. g_settings->clearDefaults(); set_default_settings(g_settings); Settings game_defaults; getGameMinetestConfig(gamespec.path, game_defaults); override_default_settings(g_settings, &game_defaults); infostream << "Initializing world at " << path << std::endl; fs::CreateAllDirs(path); // Create world.mt if does not already exist std::string worldmt_path = path + DIR_DELIM "world.mt"; if (!fs::PathExists(worldmt_path)) { Settings conf; conf.set("gameid", gamespec.id); conf.set("backend", "sqlite3"); conf.set("player_backend", "sqlite3"); conf.setBool("creative_mode", g_settings->getBool("creative_mode")); conf.setBool("enable_damage", g_settings->getBool("enable_damage")); if (!conf.updateConfigFile(worldmt_path.c_str())) return false; } // Create map_meta.txt if does not already exist std::string map_meta_path = path + DIR_DELIM + "map_meta.txt"; if (!fs::PathExists(map_meta_path)) { verbosestream << "Creating map_meta.txt (" << map_meta_path << ")" << std::endl; fs::CreateAllDirs(path); std::ostringstream oss(std::ios_base::binary); Settings conf; MapgenParams params; params.readParams(g_settings); params.writeParams(&conf); conf.writeLines(oss); oss << "[end_of_params]\n"; fs::safeWriteToFile(map_meta_path, oss.str()); } return true; }