X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fsubgame.cpp;h=cd2aa752b56c96ee5049eb1d557d2070569fc615;hb=48cd217e3b6f53af32802c1897ddd1914d215078;hp=20f5116e2b7772238c4a00a4e08e192137d3d70c;hpb=21944a0d3c5284f6bf1e61286ddbcc2ab2f1e2aa;p=minetest.git diff --git a/src/subgame.cpp b/src/subgame.cpp index 20f5116e2..cd2aa752b 100644 --- a/src/subgame.cpp +++ b/src/subgame.cpp @@ -22,7 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "filesys.h" #include "settings.h" #include "log.h" -#include "strfnd.h" +#include "util/strfnd.h" #include "defaultsettings.h" // for override_default_settings #include "mapgen.h" // for MapgenParams #include "util/string.h" @@ -79,7 +79,7 @@ SubgameSpec findSubgame(const std::string &id) Strfnd search_paths(getSubgamePathEnv()); - while (!search_paths.atend()) { + while (!search_paths.at_end()) { std::string path = search_paths.next(PATH_DELIM); find_paths.push_back(GameFindPath( path + DIR_DELIM + id, false)); @@ -153,7 +153,7 @@ std::set getAvailableGameIds() Strfnd search_paths(getSubgamePathEnv()); - while (!search_paths.atend()) + while (!search_paths.at_end()) gamespaths.insert(search_paths.next(PATH_DELIM)); for (std::set::const_iterator i = gamespaths.begin(); @@ -230,7 +230,7 @@ std::vector getAvailableWorlds() Strfnd search_paths(getWorldPathEnv()); - while (!search_paths.atend()) + while (!search_paths.at_end()) worldspaths.insert(search_paths.next(PATH_DELIM)); worldspaths.insert(porting::path_user + DIR_DELIM + "worlds"); @@ -291,16 +291,16 @@ bool loadGameConfAndInitWorld(const std::string &path, const SubgameSpec &gamesp // Create world.mt if does not already exist std::string worldmt_path = path + DIR_DELIM "world.mt"; if (!fs::PathExists(worldmt_path)) { - std::ostringstream ss(std::ios_base::binary); - ss << "gameid = " << gamespec.id - << "\nbackend = sqlite3" - << "\ncreative_mode = " << g_settings->get("creative_mode") - << "\nenable_damage = " << g_settings->get("enable_damage") - << "\n"; - if (!fs::safeWriteToFile(worldmt_path, ss.str())) - return false; + Settings conf; - infostream << "Wrote world.mt (" << worldmt_path << ")" << std::endl; + 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 @@ -313,8 +313,8 @@ bool loadGameConfAndInitWorld(const std::string &path, const SubgameSpec &gamesp Settings conf; MapgenParams params; - params.load(*g_settings); - params.save(conf); + params.readParams(g_settings); + params.writeParams(&conf); conf.writeLines(oss); oss << "[end_of_params]\n";