Allow out-of-turn switching to Machine mode
authorH.G.Muller <hgm@hgm-xboard.(none)>
Sun, 18 Dec 2022 13:24:01 +0000 (14:24 +0100)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Sun, 18 Dec 2022 13:28:47 +0000 (14:28 +0100)
It is now also possible to switch to Machine White or Machine Black
when the side we switch the engine to is not on move. This is treated
the same way as if the engine was suspended because of a book hit.

backend.c

index e6f6f18..5a9cea5 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -15239,12 +15239,12 @@ MachineWhiteEvent ()
 
     if (gameMode == EditPosition)
         EditPositionDone(TRUE);
-
+/*
     if (!WhiteOnMove(currentMove)) {
        DisplayError(_("It is not White's turn"), 0);
        return;
     }
-
+*/
     if (gameMode == AnalyzeMode || gameMode == AnalyzeFile)
       ExitAnalyzeMode();
 
@@ -15260,6 +15260,14 @@ MachineWhiteEvent ()
     gameMode = MachinePlaysWhite;
     pausing = FALSE;
     ModeHighlight();
+
+    if(!WhiteOnMove(currentMove)) {
+        first.bookSuspend = TRUE;
+       StartClocks();
+       firstMove = FALSE;
+       return;
+    }
+
     SetGameInfo();
     snprintf(buf, MSG_SIZ, "%s %s %s", gameInfo.white, _("vs."), gameInfo.black);
     DisplayTitle(buf);
@@ -15322,12 +15330,12 @@ MachineBlackEvent ()
 
     if (gameMode == EditPosition)
         EditPositionDone(TRUE);
-
+/*
     if (WhiteOnMove(currentMove)) {
        DisplayError(_("It is not Black's turn"), 0);
        return;
     }
-
+*/
     if (gameMode == AnalyzeMode || gameMode == AnalyzeFile)
       ExitAnalyzeMode();
 
@@ -15339,6 +15347,14 @@ MachineBlackEvent ()
     gameMode = MachinePlaysBlack;
     pausing = FALSE;
     ModeHighlight();
+
+    if(WhiteOnMove(currentMove)) {
+        first.bookSuspend = TRUE;
+       StartClocks();
+       firstMove = FALSE;
+       return;
+    }
+
     SetGameInfo();
     snprintf(buf, MSG_SIZ, "%s %s %s", gameInfo.white, _("vs."), gameInfo.black);
     DisplayTitle(buf);