mirror of
https://github.com/minetest/minetest.git
synced 2024-12-28 00:47:29 +01:00
avoid clearChildAttachments iterator invalidation (#12987)
This commit is contained in:
parent
386bfcda2b
commit
9527cc3fa0
@ -179,12 +179,16 @@ void UnitSAO::getAttachment(int *parent_id, std::string *bone, v3f *position,
|
||||
|
||||
void UnitSAO::clearChildAttachments()
|
||||
{
|
||||
for (int child_id : m_attachment_child_ids) {
|
||||
// Cannot use for-loop here: setAttachment() modifies 'm_attachment_child_ids'!
|
||||
while (!m_attachment_child_ids.empty()) {
|
||||
int child_id = *m_attachment_child_ids.begin();
|
||||
|
||||
// Child can be NULL if it was deleted earlier
|
||||
if (ServerActiveObject *child = m_env->getActiveObject(child_id))
|
||||
child->setAttachment(0, "", v3f(0, 0, 0), v3f(0, 0, 0), false);
|
||||
|
||||
removeAttachmentChild(child_id);
|
||||
}
|
||||
m_attachment_child_ids.clear();
|
||||
}
|
||||
|
||||
void UnitSAO::clearParentAttachment()
|
||||
|
Loading…
Reference in New Issue
Block a user