1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add Lua on_mapgen_init callback, and minetest.set_mapgen_params API

This commit is contained in:
kwolekr 2013-06-27 17:06:52 -04:00
parent 18882a4d26
commit 2e292b67a0
18 changed files with 163 additions and 14 deletions

View file

@ -59,6 +59,10 @@ EmergeManager::EmergeManager(IGameDef *gamedef) {
this->biomedef = new BiomeDefManager();
this->params = NULL;
this->luaoverride_params = NULL;
this->luaoverride_params_modified = 0;
this->luaoverride_flagmask = 0;
mapgen_debug_info = g_settings->getBool("enable_mapgen_debug_info");
queuemutex.Init();
@ -124,12 +128,37 @@ void EmergeManager::initMapgens(MapgenParams *mgparams) {
if (mapgen.size())
return;
// Resolve names of nodes for things that were registered
// (at this point, the registration period is over)
biomedef->resolveNodeNames(ndef);
for (size_t i = 0; i != ores.size(); i++)
ores[i]->resolveNodeNames(ndef);
for (size_t i = 0; i != decorations.size(); i++)
decorations[i]->resolveNodeNames(ndef);
// 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_SEED)
mgparams->seed = luaoverride_params->seed;
if (luaoverride_params_modified & MGPARAMS_SET_WATER_LEVEL)
mgparams->water_level = luaoverride_params->water_level;
if (luaoverride_params_modified & MGPARAMS_SET_FLAGS) {
mgparams->flags &= ~luaoverride_flagmask;
mgparams->flags |= luaoverride_params->flags;
}
delete luaoverride_params;
luaoverride_params = NULL;
}
// Create the mapgens
this->params = mgparams;
for (size_t i = 0; i != emergethread.size(); i++) {
mg = createMapgen(params->mg_name, 0, params);