forked from Mirrorlandia_minetest/minetest
Attachments: Avoid data loss caused by set_attach() in callbacks (#11181)
This commit is contained in:
parent
4d0fef8ae8
commit
bbe120308f
@ -134,17 +134,22 @@ void UnitSAO::setAttachment(int parent_id, const std::string &bone, v3f position
|
|||||||
|
|
||||||
int old_parent = m_attachment_parent_id;
|
int old_parent = m_attachment_parent_id;
|
||||||
m_attachment_parent_id = parent_id;
|
m_attachment_parent_id = parent_id;
|
||||||
|
|
||||||
|
// The detach callbacks might call to setAttachment() again.
|
||||||
|
// Ensure the attachment params are applied after this callback is run.
|
||||||
|
if (parent_id != old_parent)
|
||||||
|
onDetach(old_parent);
|
||||||
|
|
||||||
|
m_attachment_parent_id = parent_id;
|
||||||
m_attachment_bone = bone;
|
m_attachment_bone = bone;
|
||||||
m_attachment_position = position;
|
m_attachment_position = position;
|
||||||
m_attachment_rotation = rotation;
|
m_attachment_rotation = rotation;
|
||||||
m_force_visible = force_visible;
|
m_force_visible = force_visible;
|
||||||
m_attachment_sent = false;
|
m_attachment_sent = false;
|
||||||
|
|
||||||
if (parent_id != old_parent) {
|
if (parent_id != old_parent)
|
||||||
onDetach(old_parent);
|
|
||||||
onAttach(parent_id);
|
onAttach(parent_id);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void UnitSAO::getAttachment(int *parent_id, std::string *bone, v3f *position,
|
void UnitSAO::getAttachment(int *parent_id, std::string *bone, v3f *position,
|
||||||
v3f *rotation, bool *force_visible) const
|
v3f *rotation, bool *force_visible) const
|
||||||
|
Loading…
Reference in New Issue
Block a user