Skip to content

Commit

Permalink
bug: fix entity list removing free indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
JayArrowz committed Jul 31, 2021
1 parent 3c69f1f commit 1a3b431
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions NetScape.Modules.World/PlayerEntityList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class PlayerEntityList : IEntityList<Player>
{
private readonly Player[] _entities = new Player[2048];
private int _entityCount = 0;
private List<int> _freeIndexes = new();
private readonly List<int> _freeIndexes = new();

public void Add(Player entity)
{
Expand All @@ -32,14 +32,14 @@ public void Add(Player entity)

private void SetIndex(Player entity, int index)
{
_freeIndexes.Remove(index);
entity.Index = index;
_entities[index] = entity;
}

public void Remove(Player entity)
{
_entities[entity.Index] = null;
_freeIndexes.Remove(entity.Index);
Interlocked.Decrement(ref _entityCount);
}

Expand Down

0 comments on commit 1a3b431

Please sign in to comment.