From e1f480b44a87274361645ce539123772823f16d8 Mon Sep 17 00:00:00 2001 From: Stanley Dimant Date: Fri, 19 Jul 2024 02:45:06 +0200 Subject: [PATCH] throw errors for multiple character with same name + world set up in config --- .../ServerConfigurationManager.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/MareSynchronos/Services/ServerConfiguration/ServerConfigurationManager.cs b/MareSynchronos/Services/ServerConfiguration/ServerConfigurationManager.cs index 8bfd106..b68bb25 100644 --- a/MareSynchronos/Services/ServerConfiguration/ServerConfigurationManager.cs +++ b/MareSynchronos/Services/ServerConfiguration/ServerConfigurationManager.cs @@ -100,10 +100,16 @@ public class ServerConfigurationManager Save(); } - var auth = currentServer.Authentications.Find(f => string.Equals(f.CharacterName, charaName, StringComparison.Ordinal) && f.WorldId == worldId); - if (auth == null) return null; + var auth = currentServer.Authentications.FindAll(f => string.Equals(f.CharacterName, charaName, StringComparison.Ordinal) && f.WorldId == worldId); + if (auth.Count >= 2) + { + _mareMediator.Publish(new NotificationMessage("Multiple Identical Characters detected", "Your Service configuration has multiple characters with the same name and world set up. Please delete the duplicates.", + NotificationType.Error)); + return null; + } + if (auth.Count == 0) return null; - if (currentServer.SecretKeys.TryGetValue(auth.SecretKeyIdx, out var secretKey)) + if (currentServer.SecretKeys.TryGetValue(auth.Single().SecretKeyIdx, out var secretKey)) { return secretKey.Key; }