From b8fe2bb13f887fe1276d50d04ba7f25473e11afb Mon Sep 17 00:00:00 2001 From: edmand46 Date: Sun, 4 Feb 2024 20:06:07 +0300 Subject: [PATCH] :bug: wrong condition in lobby in memory on finding room by id --- .../Sources/Lobby/RagonLobbyInMemory.cs | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Ragon.Server/Sources/Lobby/RagonLobbyInMemory.cs b/Ragon.Server/Sources/Lobby/RagonLobbyInMemory.cs index b8bcefe..f3b287c 100644 --- a/Ragon.Server/Sources/Lobby/RagonLobbyInMemory.cs +++ b/Ragon.Server/Sources/Lobby/RagonLobbyInMemory.cs @@ -25,12 +25,20 @@ public class LobbyInMemory : IRagonLobby private readonly List _rooms = new(); private readonly Logger _logger = LogManager.GetCurrentClassLogger(); - public bool FindRoomById(string RagonRoomId, [MaybeNullWhen(false)] out RagonRoom room) + public bool FindRoomById(string roomId, [MaybeNullWhen(false)] out RagonRoom room) { foreach (var existRagonRoom in _rooms) { - if (existRagonRoom.Id == RagonRoomId && existRagonRoom.PlayerMin < existRagonRoom.PlayerMax) + if (existRagonRoom.Id == roomId) { + if (existRagonRoom.PlayerCount >= existRagonRoom.PlayerMax) + { + _logger.Warn($"Room with id {roomId} fulfilled"); + + room = default; + return false; + } + room = existRagonRoom; return true; } @@ -44,8 +52,16 @@ public class LobbyInMemory : IRagonLobby { foreach (var existsRoom in _rooms) { - if (existsRoom.Scene == sceneName && existsRoom.PlayerCount < existsRoom.PlayerMax) + if (existsRoom.Scene == sceneName) { + if (existsRoom.PlayerCount >= existsRoom.PlayerMax) + { + _logger.Warn($"Room with scene {sceneName} fulfilled"); + + room = default; + return false; + } + room = existsRoom; return true; }