forked from Mirrorlandia_minetest/minetest
EmergeManager: Fix Lua mapgen override param handling
This commit is contained in:
parent
bbae8eb751
commit
83cc882335
@ -181,8 +181,15 @@ void EmergeManager::initMapgens(MapgenParams *mgparams) {
|
||||
|
||||
// Apply mapgen parameter overrides from Lua
|
||||
if (luaoverride_params) {
|
||||
if (luaoverride_params_modified & MGPARAMS_SET_MGNAME)
|
||||
mgparams->mg_name = luaoverride_params->mg_name;
|
||||
if (luaoverride_params_modified & MGPARAMS_SET_MGNAME) {
|
||||
MapgenParams *mgp = setMapgenType(mgparams, luaoverride_params->mg_name);
|
||||
if (!mgp) {
|
||||
errorstream << "EmergeManager: Failed to set new mapgen name"
|
||||
<< std::endl;
|
||||
} else {
|
||||
mgparams = mgp;
|
||||
}
|
||||
}
|
||||
|
||||
if (luaoverride_params_modified & MGPARAMS_SET_SEED)
|
||||
mgparams->seed = luaoverride_params->seed;
|
||||
@ -202,18 +209,47 @@ void EmergeManager::initMapgens(MapgenParams *mgparams) {
|
||||
// Create the mapgens
|
||||
this->params = mgparams;
|
||||
for (size_t i = 0; i != emergethread.size(); i++) {
|
||||
mg = createMapgen(params->mg_name, 0, params);
|
||||
mg = createMapgen(params->mg_name, i, params);
|
||||
if (!mg) {
|
||||
infostream << "EmergeManager: falling back to mapgen v6" << std::endl;
|
||||
delete params;
|
||||
params = createMapgenParams("v6");
|
||||
mg = createMapgen("v6", 0, params);
|
||||
infostream << "EmergeManager: Falling back to Mapgen V6" << std::endl;
|
||||
|
||||
params = setMapgenType(params, "v6");
|
||||
mg = createMapgen(params->mg_name, i, params);
|
||||
if (!mg) {
|
||||
errorstream << "EmergeManager: CRITICAL ERROR: Failed to fall"
|
||||
"back to Mapgen V6, not generating map" << std::endl;
|
||||
}
|
||||
}
|
||||
mapgen.push_back(mg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MapgenParams *EmergeManager::setMapgenType(MapgenParams *mgparams,
|
||||
std::string newname) {
|
||||
MapgenParams *newparams = createMapgenParams(newname);
|
||||
if (!newparams) {
|
||||
errorstream << "EmergeManager: Mapgen override failed" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
newparams->mg_name = newname;
|
||||
newparams->seed = mgparams->seed;
|
||||
newparams->water_level = mgparams->water_level;
|
||||
newparams->chunksize = mgparams->chunksize;
|
||||
newparams->flags = mgparams->flags;
|
||||
|
||||
if (!newparams->readParams(g_settings)) {
|
||||
errorstream << "EmergeManager: Mapgen override failed" << std::endl;
|
||||
delete newparams;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
delete mgparams;
|
||||
return newparams;
|
||||
}
|
||||
|
||||
|
||||
Mapgen *EmergeManager::getCurrentMapgen() {
|
||||
for (unsigned int i = 0; i != emergethread.size(); i++) {
|
||||
if (emergethread[i]->IsSameThread())
|
||||
@ -229,6 +265,7 @@ void EmergeManager::triggerAllThreads() {
|
||||
emergethread[i]->trigger();
|
||||
}
|
||||
|
||||
|
||||
bool EmergeManager::enqueueBlockEmerge(u16 peer_id, v3s16 p, bool allow_generate) {
|
||||
std::map<v3s16, BlockEmergeData *>::const_iterator iter;
|
||||
BlockEmergeData *bedata;
|
||||
@ -483,7 +520,7 @@ void *EmergeThread::Thread() {
|
||||
MapBlock *block = NULL;
|
||||
std::map<v3s16, MapBlock *> modified_blocks;
|
||||
|
||||
if (getBlockOrStartGen(p, &block, &data, allow_generate)) {
|
||||
if (getBlockOrStartGen(p, &block, &data, allow_generate) && mapgen) {
|
||||
{
|
||||
ScopeProfiler sp(g_profiler, "EmergeThread: Mapgen::makeChunk", SPT_AVG);
|
||||
TimeTaker t("mapgen::make_block()");
|
||||
|
@ -112,6 +112,7 @@ public:
|
||||
~EmergeManager();
|
||||
|
||||
void initMapgens(MapgenParams *mgparams);
|
||||
MapgenParams *setMapgenType(MapgenParams *mgparams, std::string newname);
|
||||
Mapgen *getCurrentMapgen();
|
||||
Mapgen *createMapgen(std::string mgname, int mgid,
|
||||
MapgenParams *mgparams);
|
||||
|
Loading…
Reference in New Issue
Block a user