From 9df4edf1e3cbd4c68777df41060ce2f9bce42140 Mon Sep 17 00:00:00 2001 From: Arkensor Date: Mon, 12 Feb 2024 18:30:31 +0100 Subject: [PATCH] Fix dyanmic spawned entities id duplicating #32 --- .../Game/EPF_PersistentRootEntityCollection.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/Scripts/Game/EPF_PersistentRootEntityCollection.c b/src/Scripts/Game/EPF_PersistentRootEntityCollection.c index 1b58ddc..c64a412 100644 --- a/src/Scripts/Game/EPF_PersistentRootEntityCollection.c +++ b/src/Scripts/Game/EPF_PersistentRootEntityCollection.c @@ -15,13 +15,8 @@ class EPF_PersistentRootEntityCollection : EPF_MetaDataDbEntity { if (EPF_BitFlags.CheckFlags(persistenceComponent.GetFlags(), EPF_EPersistenceFlags.BAKED)) { - // TODO refactor to use https://feedback.bistudio.com/T172042 when patched - int idx = m_aRemovedBackedRootEntities.Find(persistentId); - if (idx != -1) - { - m_aRemovedBackedRootEntities.Remove(idx); + if (m_aRemovedBackedRootEntities.RemoveItem(persistentId)) return; - } } EPF_PersistenceComponentClass settings = EPF_ComponentData.Get(persistenceComponent); @@ -37,11 +32,13 @@ class EPF_PersistentRootEntityCollection : EPF_MetaDataDbEntity array ids = m_mSelfSpawnDynamicEntities.Get(settings.m_tSaveDataType); if (!ids) { - ids = {}; + ids = {persistentId}; m_mSelfSpawnDynamicEntities.Set(settings.m_tSaveDataType, ids); + return; } - - ids.Insert(persistentId); + + if (!ids.Contains(persistentId)) + ids.Insert(persistentId); } //------------------------------------------------------------------------------------------------