diff --git a/src/collision.cpp b/src/collision.cpp index c759f20c..27e3b5e9 100644 --- a/src/collision.cpp +++ b/src/collision.cpp @@ -318,8 +318,9 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef, ServerEnvironment *s_env = dynamic_cast(env); if (s_env != 0) { f32 distance = speed_f.getLength(); - std::set s_objects = s_env->getObjectsInsideRadius(pos_f,distance * 1.5); - for (std::set::iterator iter = s_objects.begin(); iter != s_objects.end(); iter++) { + std::vector s_objects; + s_env->getObjectsInsideRadius(s_objects, pos_f, distance * 1.5); + for (std::vector::iterator iter = s_objects.begin(); iter != s_objects.end(); iter++) { ServerActiveObject *current = s_env->getActiveObject(*iter); if ((self == 0) || (self != current)) { objects.push_back((ActiveObject*)current); diff --git a/src/environment.cpp b/src/environment.cpp index af213e5e..8ade7fe0 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -840,9 +840,8 @@ bool ServerEnvironment::swapNode(v3s16 p, const MapNode &n) return true; } -std::set ServerEnvironment::getObjectsInsideRadius(v3f pos, float radius) +void ServerEnvironment::getObjectsInsideRadius(std::vector &objects, v3f pos, float radius) { - std::set objects; for(std::map::iterator i = m_active_objects.begin(); i != m_active_objects.end(); ++i) @@ -852,9 +851,8 @@ std::set ServerEnvironment::getObjectsInsideRadius(v3f pos, float radius) v3f objectpos = obj->getBasePosition(); if(objectpos.getDistanceFrom(pos) > radius) continue; - objects.insert(id); + objects.push_back(id); } - return objects; } void ServerEnvironment::clearAllObjects() diff --git a/src/environment.h b/src/environment.h index c9c37441..415a9ec3 100644 --- a/src/environment.h +++ b/src/environment.h @@ -305,7 +305,7 @@ public: bool swapNode(v3s16 p, const MapNode &n); // Find all active objects inside a radius around a point - std::set getObjectsInsideRadius(v3f pos, float radius); + void getObjectsInsideRadius(std::vector &objects, v3f pos, float radius); // Clear all objects, loading and going through every MapBlock void clearAllObjects(); diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp index 840c3459..0fe1ddec 100644 --- a/src/script/lua_api/l_env.cpp +++ b/src/script/lua_api/l_env.cpp @@ -438,10 +438,11 @@ int ModApiEnvMod::l_get_objects_inside_radius(lua_State *L) // Do it v3f pos = checkFloatPos(L, 1); float radius = luaL_checknumber(L, 2) * BS; - std::set ids = env->getObjectsInsideRadius(pos, radius); + std::vector ids; + env->getObjectsInsideRadius(ids, pos, radius); ScriptApiBase *script = getScriptApiBase(L); lua_createtable(L, ids.size(), 0); - std::set::const_iterator iter = ids.begin(); + std::vector::const_iterator iter = ids.begin(); for(u32 i = 0; iter != ids.end(); iter++) { ServerActiveObject *obj = env->getActiveObject(*iter); // Insert object reference into table