From db754f560187f1cf3ae897f9eef785369f5b5a68 Mon Sep 17 00:00:00 2001 From: Marco Date: Tue, 23 Apr 2024 19:29:32 +0200 Subject: [PATCH] Do not remove a disconnected player from the 'player' slice since that crashes the server --- chess/game.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/chess/game.go b/chess/game.go index 09b6a57..b8df92b 100644 --- a/chess/game.go +++ b/chess/game.go @@ -8,7 +8,6 @@ import ( "mchess_server/types" "github.com/google/uuid" - "github.com/samber/lo" "nhooyr.io/websocket" ) @@ -210,11 +209,6 @@ func (game Game) broadcastGameEnd(reason GameEndedReason) error { } func (game *Game) playerDisconnected(p *Player) { - log.Println(string(p.color), " disconnected") - playerStillInGame := lo.Filter(game.players, func(player *Player, _ int) bool { - return player.color != p.color - }) - game.players = playerStillInGame } func (game *Game) SetWebsocketConnectionFor(ctx context.Context, p *Player, ws *websocket.Conn) {