From 4f30a47c0763fa65222bbbe88162ddc20152c9ea Mon Sep 17 00:00:00 2001 From: Brant Martin Date: Tue, 25 Jun 2019 16:11:13 -0400 Subject: [PATCH] Handle conflicting connection attempts gracefully --- Torch.Server/Managers/MultiplayerManagerDedicated.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Torch.Server/Managers/MultiplayerManagerDedicated.cs b/Torch.Server/Managers/MultiplayerManagerDedicated.cs index 34fd09e..f5c52ba 100644 --- a/Torch.Server/Managers/MultiplayerManagerDedicated.cs +++ b/Torch.Server/Managers/MultiplayerManagerDedicated.cs @@ -219,7 +219,12 @@ namespace Torch.Server.Managers _log.Info($"Connection attempt by {steamId} from {ip}"); - if (Torch.CurrentSession.KeenSession.OnlineMode == MyOnlineModeEnum.OFFLINE && + if (Players.ContainsKey(steamId)) + { + _log.Warn($"Player {steamId} already has already joined!"); + UserRejected(steamId, JoinResult.AlreadyJoined); + } + else if (Torch.CurrentSession.KeenSession.OnlineMode == MyOnlineModeEnum.OFFLINE && promoteLevel < MyPromoteLevel.Admin) { _log.Warn($"Rejecting user {steamId}, world is set to offline and user is not admin."); @@ -337,4 +342,4 @@ namespace Torch.Server.Managers #endregion } -} \ No newline at end of file +}