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

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
This commit is contained in:
SmallJoker 2019-07-29 19:14:07 +02:00 committed by GitHub
parent 50052fced5
commit 4aa9a669cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 167 additions and 120 deletions

View file

@ -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,
<<std::endl;
}
addActiveObject(obj);
u16 new_id = addActiveObject(obj);
// Object initialized:
if ((obj = getActiveObject(new_id))) {
// Final step is to update all children which are already known
// Data provided by GENERIC_CMD_SPAWN_INFANT
const auto &children = obj->getAttachmentChildIds();
for (auto c_id : children) {
if (auto *o = getActiveObject(c_id))
o->updateAttachments();
}
}
}
void ClientEnvironment::processActiveObjectMessage(u16 id, const std::string &data)