Skip to content

Commit

Permalink
Merge pull request #219 from GuoWQ222/dev
Browse files Browse the repository at this point in the history
fix small bugs
  • Loading branch information
Grange007 authored Apr 13, 2024
2 parents 92c8cf6 + de9acb2 commit 14eac47
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions logic/Server/RpcServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,37 +177,43 @@ public override async Task AddPlayer(PlayerMsg request, IServerStreamWriter<Mess
StartGame();
}
}

bool exitFlag = false;
Ship? ship = game.GameMap.GameObjDict[GameObjType.Ship].Cast<Ship>()?.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");
Expand Down

0 comments on commit 14eac47

Please sign in to comment.