From: H.G.Muller Date: Sat, 8 Dec 2018 11:59:02 +0000 (+0100) Subject: Fix pause/resume X-Git-Tag: v4.0~13 X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=1788d5e3e95e8b959a382171f31da23cc10d5ee3;p=uci2wb.git Fix pause/resume Tne 'pause' and 'resume' commands are executed in the GUI thread for instant obedience. But they have to take care that a move produced by an aborted think is ignored (by setting searching = 0 before stopping it), and that the engine thread has to be signalled to restart it. --- diff --git a/UCI2WB.c b/UCI2WB.c index 536eb44..b901bbc 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -460,7 +460,7 @@ GUI2Engine() else if(!strcmp(command, "pause")) { if(computer == stm) myTime -= GetTickCount() - startTime; suspended = 1 + (searching == 1); // remember if we were pondering, and stop search ignoring bestmove - StopPonder(searching); + if(searching) searching = 0, StopPonder(1); } else { //convert easy & hard to "option" after treating their effect on the adapter if(!strcmp(command, "easy")) { @@ -468,8 +468,8 @@ GUI2Engine() } else if(!strcmp(command, "hard")) { if(*canPonder) ponder = 1, sprintf(command, "option"), sprintf(line, "option %s=1\n", canPonder); else continue; - } else - if(!strcmp(command, "option")) { + } + else if(!strcmp(command, "option")) { if(sscanf(line+7, "UCI2WB debug output=%d", &debug) == 1) ; else if(sscanf(line+7, "ponder always=%d", &ponderAlways) == 1) ; else if(sscanf(line+7, "Floating Byoyomi=%d", &flob) == 1) ; else @@ -499,9 +499,8 @@ GUI2Engine() *qEnd++ = '\n'; Sync(WAKEUP); // make sure engine thread considers starting a search } else if(!strcmp(command, "resume")) { - searching = 0; if(suspended == 2) StartPonder(moveNr); // restart interrupted ponder search - suspended = 0; // causes thinking to start in normal way if on move or analyzing + suspended = 0; *qEnd++ = '\n'; Sync(WAKEUP); // causes search to start in normal way if on move or analyzing } else { if(searching == 3) { // command arrived during thinking; order abort for 'instant commands'