Use a string identifier for a mapgen instead of version
parent
318669327e
commit
b87cd8c58b
|
@ -174,7 +174,7 @@ void set_default_settings(Settings *settings)
|
||||||
settings->setDefault("remote_media", "");
|
settings->setDefault("remote_media", "");
|
||||||
|
|
||||||
//mapgen related things
|
//mapgen related things
|
||||||
settings->setDefault("mg_version", "6");
|
settings->setDefault("mg_name", "v6");
|
||||||
settings->setDefault("water_level", "1");
|
settings->setDefault("water_level", "1");
|
||||||
settings->setDefault("chunksize", "5");
|
settings->setDefault("chunksize", "5");
|
||||||
settings->setDefault("mg_flags", "19");
|
settings->setDefault("mg_flags", "19");
|
||||||
|
|
10
src/map.cpp
10
src/map.cpp
|
@ -3079,15 +3079,15 @@ void ServerMap::saveMapMeta()
|
||||||
|
|
||||||
Settings params;
|
Settings params;
|
||||||
|
|
||||||
params.setS16("mg_version", m_emerge->params->mg_version);
|
params.set("mg_name", m_emerge->params->mg_name);
|
||||||
|
|
||||||
params.setU64("seed", m_emerge->params->seed);
|
params.setU64("seed", m_emerge->params->seed);
|
||||||
params.setS16("water_level", m_emerge->params->water_level);
|
params.setS16("water_level", m_emerge->params->water_level);
|
||||||
params.setS16("chunksize", m_emerge->params->chunksize);
|
params.setS16("chunksize", m_emerge->params->chunksize);
|
||||||
params.setS32("mg_flags", m_emerge->params->flags);
|
params.setS32("mg_flags", m_emerge->params->flags);
|
||||||
switch (m_emerge->params->mg_version) {
|
/* switch (m_emerge->params->mg_version) {
|
||||||
case 6:
|
case 6:
|
||||||
{
|
{*/
|
||||||
MapgenV6Params *v6params = (MapgenV6Params *)m_emerge->params;
|
MapgenV6Params *v6params = (MapgenV6Params *)m_emerge->params;
|
||||||
|
|
||||||
params.setFloat("mgv6_freq_desert", v6params->freq_desert);
|
params.setFloat("mgv6_freq_desert", v6params->freq_desert);
|
||||||
|
@ -3101,11 +3101,11 @@ void ServerMap::saveMapMeta()
|
||||||
params.setNoiseParams("mgv6_np_beach", v6params->np_beach);
|
params.setNoiseParams("mgv6_np_beach", v6params->np_beach);
|
||||||
params.setNoiseParams("mgv6_np_biome", v6params->np_biome);
|
params.setNoiseParams("mgv6_np_biome", v6params->np_biome);
|
||||||
params.setNoiseParams("mgv6_np_cave", v6params->np_cave);
|
params.setNoiseParams("mgv6_np_cave", v6params->np_cave);
|
||||||
break;
|
/* break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
; //complain here
|
; //complain here
|
||||||
}
|
}*/
|
||||||
|
|
||||||
params.writeLines(os);
|
params.writeLines(os);
|
||||||
|
|
||||||
|
|
|
@ -78,16 +78,16 @@ EmergeManager::~EmergeManager() {
|
||||||
|
|
||||||
Mapgen *EmergeManager::getMapgen() {
|
Mapgen *EmergeManager::getMapgen() {
|
||||||
if (!mapgen) {
|
if (!mapgen) {
|
||||||
switch (params->mg_version) {
|
/*switch (params->mg_version) {
|
||||||
case 6:
|
case 6:*/
|
||||||
mapgen = new MapgenV6(0, (MapgenV6Params *)params);
|
mapgen = new MapgenV6(0, (MapgenV6Params *)params);
|
||||||
break;
|
/* break;
|
||||||
default:
|
default:
|
||||||
errorstream << "EmergeManager: Unsupported mapgen version "
|
errorstream << "EmergeManager: Unsupported mapgen version "
|
||||||
<< params->mg_version << ", falling back to V6" << std::endl;
|
<< params->mg_version << ", falling back to V6" << std::endl;
|
||||||
params->mg_version = 6;
|
params->mg_version = 6;
|
||||||
mapgen = new MapgenV6(0, (MapgenV6Params *)params);
|
mapgen = new MapgenV6(0, (MapgenV6Params *)params);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
return mapgen;
|
return mapgen;
|
||||||
}
|
}
|
||||||
|
@ -127,28 +127,29 @@ u32 EmergeManager::getBlockSeed(v3s16 p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MapgenParams *MapgenParams::createMapgenParams(int mgver) {
|
MapgenParams *MapgenParams::createMapgenParams(std::string &mgstr) {
|
||||||
switch (mgver) {
|
return new MapgenV6Params(); // this will be fixed later
|
||||||
|
/*switch (mgver) {
|
||||||
case 6:
|
case 6:
|
||||||
return new MapgenV6Params();
|
return new MapgenV6Params();
|
||||||
default: //instead of complaining, default to 6
|
default: //instead of complaining, default to 6
|
||||||
return new MapgenV6Params();
|
return new MapgenV6Params();
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MapgenParams *MapgenParams::getParamsFromSettings(Settings *settings) {
|
MapgenParams *MapgenParams::getParamsFromSettings(Settings *settings) {
|
||||||
int mg_version = settings->getS16("mg_version");
|
std::string mg_name = settings->get("mg_name");
|
||||||
MapgenParams *mgparams = MapgenParams::createMapgenParams(mg_version);
|
MapgenParams *mgparams = MapgenParams::createMapgenParams(mg_name);
|
||||||
mgparams->mg_version = mg_version;
|
mgparams->mg_name = mg_name;
|
||||||
mgparams->seed = settings->getU64(settings == g_settings ? "fixed_map_seed" : "seed");
|
mgparams->seed = settings->getU64(settings == g_settings ? "fixed_map_seed" : "seed");
|
||||||
mgparams->water_level = settings->getS16("water_level");
|
mgparams->water_level = settings->getS16("water_level");
|
||||||
mgparams->chunksize = settings->getS16("chunksize");
|
mgparams->chunksize = settings->getS16("chunksize");
|
||||||
mgparams->flags = settings->getS32("mg_flags");
|
mgparams->flags = settings->getS32("mg_flags");
|
||||||
|
|
||||||
switch (mg_version) {
|
/* switch (mg_version) {
|
||||||
case 6:
|
case 6:
|
||||||
{
|
{*/
|
||||||
MapgenV6Params *v6params = (MapgenV6Params *)mgparams;
|
MapgenV6Params *v6params = (MapgenV6Params *)mgparams;
|
||||||
|
|
||||||
v6params->freq_desert = settings->getFloat("mgv6_freq_desert");
|
v6params->freq_desert = settings->getFloat("mgv6_freq_desert");
|
||||||
|
@ -170,13 +171,13 @@ MapgenParams *MapgenParams::getParamsFromSettings(Settings *settings) {
|
||||||
delete mgparams;
|
delete mgparams;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
delete mgparams;
|
delete mgparams;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return mgparams;
|
return mgparams;
|
||||||
|
|
||||||
|
|
|
@ -83,21 +83,21 @@ struct BlockMakeData {
|
||||||
|
|
||||||
|
|
||||||
struct MapgenParams {
|
struct MapgenParams {
|
||||||
int mg_version;
|
std::string mg_name;
|
||||||
int chunksize;
|
int chunksize;
|
||||||
u64 seed;
|
u64 seed;
|
||||||
int water_level;
|
int water_level;
|
||||||
u32 flags;
|
u32 flags;
|
||||||
|
|
||||||
MapgenParams() {
|
MapgenParams() {
|
||||||
mg_version = 6;
|
mg_name = "v6";
|
||||||
seed = 0;
|
seed = 0;
|
||||||
water_level = 1;
|
water_level = 1;
|
||||||
chunksize = 5;
|
chunksize = 5;
|
||||||
flags = MG_TREES | MG_CAVES | MGV6_BIOME_BLEND;
|
flags = MG_TREES | MG_CAVES | MGV6_BIOME_BLEND;
|
||||||
}
|
}
|
||||||
|
|
||||||
static MapgenParams *createMapgenParams(int mgver);
|
static MapgenParams *createMapgenParams(std::string &mgname);
|
||||||
static MapgenParams *getParamsFromSettings(Settings *settings);
|
static MapgenParams *getParamsFromSettings(Settings *settings);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue