X-Git-Url: http://winboard.nl/cgi-bin?p=uci2wb.git;a=blobdiff_plain;f=UCI2WB.c;h=41c71c81f97880a7f7de80da1b5d1f675a32d47d;hp=b901bbcbcba92bb1b9b6ae82c0a0b2a487756ade;hb=990ae69c6d5ff8468541372acc4c6fcb854f64e2;hpb=1788d5e3e95e8b959a382171f31da23cc10d5ee3 diff --git a/UCI2WB.c b/UCI2WB.c index b901bbc..41c71c8 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -160,9 +160,10 @@ StartSearch(char *ponder) } void -StopPonder(int pondering) +StopSearch(int discard) { - if(!pondering) return; + if(!searching) return; + if(discard) searching = 0; // this causes bestmove to be ignored EPRINT((f, "# stop\n")) fflush(toE); // note: 'pondering' remains set until engine acknowledges 'stop' with 'bestmove' } @@ -457,10 +458,13 @@ GUI2Engine() else if(!strcmp(command, "offer")) drawOffer = 1; // backlogged anyway, so this can be done instantly else if(!strcmp(command, "post")) post = 1; else if(!strcmp(command, "nopost"))post = 0; + else if(!strcmp(command, ".")) { + printf("stat01: %d %d %d %d 100 %s\n", statTime, statNodes, statDepth, 100-currNr, currMove); + } 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 - if(searching) searching = 0, StopPonder(1); + StopSearch(1); } else { //convert easy & hard to "option" after treating their effect on the adapter if(!strcmp(command, "easy")) { @@ -493,7 +497,7 @@ GUI2Engine() EPRINT((f, "# ponderhit%s\n", draw)) fflush(toE); fflush(stdout); continue; } - searching = 0; StopPonder(1); + StopSearch(1); } strcpy(move[moveNr++], command); // possibly overwrites ponder move *qEnd++ = '\n'; Sync(WAKEUP); // make sure engine thread considers starting a search @@ -505,8 +509,8 @@ GUI2Engine() { if(searching == 3) { // command arrived during thinking; order abort for 'instant commands' if(!strcmp(command, "?") || !strcmp(command, "quit") || - !strcmp(command, "force") || !strcmp(command, "result")) StopPonder(1); - } else if(searching) searching = 0, StopPonder(1); // always abort pondering or analysis + !strcmp(command, "force") || !strcmp(command, "result")) StopSearch(0); + } else StopSearch(1); // always abort pondering or analysis // queue command for execution by engine thread if(qStart == qEnd) qStart = qEnd = queue; @@ -586,10 +590,6 @@ DoCommand () else if(!strcmp(command, "undo") && (i=1) || !strcmp(command, "remove") && (i=2)) { moveNr = moveNr > i ? moveNr - i : 0; collect = (computer == ANALYZE); sm = 0; } - else if(!strcmp(command, ".")) { - printf("stat01: %d %d %d %d 100 %s\n", statTime, statNodes, statDepth, 100-currNr, currMove); - return 1; - } else if(!strcmp(command+2, "clude") && collect > 2) { // include or exclude int all = !strcmp(line+8, "all"), in = command[1] == 'n'; inex = 1; line[strlen(line)-1] = sm = 0; // strip LF and clear sm flag