From: H.G.Muller Date: Fri, 7 Dec 2018 22:02:48 +0000 (+0100) Subject: Pass command to DoCommand through global command queue X-Git-Tag: v4.0~22 X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=0bcc18ddfe1e849b345a565850e2a14cdab30d1a;p=uci2wb.git Pass command to DoCommand through global command queue Rather than passing the command to process as a parameter to DoCommand, we now append it to a global 'command queue', from which DoCommand() then reads the first line. This in preparation for letting the engine thread handle the difficult commands. --- diff --git a/UCI2WB.c b/UCI2WB.c index 4cbf5a8..0e7f34f 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -436,8 +436,9 @@ Move4Engine(char *m) } } -int DoCommand (char *line); +int DoCommand (); char mySide; +char queue[10000], *qStart, *qEnd; void GUI2Engine() @@ -532,16 +533,19 @@ 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; + if(qStart == qEnd) qStart = qEnd = queue; + p = line; while(qEnd < queue+10000 && (*qEnd++ = *p++) != '\n') {} + if(DoCommand()) goto nomove; } } int -DoCommand (char *line) +DoCommand () { - char command[256], *p, *q, *r, type[99]; + 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")) {