From de9acb223684a477568f73ce5bbd3b5982b191a7 Mon Sep 17 00:00:00 2001 From: GuoWQ222 Date: Sat, 13 Apr 2024 21:17:17 +0800 Subject: [PATCH] fix small bugs --- logic/Server/RpcServices.cs | 42 +++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/logic/Server/RpcServices.cs b/logic/Server/RpcServices.cs index a0903685..80830dbe 100755 --- a/logic/Server/RpcServices.cs +++ b/logic/Server/RpcServices.cs @@ -177,37 +177,43 @@ public override async Task AddPlayer(PlayerMsg request, IServerStreamWriter()?.Find( + ship => ship.PlayerID == request.PlayerId); do { if (request.TeamId == 0) semaDict0[request.PlayerId].Item1.Wait(); else if (request.TeamId == 1) semaDict1[request.PlayerId].Item1.Wait(); - try + if (ship == null || ship.IsRemoved == true) + { } + else { - if (currentGameInfo != null && !exitFlag) + try { - await responseStream.WriteAsync(currentGameInfo); - Console.WriteLine("Send!"); + if (currentGameInfo != null && !exitFlag) + { + await responseStream.WriteAsync(currentGameInfo); + Console.WriteLine("Send!"); + } } - } - catch - { - if (!exitFlag) + catch + { + if (!exitFlag) + { + Console.WriteLine($"The client {request.PlayerId} exited"); + exitFlag = true; + } + } + finally { - Console.WriteLine($"The client {request.PlayerId} exited"); - exitFlag = true; + if (request.TeamId == 0) + semaDict0[request.PlayerId].Item2.Release(); + else if (request.TeamId == 1) + semaDict1[request.PlayerId].Item2.Release(); } } - finally - { - if (request.TeamId == 0) - semaDict0[request.PlayerId].Item2.Release(); - else if (request.TeamId == 1) - semaDict1[request.PlayerId].Item2.Release(); - } } while (game.GameMap.Timer.IsGaming); #if DEBUG Console.WriteLine("END Add Player");