summaryrefslogtreecommitdiffstats
path: root/src/Entities/Entity.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Entities/Entity.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 30aa87f37..6e1dec957 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -1927,10 +1927,13 @@ void cEntity::AttachTo(cEntity * a_AttachTo)
Detach();
}
- // Attach to the new entity:
+ // Update state information
m_AttachedTo = a_AttachTo;
a_AttachTo->m_Attachee = this;
- m_World->BroadcastAttachEntity(*this, a_AttachTo);
+ if (a_AttachTo != nullptr)
+ {
+ m_World->BroadcastAttachEntity(*this, *a_AttachTo);
+ }
}
@@ -1941,12 +1944,13 @@ void cEntity::Detach(void)
{
if (m_AttachedTo == nullptr)
{
- // Attached to no entity, our work is done
+ // Already not attached to any entity, our work is done
return;
}
+ m_World->BroadcastDetachEntity(*this, *m_AttachedTo);
+
m_AttachedTo->m_Attachee = nullptr;
m_AttachedTo = nullptr;
- m_World->BroadcastAttachEntity(*this, nullptr);
}