Allow setting chunksize in core.set_mapgen_params

This commit is contained in:
kwolekr 2015-10-04 17:26:08 -04:00
parent 9f25aba6c2
commit 5130dbce7b
3 changed files with 16 additions and 1 deletions

@ -256,6 +256,12 @@ void EmergeManager::stopThreads()
} }
bool EmergeManager::isRunning()
{
return m_threads_active;
}
bool EmergeManager::enqueueBlockEmerge( bool EmergeManager::enqueueBlockEmerge(
u16 peer_id, u16 peer_id,
v3s16 blockpos, v3s16 blockpos,

@ -115,6 +115,7 @@ public:
void startThreads(); void startThreads();
void stopThreads(); void stopThreads();
bool isRunning();
bool enqueueBlockEmerge( bool enqueueBlockEmerge(
u16 peer_id, u16 peer_id,

@ -619,7 +619,11 @@ int ModApiMapgen::l_set_mapgen_params(lua_State *L)
if (!lua_istable(L, 1)) if (!lua_istable(L, 1))
return 0; return 0;
MapgenParams *params = &getServer(L)->getEmergeManager()->params; EmergeManager *emerge = getServer(L)->getEmergeManager();
if (emerge->isRunning())
throw LuaError("Cannot set parameters while mapgen is running");
MapgenParams *params = &emerge->params;
u32 flags = 0, flagmask = 0; u32 flags = 0, flagmask = 0;
lua_getfield(L, 1, "mgname"); lua_getfield(L, 1, "mgname");
@ -637,6 +641,10 @@ int ModApiMapgen::l_set_mapgen_params(lua_State *L)
if (lua_isnumber(L, -1)) if (lua_isnumber(L, -1))
params->water_level = lua_tointeger(L, -1); params->water_level = lua_tointeger(L, -1);
lua_getfield(L, 1, "chunksize");
if (lua_isnumber(L, -1))
params->chunksize = lua_tointeger(L, -1);
warn_if_field_exists(L, 1, "flagmask", warn_if_field_exists(L, 1, "flagmask",
"Deprecated: flags field now includes unset flags."); "Deprecated: flags field now includes unset flags.");
lua_getfield(L, 1, "flagmask"); lua_getfield(L, 1, "flagmask");