diff --git a/UdpHosts/GameServer/Systems/EntityManager/EntityManager.cs b/UdpHosts/GameServer/Systems/EntityManager/EntityManager.cs index a8183449..19a6dc1f 100644 --- a/UdpHosts/GameServer/Systems/EntityManager/EntityManager.cs +++ b/UdpHosts/GameServer/Systems/EntityManager/EntityManager.cs @@ -1434,7 +1434,12 @@ public void ScopeIn(INetworkPlayer player, IEntity entity) public void ScopeOut(INetworkPlayer player, IEntity entity) { - _scopedPlayersByEntity[entity.EntityId].Remove(player); + // Remove the tracking even if the player can't receive the scope out. + // The entity can already be removed. Refer to the same guard in ScopeIn. + if (_scopedPlayersByEntity.TryGetValue(entity.EntityId, out var scopedPlayers)) + { + scopedPlayers.Remove(player); + } // Avoid sending messages if player is not in the appropriate state if (!player.CanReceiveGSS) @@ -1442,12 +1447,6 @@ public void ScopeOut(INetworkPlayer player, IEntity entity) return; } - // The entity can already be removed. Refer to the same guard in ScopeIn. - if (_scopedPlayersByEntity.TryGetValue(entity.EntityId, out var scopedPlayers)) - { - scopedPlayers.Remove(player); - } - if (entity is CharacterEntity character) { if (character.IsPlayerControlled && character.Player == player)