core.get_objects_inside_radius: Omit removed objects (#6318)
authoryou <ovvv@web.de>
Sun, 27 Aug 2017 16:38:50 +0000 (18:38 +0200)
committerSmallJoker <SmallJoker@users.noreply.github.com>
Sun, 27 Aug 2017 16:38:50 +0000 (18:38 +0200)
Fixes #6294

doc/lua_api.txt
src/script/lua_api/l_env.cpp

index 152da5985241bb89ac1d16521f2e143f7bb6fc05..d8e58f2a88d5adcea4f4281c2701d7f6e507c494 100644 (file)
@@ -2555,7 +2555,7 @@ and `minetest.auth_reload` call the authetification handler.
 * `minetest.add_item(pos, item)`: Spawn item
     * Returns `ObjectRef`, or `nil` if failed
 * `minetest.get_player_by_name(name)`: Get an `ObjectRef` to a player
-* `minetest.get_objects_inside_radius(pos, radius)`
+* `minetest.get_objects_inside_radius(pos, radius)`: returns a list of ObjectRefs
     * `radius`: using an euclidean metric
 * `minetest.set_timeofday(val)`
     * `val` is between `0` and `1`; `0` for midnight, `0.5` for midday
index 07d33a4eba4911efad54a5ed8a2cf9b8f32155ca..be92365acf5c06ccacfd4943f4d5c1489837e70c 100644 (file)
@@ -642,9 +642,11 @@ int ModApiEnvMod::l_get_objects_inside_radius(lua_State *L)
        std::vector<u16>::const_iterator iter = ids.begin();
        for(u32 i = 0; iter != ids.end(); ++iter) {
                ServerActiveObject *obj = env->getActiveObject(*iter);
-               // Insert object reference into table
-               script->objectrefGetOrCreate(L, obj);
-               lua_rawseti(L, -2, ++i);
+               if (!obj->m_removed) {
+                       // Insert object reference into table
+                       script->objectrefGetOrCreate(L, obj);
+                       lua_rawseti(L, -2, ++i);
+               }
        }
        return 1;
 }