From 170b9a1ed61ff117a1d95f099436460ab927a1d4 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 18 Apr 2020 20:59:15 -0700 Subject: [PATCH] set turn to -1 while waiting for phonies check When a guest sends a move to the server it's not the next player's turn until the server checks the move and rejects or accepts it. It was possible still to manipulate the board, playing new tiles, and even to attempt to commit them. And if the move came back rejected, the bogus committed one would be that was cleared. Bad. So I'm just setting the turn to -1, which disables board etc., and letting nextTurn() assigne it after the confirmation comes back. --- xwords4/common/server.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xwords4/common/server.c b/xwords4/common/server.c index 3c31750ba..476b769d3 100644 --- a/xwords4/common/server.c +++ b/xwords4/common/server.c @@ -3598,6 +3598,7 @@ finishMove( ServerCtxt* server, TrayTileSet* newTiles, XP_U16 turn ) } else if (isClient && (gi->phoniesAction == PHONIES_DISALLOW) && nTilesMoved > 0 ) { SETSTATE( server, XWSTATE_MOVE_CONFIRM_WAIT ); + setTurn( server, -1 ); #endif } else { nextTurn( server, PICK_NEXT ); @@ -3877,6 +3878,7 @@ handleMoveOk( ServerCtxt* server, XWStreamCtxt* XP_UNUSED(incoming) ) XP_ASSERT( server->nv.gameState == XWSTATE_MOVE_CONFIRM_WAIT ); SETSTATE( server, XWSTATE_INTURN ); + setTurn( server, 0 ); nextTurn( server, PICK_NEXT ); return accepted; @@ -4125,6 +4127,7 @@ server_receiveMessage( ServerCtxt* server, XWStreamCtxt* incoming ) case XWPROTO_BADWORD_INFO: accepted = handleIllegalWord( server, incoming ); if ( accepted && server->nv.gameState != XWSTATE_GAMEOVER ) { + setTurn( server, 0 ); nextTurn( server, PICK_NEXT ); } break;