From 4aa9a669cb184b77213e8df82eb20eda5aad9004 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Mon, 29 Jul 2019 19:14:07 +0200 Subject: ContentCAO: Fix broken attachments on join (#8701) What happened: 1) Object data is received. Client begins to read the data 2) Client initializes all its children (gob_cmd_update_infant) 3) Children try to attach to parent (yet not added) 4) Parent initializes, is added to the environment And somewhere in between, Irrlicht wrecks up the attachments due to the missing matrix node. The solution here is to: 1) Use the same structure as ServerActiveObject 2) Attach all children after the parent is really initialized --- src/client/clientenvironment.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/client/clientenvironment.cpp') diff --git a/src/client/clientenvironment.cpp b/src/client/clientenvironment.cpp index a788c93c2..11dbcc35b 100644 --- a/src/client/clientenvironment.cpp +++ b/src/client/clientenvironment.cpp @@ -47,8 +47,6 @@ ClientEnvironment::ClientEnvironment(ClientMap *map, m_texturesource(texturesource), m_client(client) { - char zero = 0; - memset(attachement_parent_ids, zero, sizeof(attachement_parent_ids)); } ClientEnvironment::~ClientEnvironment() @@ -392,7 +390,17 @@ void ClientEnvironment::addActiveObject(u16 id, u8 type, <getAttachmentChildIds(); + for (auto c_id : children) { + if (auto *o = getActiveObject(c_id)) + o->updateAttachments(); + } + } } void ClientEnvironment::processActiveObjectMessage(u16 id, const std::string &data) -- cgit v1.2.3