Skip to content

Commit

Permalink
Merge pull request #161 from timiimit/fix-gameserver-player-updates
Browse files Browse the repository at this point in the history
Fix gameserver player updates
  • Loading branch information
timiimit authored Feb 2, 2023
2 parents a6c7067 + b2bd2be commit e3d0380
Showing 1 changed file with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,29 @@ public async Task<IActionResult> UpdateGameServerPlayers(string id, [FromBody] G
if (server.OwningClientID != user.Session.ClientID)
Unauthorized();

server.PublicPlayers = serverOnlyWithPlayers.PublicPlayers;
server.PrivatePlayers = serverOnlyWithPlayers.PrivatePlayers;
// handle player list update
foreach (var player in serverOnlyWithPlayers.PublicPlayers)
{
if (!server.PublicPlayers.Where(x => x == player).Any())
{
server.PublicPlayers.Add(player);
}
if (server.PrivatePlayers.Where(x => x == player).Any())
{
server.PrivatePlayers.Remove(player);
}
}
foreach (var player in serverOnlyWithPlayers.PrivatePlayers)
{
if (!server.PrivatePlayers.Where(x => x == player).Any())
{
server.PrivatePlayers.Add(player);
}
if (server.PublicPlayers.Where(x => x == player).Any())
{
server.PublicPlayers.Remove(player);
}
}

await matchmakingService.UpdateAsync(server);

Expand All @@ -258,8 +279,10 @@ public async Task<IActionResult> RemovePlayer(string id, [FromBody] EpicID[] pla

foreach (var player in players)
{
server.PublicPlayers.Remove(player);
server.PrivatePlayers.Remove(player);
if (!server.PublicPlayers.Remove(player))
{
server.PrivatePlayers.Remove(player);
}
}

await matchmakingService.UpdateAsync(server);
Expand Down

0 comments on commit e3d0380

Please sign in to comment.