summaryrefslogtreecommitdiff
path: root/src/client/clientenvironment.cpp
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2019-10-02 19:11:27 +0200
committerGitHub <noreply@github.com>2019-10-02 19:11:27 +0200
commit81c2370c8b1a66a279a5ff450c78caf5dfef77bf (patch)
treedafd49bfa912783985b5a58713805027f06322b4 /src/client/clientenvironment.cpp
parent251038e136f22f29999bd938e6c9e9f1a5269243 (diff)
downloadminetest-81c2370c8b1a66a279a5ff450c78caf5dfef77bf.tar.gz
minetest-81c2370c8b1a66a279a5ff450c78caf5dfef77bf.tar.bz2
minetest-81c2370c8b1a66a279a5ff450c78caf5dfef77bf.zip
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.
Diffstat (limited to 'src/client/clientenvironment.cpp')
-rw-r--r--src/client/clientenvironment.cpp17
1 files changed, 17 insertions, 0 deletions
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<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);