diff options
Diffstat (limited to 'src/script/lua_api/l_env.cpp')
-rw-r--r-- | src/script/lua_api/l_env.cpp | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp index 1b1f96389..94edf201e 100644 --- a/src/script/lua_api/l_env.cpp +++ b/src/script/lua_api/l_env.cpp @@ -743,9 +743,8 @@ int ModApiEnvMod::l_find_node_near(lua_State *L) for (int d = start_radius; d <= radius; d++) { std::vector<v3s16> list = FacePositionCache::getFacePositions(d); - for (std::vector<v3s16>::iterator i = list.begin(); - i != list.end(); ++i) { - v3s16 p = pos + (*i); + for (v3s16 i : list) { + v3s16 p = pos + i; content_t c = env->getMap().getNodeNoEx(p).getContent(); if (filter.count(c) != 0) { push_v3s16(L, p); @@ -809,10 +808,9 @@ int ModApiEnvMod::l_find_nodes_in_area(lua_State *L) } } lua_newtable(L); - for (std::set<content_t>::const_iterator it = filter.begin(); - it != filter.end(); ++it) { - lua_pushnumber(L, individual_count[*it]); - lua_setfield(L, -2, ndef->get(*it).name.c_str()); + for (content_t it : filter) { + lua_pushnumber(L, individual_count[it]); + lua_setfield(L, -2, ndef->get(it).name.c_str()); } return 2; } @@ -1004,12 +1002,11 @@ int ModApiEnvMod::l_fix_light(lua_State *L) for (blockpos.Z = blockpos1.Z; blockpos.Z <= blockpos2.Z; blockpos.Z++) { success = success & map.repairBlockLight(blockpos, &modified_blocks); } - if (modified_blocks.size() > 0) { + if (!modified_blocks.empty()) { MapEditEvent event; event.type = MEET_OTHER; - for (std::map<v3s16, MapBlock *>::iterator it = modified_blocks.begin(); - it != modified_blocks.end(); ++it) - event.modified_blocks.insert(it->first); + for (auto &modified_block : modified_blocks) + event.modified_blocks.insert(modified_block.first); map.dispatchEvent(&event); } @@ -1126,14 +1123,13 @@ int ModApiEnvMod::l_find_path(lua_State *L) std::vector<v3s16> path = get_path(env, pos1, pos2, searchdistance, max_jump, max_drop, algo); - if (path.size() > 0) - { + if (!path.empty()) { lua_newtable(L); int top = lua_gettop(L); unsigned int index = 1; - for (std::vector<v3s16>::iterator i = path.begin(); i != path.end(); ++i) { + for (v3s16 i : path) { lua_pushnumber(L,index); - push_v3s16(L, *i); + push_v3s16(L, i); lua_settable(L, top); index++; } @@ -1167,8 +1163,7 @@ int ModApiEnvMod::l_spawn_tree(lua_State *L) tree_def.leavesnode=ndef->getId(leaves); tree_def.leaves2_chance=0; getstringfield(L, 2, "leaves2", leaves); - if (leaves !="") - { + if (!leaves.empty()) { tree_def.leaves2node=ndef->getId(leaves); getintfield(L, 2, "leaves2_chance", tree_def.leaves2_chance); } @@ -1180,8 +1175,7 @@ int ModApiEnvMod::l_spawn_tree(lua_State *L) getboolfield(L, 2, "thin_branches", tree_def.thin_branches); tree_def.fruit_chance=0; getstringfield(L, 2, "fruit", fruit); - if (fruit != "") - { + if (!fruit.empty()) { tree_def.fruitnode=ndef->getId(fruit); getintfield(L, 2, "fruit_chance",tree_def.fruit_chance); } |