fix: Prevent cascading deletes during world deserialization (#2298)
### Summary Fixes an issue where deleting entities during world load can cause cascading delete failures when the world is not fully loaded.
This commit is contained in:
parent
cc4a679fb0
commit
9887818e7e
1 changed files with 15 additions and 1 deletions
|
|
@ -345,8 +345,21 @@ public class GenericEntityPersistence<T> : GenericPersistence, IGenericEntityPer
|
|||
_entities.Clear();
|
||||
_entities.TrimExcess();
|
||||
_entities = null;
|
||||
|
||||
if (_toDelete != null)
|
||||
{
|
||||
foreach (var t in _toDelete)
|
||||
{
|
||||
t.Delete();
|
||||
}
|
||||
|
||||
_toDelete.Clear();
|
||||
_toDelete = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static List<T> _toDelete;
|
||||
|
||||
private unsafe void InternalDeserialize(string filePath, int index, Dictionary<ulong, string> typesDb)
|
||||
{
|
||||
using var mmf = MemoryMappedFile.CreateFromFile(filePath, FileMode.Open);
|
||||
|
|
@ -415,7 +428,8 @@ public class GenericEntityPersistence<T> : GenericPersistence, IGenericEntityPer
|
|||
}
|
||||
}
|
||||
|
||||
t.Delete();
|
||||
_toDelete ??= [];
|
||||
_toDelete.Add(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue