From 81c2370c8b1a66a279a5ff450c78caf5dfef77bf Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Wed, 2 Oct 2019 19:11:27 +0200 Subject: 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. --- src/client/clientenvironment.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/client/clientenvironment.cpp') diff --git a/src/client/clientenvironment.cpp b/src/client/clientenvironment.cpp index e1b20ec84..5eb033302 100644 --- a/src/client/clientenvironment.cpp +++ b/src/client/clientenvironment.cpp @@ -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 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); -- cgit v1.2.3