From f6e4c5d9cf459e8278a76a2beaee59732e841458 Mon Sep 17 00:00:00 2001 From: ngosang Date: Mon, 26 Jan 2015 12:44:49 +0100 Subject: Respect game mapgen flags and save world noise params --- src/subgame.cpp | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'src/subgame.cpp') diff --git a/src/subgame.cpp b/src/subgame.cpp index ccf477e8f..4e8777d13 100644 --- a/src/subgame.cpp +++ b/src/subgame.cpp @@ -24,6 +24,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "main.h" #include "log.h" #include "strfnd.h" +#include "defaultsettings.h" // for override_default_settings +#include "mapgen.h" // for MapgenParams +#include "main.h" // for g_settings #ifndef SERVER #include "client/tile.h" // getImagePath #endif @@ -270,6 +273,12 @@ bool initializeWorld(const std::string &path, const std::string &gameid) fs::CreateAllDirs(path); + // Initialize default settings and override defaults with those + // provided by the game + Settings game_defaults; + getGameMinetestConfig(path, game_defaults); + override_default_settings(g_settings, &game_defaults); + // Create world.mt if does not already exist std::string worldmt_path = path + DIR_DELIM "world.mt"; if (!fs::PathExists(worldmt_path)) { @@ -282,21 +291,22 @@ bool initializeWorld(const std::string &path, const std::string &gameid) } // Create map_meta.txt if does not already exist - std::string mapmeta_path = path + DIR_DELIM "map_meta.txt"; - if (!fs::PathExists(mapmeta_path)) { - std::ostringstream ss(std::ios_base::binary); - ss - << "mg_name = " << g_settings->get("mg_name") - << "\nseed = " << g_settings->get("fixed_map_seed") - << "\nchunksize = " << g_settings->get("chunksize") - << "\nwater_level = " << g_settings->get("water_level") - << "\nmg_flags = " << g_settings->get("mg_flags") - << "\n[end_of_params]\n"; - if (!fs::safeWriteToFile(mapmeta_path, ss.str())) - return false; + 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); - infostream << "Wrote map_meta.txt (" << mapmeta_path << ")" << std::endl; - } + Settings conf; + MapgenParams params; + params.load(*g_settings); + params.save(conf); + conf.writeLines(oss); + oss << "[end_of_params]\n"; + + fs::safeWriteToFile(map_meta_path, oss.str()); + } return true; } + -- cgit v1.2.3