1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-02 16:38:41 +00:00

Attachments: Fix attachments to temporary removed objects (#8989)

Does not clear the parent's attachment information when the child is deleted locally.
Either it was removed permanently, or just temporary - we don't know, but it's up to the server to send a *detach from child" packet for the parent.
This commit is contained in:
SmallJoker 2019-10-02 19:11:27 +02:00 committed by GitHub
parent 251038e136
commit 81c2370c8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 70 additions and 31 deletions

View file

@ -402,6 +402,23 @@ void ClientEnvironment::addActiveObject(u16 id, u8 type,
}
}
void ClientEnvironment::removeActiveObject(u16 id)
{
// Get current attachment childs to detach them visually
std::unordered_set<int> attachment_childs;
if (auto *obj = getActiveObject(id))
attachment_childs = obj->getAttachmentChildIds();
m_ao_manager.removeObject(id);
// Perform a proper detach in Irrlicht
for (auto c_id : attachment_childs) {
if (ClientActiveObject *child = getActiveObject(c_id))
child->updateAttachments();
}
}
void ClientEnvironment::processActiveObjectMessage(u16 id, const std::string &data)
{
ClientActiveObject *obj = getActiveObject(id);