X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=UCI2WB.c;h=4cbf5a87819667a4b3e66be87e2e24f96c6a9be0;hb=f9b3d49480bbbf3200dde21ca58dcd5ae41bcfa1;hp=c0ace0f5d0e2a2a1cf8561330785dbd6a8e69ee8;hpb=29739720e2b8d549906e235e88bdc603491e9aa3;p=uci2wb.git diff --git a/UCI2WB.c b/UCI2WB.c index c0ace0f..4cbf5a8 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -250,12 +250,11 @@ ReadLine (FILE *f, char *line) return (x != EOF); } -void * -Engine2GUI() +void +HandleEngineOutput() { char line[1024], command[256]; static char egts[999]; - if(fromF = fopen("DefectiveEngineOptions.ini", "r")) printf("# fake engine input\n"); while(1) { int i=0, x; char *p, dummy, len; @@ -412,6 +411,13 @@ Engine2GUI() } } +void * +Engine2GUI() +{ + if(fromF = fopen("DefectiveEngineOptions.ini", "r")) printf("# fake engine input\n"); + HandleEngineOutput(); +} + void Move4Engine(char *m) { @@ -430,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; @@ -523,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; @@ -579,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