1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

ServerEnv: Clean up object lifecycle handling (#6414)

* ServerEnv: Clean up object lifecycle handling
This commit is contained in:
sfan5 2017-09-15 12:19:01 +02:00 committed by Loïc Blot
parent edbc533414
commit 04839f233f
8 changed files with 175 additions and 213 deletions

View file

@ -642,7 +642,7 @@ 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);
if (!obj->m_removed) {
if (!obj->isGone()) {
// Insert object reference into table
script->objectrefGetOrCreate(L, obj);
lua_rawseti(L, -2, ++i);

View file

@ -140,15 +140,14 @@ int ObjectRef::l_remove(lua_State *L)
return 0;
const std::unordered_set<int> &child_ids = co->getAttachmentChildIds();
std::unordered_set<int>::const_iterator it;
for (it = child_ids.begin(); it != child_ids.end(); ++it) {
for (int child_id : child_ids) {
// Child can be NULL if it was deleted earlier
if (ServerActiveObject *child = env->getActiveObject(*it))
if (ServerActiveObject *child = env->getActiveObject(child_id))
child->setAttachment(0, "", v3f(0, 0, 0), v3f(0, 0, 0));
}
verbosestream<<"ObjectRef::l_remove(): id="<<co->getId()<<std::endl;
co->m_removed = true;
verbosestream << "ObjectRef::l_remove(): id=" << co->getId() << std::endl;
co->m_pending_removal = true;
return 0;
}