mirror of
https://github.com/minetest/minetest.git
synced 2024-11-09 17:23:45 +01:00
Write common mapgen params to map_meta.txt on world initialization
This commit is contained in:
parent
80a7408e4d
commit
ad690c46b1
@ -380,9 +380,12 @@ void EmergeManager::loadParamsFromSettings(Settings *settings)
|
||||
|
||||
delete params.sparams;
|
||||
params.sparams = createMapgenParams(params.mg_name);
|
||||
if (params.sparams)
|
||||
|
||||
if (params.sparams) {
|
||||
params.sparams->readParams(g_settings);
|
||||
params.sparams->readParams(settings);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EmergeManager::saveParamsToSettings(Settings *settings)
|
||||
|
@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "porting.h"
|
||||
#include "filesys.h"
|
||||
#include "settings.h"
|
||||
#include "main.h"
|
||||
#include "log.h"
|
||||
#include "strfnd.h"
|
||||
#ifndef SERVER
|
||||
@ -266,14 +267,36 @@ std::vector<WorldSpec> getAvailableWorlds()
|
||||
bool initializeWorld(const std::string &path, const std::string &gameid)
|
||||
{
|
||||
infostream << "Initializing world at " << path << std::endl;
|
||||
// Create world.mt if does not already exist
|
||||
std::string worldmt_path = path + DIR_DELIM + "world.mt";
|
||||
if(!fs::PathExists(worldmt_path)){
|
||||
infostream<<"Creating world.mt ("<<worldmt_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)) {
|
||||
std::ostringstream ss(std::ios_base::binary);
|
||||
ss << "gameid = " << gameid << "\nbackend = sqlite3\n";
|
||||
fs::safeWriteToFile(worldmt_path, ss.str());
|
||||
if (!fs::safeWriteToFile(worldmt_path, ss.str()))
|
||||
return false;
|
||||
|
||||
infostream << "Wrote world.mt (" << worldmt_path << ")" << std::endl;
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
infostream << "Wrote map_meta.txt (" << mapmeta_path << ")" << std::endl;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user