Address quickbuilds being unbuildable

Address an issue where quickbuilds would become unbuildable.  The main issue lied within serializing parent/child info too often for some reason / serializing it when the info wasnt dirty.  Only serializing this info when it is actually dirty and has changed has addressed the issue and allows quickbuilds to never break.
This commit is contained in:
EmosewaMC 2022-06-15 22:58:38 -07:00
parent 4556faf833
commit 8bdd5b6e2c
2 changed files with 7 additions and 2 deletions

View File

@ -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);
}

View File

@ -322,6 +322,8 @@ protected:
int8_t m_Observers = 0;
bool m_IsParentChildDirty = true;
/*
* Collision
*/