X-Git-Url: http://winboard.nl/cgi-bin?p=uci2wb.git;a=blobdiff_plain;f=UCI2WB.c;h=0e7f34f0fe7bea3bafa54ca4e62162d7484cc9e9;hp=e87504ae4a616bb3fadee27287c5ccfd53e4735d;hb=0bcc18ddfe1e849b345a565850e2a14cdab30d1a;hpb=0eb214919078bb63985e66a39b392a7d125e3218 diff --git a/UCI2WB.c b/UCI2WB.c index e87504a..0e7f34f 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -436,10 +436,14 @@ Move4Engine(char *m) } } +int DoCommand (); +char mySide; +char queue[10000], *qStart, *qEnd; + 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 +533,21 @@ 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(qStart == qEnd) qStart = qEnd = queue; + p = line; while(qEnd < queue+10000 && (*qEnd++ = *p++) != '\n') {} + if(DoCommand()) goto nomove; + } +} + +int +DoCommand () +{ + char line[1024], command[256], *p, *q, *r, type[99]; + int i; + + p=line; while(qStart < qEnd && (*p++ = *qStart++) != '\n') {} *p = 0; + 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 +604,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