From 54f1267c2c87daea769966c694777a2e5977f870 Mon Sep 17 00:00:00 2001 From: kwolekr Date: Sun, 25 Oct 2015 00:45:18 -0400 Subject: SAPI: Mark all Lua API functions requiring envlock --- src/script/lua_api/l_mapgen.cpp | 44 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'src/script/lua_api/l_mapgen.cpp') diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp index cfa216a3d..825292419 100644 --- a/src/script/lua_api/l_mapgen.cpp +++ b/src/script/lua_api/l_mapgen.cpp @@ -454,6 +454,8 @@ size_t get_biome_list(lua_State *L, int index, // returns the biome id used in biomemap int ModApiMapgen::l_get_biome_id(lua_State *L) { + NO_MAP_LOCK_REQUIRED; + const char *biome_str = lua_tostring(L, 1); if (!biome_str) return 0; @@ -463,7 +465,7 @@ int ModApiMapgen::l_get_biome_id(lua_State *L) if (!bmgr) return 0; - Biome *biome = (Biome *) bmgr->getByName(biome_str); + Biome *biome = (Biome *)bmgr->getByName(biome_str); if (!biome || biome->index == OBJDEF_INVALID_INDEX) return 0; @@ -478,6 +480,8 @@ int ModApiMapgen::l_get_biome_id(lua_State *L) // returns the requested object used during map generation int ModApiMapgen::l_get_mapgen_object(lua_State *L) { + NO_MAP_LOCK_REQUIRED; + const char *mgobjstr = lua_tostring(L, 1); int mgobjint; @@ -588,6 +592,8 @@ int ModApiMapgen::l_get_mapgen_object(lua_State *L) int ModApiMapgen::l_get_mapgen_params(lua_State *L) { + NO_MAP_LOCK_REQUIRED; + MapgenParams *params = &getServer(L)->getEmergeManager()->params; lua_newtable(L); @@ -616,6 +622,8 @@ int ModApiMapgen::l_get_mapgen_params(lua_State *L) // set mapgen parameters int ModApiMapgen::l_set_mapgen_params(lua_State *L) { + NO_MAP_LOCK_REQUIRED; + if (!lua_istable(L, 1)) return 0; @@ -664,6 +672,8 @@ int ModApiMapgen::l_set_mapgen_params(lua_State *L) // set global config values for noise parameters int ModApiMapgen::l_set_noiseparams(lua_State *L) { + NO_MAP_LOCK_REQUIRED; + const char *name = luaL_checkstring(L, 1); NoiseParams np; @@ -681,6 +691,8 @@ int ModApiMapgen::l_set_noiseparams(lua_State *L) // get_noiseparams(name) int ModApiMapgen::l_get_noiseparams(lua_State *L) { + NO_MAP_LOCK_REQUIRED; + std::string name = luaL_checkstring(L, 1); NoiseParams np; @@ -695,6 +707,8 @@ int ModApiMapgen::l_get_noiseparams(lua_State *L) // set_gen_notify(flags, {deco_id_table}) int ModApiMapgen::l_set_gen_notify(lua_State *L) { + NO_MAP_LOCK_REQUIRED; + u32 flags = 0, flagmask = 0; EmergeManager *emerge = getServer(L)->getEmergeManager(); @@ -719,6 +733,8 @@ int ModApiMapgen::l_set_gen_notify(lua_State *L) // get_gen_notify() int ModApiMapgen::l_get_gen_notify(lua_State *L) { + NO_MAP_LOCK_REQUIRED; + EmergeManager *emerge = getServer(L)->getEmergeManager(); push_flags_string(L, flagdesc_gennotify, emerge->gen_notify_on, emerge->gen_notify_on); @@ -738,6 +754,8 @@ int ModApiMapgen::l_get_gen_notify(lua_State *L) // register_biome({lots of stuff}) int ModApiMapgen::l_register_biome(lua_State *L) { + NO_MAP_LOCK_REQUIRED; + int index = 1; luaL_checktype(L, index, LUA_TTABLE); @@ -762,6 +780,8 @@ int ModApiMapgen::l_register_biome(lua_State *L) // register_decoration({lots of stuff}) int ModApiMapgen::l_register_decoration(lua_State *L) { + NO_MAP_LOCK_REQUIRED; + int index = 1; luaL_checktype(L, index, LUA_TTABLE); @@ -902,6 +922,8 @@ bool read_deco_schematic(lua_State *L, SchematicManager *schemmgr, DecoSchematic // register_ore({lots of stuff}) int ModApiMapgen::l_register_ore(lua_State *L) { + NO_MAP_LOCK_REQUIRED; + int index = 1; luaL_checktype(L, index, LUA_TTABLE); @@ -1030,6 +1052,8 @@ int ModApiMapgen::l_register_ore(lua_State *L) // register_schematic({schematic}, replacements={}) int ModApiMapgen::l_register_schematic(lua_State *L) { + NO_MAP_LOCK_REQUIRED; + SchematicManager *schemmgr = getServer(L)->getEmergeManager()->schemmgr; StringMap replace_names; @@ -1055,6 +1079,8 @@ int ModApiMapgen::l_register_schematic(lua_State *L) // clear_registered_biomes() int ModApiMapgen::l_clear_registered_biomes(lua_State *L) { + NO_MAP_LOCK_REQUIRED; + BiomeManager *bmgr = getServer(L)->getEmergeManager()->biomemgr; bmgr->clear(); return 0; @@ -1064,6 +1090,8 @@ int ModApiMapgen::l_clear_registered_biomes(lua_State *L) // clear_registered_decorations() int ModApiMapgen::l_clear_registered_decorations(lua_State *L) { + NO_MAP_LOCK_REQUIRED; + DecorationManager *dmgr = getServer(L)->getEmergeManager()->decomgr; dmgr->clear(); return 0; @@ -1073,6 +1101,8 @@ int ModApiMapgen::l_clear_registered_decorations(lua_State *L) // clear_registered_ores() int ModApiMapgen::l_clear_registered_ores(lua_State *L) { + NO_MAP_LOCK_REQUIRED; + OreManager *omgr = getServer(L)->getEmergeManager()->oremgr; omgr->clear(); return 0; @@ -1082,6 +1112,8 @@ int ModApiMapgen::l_clear_registered_ores(lua_State *L) // clear_registered_schematics() int ModApiMapgen::l_clear_registered_schematics(lua_State *L) { + NO_MAP_LOCK_REQUIRED; + SchematicManager *smgr = getServer(L)->getEmergeManager()->schemmgr; smgr->clear(); return 0; @@ -1091,6 +1123,8 @@ int ModApiMapgen::l_clear_registered_schematics(lua_State *L) // generate_ores(vm, p1, p2, [ore_id]) int ModApiMapgen::l_generate_ores(lua_State *L) { + NO_MAP_LOCK_REQUIRED; + EmergeManager *emerge = getServer(L)->getEmergeManager(); Mapgen mg; @@ -1115,6 +1149,8 @@ int ModApiMapgen::l_generate_ores(lua_State *L) // generate_decorations(vm, p1, p2, [deco_id]) int ModApiMapgen::l_generate_decorations(lua_State *L) { + NO_MAP_LOCK_REQUIRED; + EmergeManager *emerge = getServer(L)->getEmergeManager(); Mapgen mg; @@ -1139,6 +1175,8 @@ int ModApiMapgen::l_generate_decorations(lua_State *L) // create_schematic(p1, p2, probability_list, filename, y_slice_prob_list) int ModApiMapgen::l_create_schematic(lua_State *L) { + MAP_LOCK_REQUIRED; + INodeDefManager *ndef = getServer(L)->getNodeDefManager(); const char *filename = luaL_checkstring(L, 4); @@ -1202,6 +1240,8 @@ int ModApiMapgen::l_create_schematic(lua_State *L) // place_schematic(p, schematic, rotation, replacement) int ModApiMapgen::l_place_schematic(lua_State *L) { + MAP_LOCK_REQUIRED; + Map *map = &(getEnv(L)->getMap()); SchematicManager *schemmgr = getServer(L)->getEmergeManager()->schemmgr; @@ -1240,6 +1280,8 @@ int ModApiMapgen::l_place_schematic(lua_State *L) // serialize_schematic(schematic, format, options={...}) int ModApiMapgen::l_serialize_schematic(lua_State *L) { + NO_MAP_LOCK_REQUIRED; + SchematicManager *schemmgr = getServer(L)->getEmergeManager()->schemmgr; //// Read options -- cgit v1.2.3