diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 132a0eb7..960439bf 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -79,6 +79,7 @@ Entity::Entity(const LWOOBJID& objectID, EntityInfo info, Entity* parentEntity) m_Components = {}; m_DieCallbacks = {}; m_PhantomCollisionCallbacks = {}; + m_IsParentChildDirty = true; m_Settings = info.settings; m_NetworkSettings = info.networkSettings; @@ -974,8 +975,9 @@ void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacke } else outBitStream->Write0(); //No GM Level } - outBitStream->Write((m_ParentEntity != nullptr || m_ChildEntities.size() > 0)); - if (m_ParentEntity || m_ChildEntities.size() > 0) { + outBitStream->Write((m_ParentEntity != nullptr || m_ChildEntities.size() > 0) && (m_IsParentChildDirty || packetType == PACKET_TYPE_CONSTRUCTION)); + if ((m_ParentEntity != nullptr || m_ChildEntities.size() > 0) && (m_IsParentChildDirty || packetType == PACKET_TYPE_CONSTRUCTION)) { + m_IsParentChildDirty = false; outBitStream->Write(m_ParentEntity != nullptr); if (m_ParentEntity) { outBitStream->Write(m_ParentEntity->GetObjectID()); @@ -1661,6 +1663,7 @@ void Entity::RegisterCoinDrop(uint64_t count) { } void Entity::AddChild(Entity* child) { + m_IsParentChildDirty = true; m_ChildEntities.push_back(child); } diff --git a/dGame/Entity.h b/dGame/Entity.h index cef7b97f..f2bc4237 100644 --- a/dGame/Entity.h +++ b/dGame/Entity.h @@ -322,6 +322,8 @@ protected: int8_t m_Observers = 0; + bool m_IsParentChildDirty = true; + /* * Collision */