From 1a3b4318a6b8b9fad8ca972d5d8759afffb9083f Mon Sep 17 00:00:00 2001 From: JayArrowz Date: Sat, 31 Jul 2021 13:03:45 +0100 Subject: [PATCH] bug: fix entity list removing free indexes --- NetScape.Modules.World/PlayerEntityList.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NetScape.Modules.World/PlayerEntityList.cs b/NetScape.Modules.World/PlayerEntityList.cs index a6a751d..b5bec5a 100644 --- a/NetScape.Modules.World/PlayerEntityList.cs +++ b/NetScape.Modules.World/PlayerEntityList.cs @@ -12,7 +12,7 @@ public class PlayerEntityList : IEntityList { private readonly Player[] _entities = new Player[2048]; private int _entityCount = 0; - private List _freeIndexes = new(); + private readonly List _freeIndexes = new(); public void Add(Player entity) { @@ -32,6 +32,7 @@ public void Add(Player entity) private void SetIndex(Player entity, int index) { + _freeIndexes.Remove(index); entity.Index = index; _entities[index] = entity; } @@ -39,7 +40,6 @@ private void SetIndex(Player entity, int index) public void Remove(Player entity) { _entities[entity.Index] = null; - _freeIndexes.Remove(entity.Index); Interlocked.Decrement(ref _entityCount); }