diff options
author | kwolekr <kwolekr@minetest.net> | 2015-10-25 00:45:18 -0400 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2015-10-25 23:06:48 -0400 |
commit | 54f1267c2c87daea769966c694777a2e5977f870 (patch) | |
tree | ae08897774c1b1d1ecae0ad1a31b147c9c98dd02 /src/script/lua_api/l_vmanip.cpp | |
parent | 3936a5e3f71d46e61f819b8f6c85dd47a440f21e (diff) | |
download | minetest-54f1267c2c87daea769966c694777a2e5977f870.tar.gz minetest-54f1267c2c87daea769966c694777a2e5977f870.tar.bz2 minetest-54f1267c2c87daea769966c694777a2e5977f870.zip |
SAPI: Mark all Lua API functions requiring envlock
Diffstat (limited to 'src/script/lua_api/l_vmanip.cpp')
-rw-r--r-- | src/script/lua_api/l_vmanip.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/script/lua_api/l_vmanip.cpp b/src/script/lua_api/l_vmanip.cpp index ac6c10303..ec9be8fba 100644 --- a/src/script/lua_api/l_vmanip.cpp +++ b/src/script/lua_api/l_vmanip.cpp @@ -28,10 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "server.h" #include "mapgen.h" -#define GET_ENV_PTR ServerEnvironment* env = \ - dynamic_cast<ServerEnvironment*>(getEnv(L)); \ - if (env == NULL) return 0 - // garbage collector int LuaVoxelManip::gc_object(lua_State *L) { @@ -43,6 +39,8 @@ int LuaVoxelManip::gc_object(lua_State *L) int LuaVoxelManip::l_read_from_map(lua_State *L) { + MAP_LOCK_REQUIRED; + LuaVoxelManip *o = checkobject(L, 1); MMVManip *vm = o->vm; @@ -108,6 +106,8 @@ int LuaVoxelManip::l_set_data(lua_State *L) int LuaVoxelManip::l_write_to_map(lua_State *L) { + MAP_LOCK_REQUIRED; + LuaVoxelManip *o = checkobject(L, 1); MMVManip *vm = o->vm; @@ -119,23 +119,25 @@ int LuaVoxelManip::l_write_to_map(lua_State *L) int LuaVoxelManip::l_get_node_at(lua_State *L) { NO_MAP_LOCK_REQUIRED; - GET_ENV_PTR; + + INodeDefManager *ndef = getServer(L)->getNodeDefManager(); LuaVoxelManip *o = checkobject(L, 1); v3s16 pos = check_v3s16(L, 2); - pushnode(L, o->vm->getNodeNoExNoEmerge(pos), env->getGameDef()->ndef()); + pushnode(L, o->vm->getNodeNoExNoEmerge(pos), ndef); return 1; } int LuaVoxelManip::l_set_node_at(lua_State *L) { NO_MAP_LOCK_REQUIRED; - GET_ENV_PTR; + + INodeDefManager *ndef = getServer(L)->getNodeDefManager(); LuaVoxelManip *o = checkobject(L, 1); v3s16 pos = check_v3s16(L, 2); - MapNode n = readnode(L, 3, env->getGameDef()->ndef()); + MapNode n = readnode(L, 3, ndef); o->vm->setNodeNoEmerge(pos, n); @@ -313,14 +315,12 @@ int LuaVoxelManip::l_set_param2_data(lua_State *L) int LuaVoxelManip::l_update_map(lua_State *L) { + GET_ENV_PTR; + LuaVoxelManip *o = checkobject(L, 1); if (o->is_mapgen_vm) return 0; - Environment *env = getEnv(L); - if (!env) - return 0; - Map *map = &(env->getMap()); // TODO: Optimize this by using Mapgen::calcLighting() instead @@ -359,6 +359,8 @@ int LuaVoxelManip::l_was_modified(lua_State *L) int LuaVoxelManip::l_get_emerged_area(lua_State *L) { + NO_MAP_LOCK_REQUIRED; + LuaVoxelManip *o = checkobject(L, 1); push_v3s16(L, o->vm->m_area.MinEdge); @@ -400,11 +402,7 @@ LuaVoxelManip::~LuaVoxelManip() // Creates an LuaVoxelManip and leaves it on top of stack int LuaVoxelManip::create_object(lua_State *L) { - NO_MAP_LOCK_REQUIRED; - - Environment *env = getEnv(L); - if (!env) - return 0; + GET_ENV_PTR; Map *map = &(env->getMap()); LuaVoxelManip *o = (lua_istable(L, 1) && lua_istable(L, 2)) ? |