From a06abe550f9239f84cd11268fe0600704b952c90 Mon Sep 17 00:00:00 2001 From: Trevor Slocum Date: Tue, 28 Nov 2023 11:32:22 -0800 Subject: [PATCH] Fix transitioning spectators during rematch --- PROTOCOL.md | 4 ++-- cmd/bgammon-server/server.go | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/PROTOCOL.md b/PROTOCOL.md index 2c20e83..a74be4a 100644 --- a/PROTOCOL.md +++ b/PROTOCOL.md @@ -40,8 +40,8 @@ formatted responses are more easily parsed by computers. - List all matches. - Aliases: `ls` -- `create / [name]` - - Create a match. +- `create / [name]` + - Create a match. An `acey` value of 0 represents a standard game, while a value of 1 represents an acey-deucey game. - Aliases: `c` - `join / [password]` diff --git a/cmd/bgammon-server/server.go b/cmd/bgammon-server/server.go index 47ca745..268e001 100644 --- a/cmd/bgammon-server/server.go +++ b/cmd/bgammon-server/server.go @@ -1258,15 +1258,17 @@ COMMANDS: newGame.password = clientGame.password newGame.client1 = clientGame.client1 newGame.client2 = clientGame.client2 + newGame.spectators = make([]*serverClient, len(clientGame.spectators)) + copy(newGame.spectators, clientGame.spectators) newGame.Player1 = clientGame.Player1 newGame.Player2 = clientGame.Player2 newGame.allowed1 = clientGame.allowed1 newGame.allowed2 = clientGame.allowed2 - copy(newGame.spectators, clientGame.spectators) s.games = append(s.games, newGame) clientGame.client1 = nil clientGame.client2 = nil + clientGame.spectators = nil s.gamesLock.Unlock()