Skip to content

Commit

Permalink
fix childs corruption
Browse files Browse the repository at this point in the history
  • Loading branch information
RevenantX committed Dec 15, 2024
1 parent 7f4c9be commit ea5a1d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions LiteEntitySystem/ServerEntityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,11 @@ protected override unsafe void OnLogicTick()

internal override void EntityFieldChanged<T>(InternalEntity entity, ushort fieldId, ref T newValue)
{
if (entity.IsDestroyed && _stateSerializers[entity.Id].Entity != entity)
{
//old freed entity
return;
}
_changedEntities.Add(entity);
_stateSerializers[entity.Id].MarkFieldChanged(fieldId, _tick, ref newValue);
}
Expand Down
2 changes: 1 addition & 1 deletion LiteEntitySystem/SyncVar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public T Value
get => _value;
set
{
if (Container != null && !Container.IsDestroyed && !Utils.FastEquals(ref value, ref _value))
if (Container != null && !Utils.FastEquals(ref value, ref _value))
Container.EntityManager.EntityFieldChanged(Container, FieldId, ref value);
_value = value;
}
Expand Down

0 comments on commit ea5a1d0

Please sign in to comment.