summaryrefslogtreecommitdiff
path: root/src/content_sao.cpp
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2019-07-29 19:14:07 +0200
committerGitHub <noreply@github.com>2019-07-29 19:14:07 +0200
commit4aa9a669cb184b77213e8df82eb20eda5aad9004 (patch)
treead252a18613aa7ecfdfee57074585a43c59f2881 /src/content_sao.cpp
parent50052fced51c6a97414472a84aac8ec9bb57d3ee (diff)
downloadminetest-4aa9a669cb184b77213e8df82eb20eda5aad9004.tar.gz
minetest-4aa9a669cb184b77213e8df82eb20eda5aad9004.tar.bz2
minetest-4aa9a669cb184b77213e8df82eb20eda5aad9004.zip
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
Diffstat (limited to 'src/content_sao.cpp')
-rw-r--r--src/content_sao.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/content_sao.cpp b/src/content_sao.cpp
index 336f8df18..41b1aec18 100644
--- a/src/content_sao.cpp
+++ b/src/content_sao.cpp
@@ -200,7 +200,7 @@ void UnitSAO::setAttachment(int parent_id, const std::string &bone, v3f position
}
void UnitSAO::getAttachment(int *parent_id, std::string *bone, v3f *position,
- v3f *rotation)
+ v3f *rotation) const
{
*parent_id = m_attachment_parent_id;
*bone = m_attachment_bone;
@@ -242,7 +242,7 @@ void UnitSAO::removeAttachmentChild(int child_id)
m_attachment_child_ids.erase(child_id);
}
-const std::unordered_set<int> &UnitSAO::getAttachmentChildIds()
+const std::unordered_set<int> &UnitSAO::getAttachmentChildIds() const
{
return m_attachment_child_ids;
}
@@ -575,6 +575,8 @@ std::string LuaEntitySAO::getClientInitializationData(u16 protocol_version)
(ii != m_attachment_child_ids.end()); ++ii) {
if (ServerActiveObject *obj = m_env->getActiveObject(*ii)) {
message_count++;
+ // TODO after a protocol bump: only send the object initialization data
+ // to older clients (superfluous since this message exists)
msg_os << serializeLongString(gob_cmd_update_infant(*ii, obj->getSendType(),
obj->getClientInitializationData(protocol_version)));
}