mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Lua on each mapgen thread (#13092)
This commit is contained in:
parent
d4b107e2e8
commit
3cac17d23e
32 changed files with 1329 additions and 193 deletions
|
@ -48,6 +48,9 @@ int LuaVoxelManip::l_read_from_map(lua_State *L)
|
|||
if (vm->isOrphan())
|
||||
return 0;
|
||||
|
||||
if (getEmergeThread(L))
|
||||
throw LuaError("VoxelManip:read_from_map called in mapgen environment");
|
||||
|
||||
v3s16 bp1 = getNodeBlockPos(check_v3s16(L, 2));
|
||||
v3s16 bp2 = getNodeBlockPos(check_v3s16(L, 3));
|
||||
sortBoxVerticies(bp1, bp2);
|
||||
|
@ -110,14 +113,18 @@ int LuaVoxelManip::l_set_data(lua_State *L)
|
|||
|
||||
int LuaVoxelManip::l_write_to_map(lua_State *L)
|
||||
{
|
||||
GET_ENV_PTR;
|
||||
|
||||
LuaVoxelManip *o = checkObject<LuaVoxelManip>(L, 1);
|
||||
bool update_light = !lua_isboolean(L, 2) || readParam<bool>(L, 2);
|
||||
|
||||
if (o->vm->isOrphan())
|
||||
return 0;
|
||||
|
||||
// This wouldn't work anyway as we have no env ptr, but it's still unsafe.
|
||||
if (getEmergeThread(L))
|
||||
throw LuaError("VoxelManip:write_to_map called in mapgen environment");
|
||||
|
||||
GET_ENV_PTR;
|
||||
|
||||
ServerMap *map = &(env->getServerMap());
|
||||
|
||||
std::map<v3s16, MapBlock*> modified_blocks;
|
||||
|
@ -154,9 +161,8 @@ int LuaVoxelManip::l_set_node_at(lua_State *L)
|
|||
v3s16 pos = check_v3s16(L, 2);
|
||||
MapNode n = readnode(L, 3);
|
||||
|
||||
o->vm->setNodeNoEmerge(pos, n);
|
||||
|
||||
return 0;
|
||||
lua_pushboolean(L, o->vm->setNodeNoEmerge(pos, n));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int LuaVoxelManip::l_update_liquids(lua_State *L)
|
||||
|
@ -193,8 +199,8 @@ int LuaVoxelManip::l_set_lighting(lua_State *L)
|
|||
{
|
||||
LuaVoxelManip *o = checkObject<LuaVoxelManip>(L, 1);
|
||||
if (!o->is_mapgen_vm) {
|
||||
warningstream << "VoxelManip:set_lighting called for a non-mapgen "
|
||||
"VoxelManip object" << std::endl;
|
||||
log_deprecated(L, "set_lighting called for a non-mapgen "
|
||||
"VoxelManip object");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue