1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-09-05 18:41:05 +00:00

Add VoxelManip:close() for explicit free

This commit is contained in:
sfan5 2025-05-25 12:39:11 +02:00
parent 79e0d834fd
commit e03957ec0c
3 changed files with 23 additions and 0 deletions

View file

@ -344,6 +344,19 @@ int LuaVoxelManip::l_get_emerged_area(lua_State *L)
return 2;
}
int LuaVoxelManip::l_close(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
LuaVoxelManip *o = checkObject<LuaVoxelManip>(L, 1);
if (o->is_mapgen_vm)
throw LuaError("Cannot dispose of mapgen VoxelManip object");
o->vm->clear();
return 0;
}
LuaVoxelManip::LuaVoxelManip(MMVManip *mmvm, bool is_mg_vm) :
is_mapgen_vm(is_mg_vm),
vm(mmvm)
@ -451,5 +464,6 @@ const luaL_Reg LuaVoxelManip::methods[] = {
luamethod(LuaVoxelManip, set_param2_data),
luamethod(LuaVoxelManip, was_modified),
luamethod(LuaVoxelManip, get_emerged_area),
luamethod(LuaVoxelManip, close),
{0,0}
};

View file

@ -45,6 +45,8 @@ private:
static int l_was_modified(lua_State *L);
static int l_get_emerged_area(lua_State *L);
static int l_close(lua_State *L);
public:
MMVManip *vm = nullptr;