From 1082d874b4ce55707ff4b7216a9bb58e5fd595ff Mon Sep 17 00:00:00 2001 From: Rutherther Date: Fri, 30 Dec 2022 19:49:55 +0100 Subject: [PATCH] fix(game): do not replace character with player in map entities --- Core/NosSmooth.Game/Data/Maps/MapEntities.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Core/NosSmooth.Game/Data/Maps/MapEntities.cs b/Core/NosSmooth.Game/Data/Maps/MapEntities.cs index ddf7c0d..b65dac9 100644 --- a/Core/NosSmooth.Game/Data/Maps/MapEntities.cs +++ b/Core/NosSmooth.Game/Data/Maps/MapEntities.cs @@ -5,6 +5,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Concurrent; +using NosSmooth.Game.Data.Characters; using NosSmooth.Game.Data.Entities; using NosSmooth.Packets.Enums; @@ -69,7 +70,19 @@ public class MapEntities /// The entity to add. internal void AddEntity(IEntity entity) { - _entities.AddOrUpdate(entity.Id, _ => entity, (i, e) => entity); + _entities.AddOrUpdate + ( + entity.Id, + _ => entity, + (_, e) => + { + if (entity is Player && e is Character) + { // Do not replace Character with Player! + return e; + } + return entity; + } + ); } /// -- 2.49.0