Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow setting chunksize in core.set_mapgen_params
  • Loading branch information
kwolekr committed Oct 4, 2015
1 parent 9f25aba commit 5130dbc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/emerge.cpp
Expand Up @@ -256,6 +256,12 @@ void EmergeManager::stopThreads()
}


bool EmergeManager::isRunning()
{
return m_threads_active;
}


bool EmergeManager::enqueueBlockEmerge(
u16 peer_id,
v3s16 blockpos,
Expand Down
1 change: 1 addition & 0 deletions src/emerge.h
Expand Up @@ -115,6 +115,7 @@ class EmergeManager {

void startThreads();
void stopThreads();
bool isRunning();

bool enqueueBlockEmerge(
u16 peer_id,
Expand Down
10 changes: 9 additions & 1 deletion src/script/lua_api/l_mapgen.cpp
Expand Up @@ -619,7 +619,11 @@ int ModApiMapgen::l_set_mapgen_params(lua_State *L)
if (!lua_istable(L, 1))
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;

lua_getfield(L, 1, "mgname");
Expand All @@ -637,6 +641,10 @@ int ModApiMapgen::l_set_mapgen_params(lua_State *L)
if (lua_isnumber(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",
"Deprecated: flags field now includes unset flags.");
lua_getfield(L, 1, "flagmask");
Expand Down

0 comments on commit 5130dbc

Please sign in to comment.