Pass command to DoCommand through global command queue
[uci2wb.git] / UCI2WB.c
index 4cbf5a8..0e7f34f 100644 (file)
--- a/UCI2WB.c
+++ b/UCI2WB.c
@@ -436,8 +436,9 @@ Move4Engine(char *m)
     }\r
 }\r
 \r
-int DoCommand (char *line);\r
+int DoCommand ();\r
 char mySide;\r
+char queue[10000], *qStart, *qEnd;\r
 \r
 void\r
 GUI2Engine()\r
@@ -532,16 +533,19 @@ GUI2Engine()
               !strcmp(command, "force") || !strcmp(command, "result")) { EPRINT((f, "# stop\n")); fflush(toE); }\r
            Sync(PAUSE); Release(); // block processing of difficult commands during thinking; send backlog left because of race\r
        }\r
-       if(DoCommand(line)) goto nomove;\r
+       if(qStart == qEnd) qStart = qEnd = queue;\r
+       p = line; while(qEnd < queue+10000 && (*qEnd++ = *p++) != '\n') {}\r
+       if(DoCommand()) goto nomove;\r
     }\r
 }\r
 \r
 int\r
-DoCommand (char *line)\r
+DoCommand ()\r
 {\r
-    char command[256], *p, *q, *r, type[99];\r
+    char line[1024], command[256], *p, *q, *r, type[99];\r
     int i;\r
 \r
+    p=line; while(qStart < qEnd && (*p++ = *qStart++) != '\n') {} *p = 0;\r
     sscanf(line, "%s", command);\r
 \r
        if(!strcmp(command, "new")) {\r