1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Use std::vector instead of std::set for Environment::getObjectsInsideRadius

We are only iterating sequentially, we don't need a set here
Also use a vector reference instead of a copy
This commit is contained in:
Loic Blot 2015-04-16 14:11:46 +02:00
parent d02300a749
commit 0c634a9719
4 changed files with 9 additions and 9 deletions

View file

@ -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<u16> ids = env->getObjectsInsideRadius(pos, radius);
std::vector<u16> ids;
env->getObjectsInsideRadius(ids, pos, radius);
ScriptApiBase *script = getScriptApiBase(L);
lua_createtable(L, ids.size(), 0);
std::set<u16>::const_iterator iter = ids.begin();
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