#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"
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));
Strfnd search_paths(getSubgamePathEnv());
- while (!search_paths.atend())
+ while (!search_paths.at_end())
gamespaths.insert(search_paths.next(PATH_DELIM));
for (std::set<std::string>::const_iterator i = gamespaths.begin();
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");
// 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
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";