From: H.G.Muller Date: Fri, 7 Dec 2018 21:35:01 +0000 (+0100) Subject: Parse 'difficult' commands in separate routine X-Git-Tag: v4.0~23 X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=f9b3d49480bbbf3200dde21ca58dcd5ae41bcfa1;p=uci2wb.git Parse 'difficult' commands in separate routine The parsing of (most) commands that can only be executed when not searching is now put in a separate routine DoCommand(). This in preparation for having the engine thread do this. --- diff --git a/UCI2WB.c b/UCI2WB.c index e87504a..4cbf5a8 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -436,10 +436,13 @@ Move4Engine(char *m) } } +int DoCommand (char *line); +char mySide; + void GUI2Engine() { - char line[256], command[256], *p, *q, *r, mySide, type[99]; + char line[256], command[256], *p; while(1) { int i, difficult, think=0; @@ -529,6 +532,18 @@ GUI2Engine() !strcmp(command, "force") || !strcmp(command, "result")) { EPRINT((f, "# stop\n")); fflush(toE); } Sync(PAUSE); Release(); // block processing of difficult commands during thinking; send backlog left because of race } + if(DoCommand(line)) goto nomove; + } +} + +int +DoCommand (char *line) +{ + char command[256], *p, *q, *r, type[99]; + int i; + + sscanf(line, "%s", command); + if(!strcmp(command, "new")) { computer = BLACK; moveNr = 0; depth = -1; move[0][0] = 0; stm = WHITE; strcpy(iniPos, "position startpos"); frc &= ~1; @@ -585,13 +600,13 @@ GUI2Engine() } else if(!strcmp(command, ".")) { printf("stat01: %d %d %d %d 100 %s\n", statTime, statNodes, statDepth, 100-currNr, currMove); - goto nomove; + 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 for(i=1; i