From: H.G. Muller Date: Wed, 12 Dec 2012 16:52:21 +0000 (+0100) Subject: Allow faking of options the engine fails to announce X-Git-Tag: v2.0~26 X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=c40a62807f5efb7b42a6136b1c31f11be26078df;p=uci2wb.git Allow faking of options the engine fails to announce A file DefectiveEngineOptions.ini will be read as if it is engine output before any real engine output. This can be used to fake UCI 'option' commands that the engine fails to announce, so that they will appear in the GUI's Engine Settings dialog, and can be changed by user or GUI. --- diff --git a/UCI2WB.c b/UCI2WB.c index cf50631..e0570a2 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -34,7 +34,7 @@ char move[2000][10], checkOptions[8192], iniPos[256], hashOpt[20], pause, ponder int mps, tc, inc, sTime, depth, myTime, hisTime, stm, computer = NONE, memory, oldMem=0, cores, moveNr, lastDepth, lastScore, startTime, debug; int statDepth, statScore, statNodes, statTime, currNr, size, collect, nr, sm, inex, on[500]; char currMove[20], moveMap[500][10]; // for analyze mode -FILE *toE, *fromE; +FILE *toE, *fromE, *fromF; int pid; #ifdef WIN32 @@ -151,20 +151,32 @@ Move4GUI(char *m) } } +int +GetChar() +{ + int c; + if(fromF) { + if((c = fgetc(fromF)) != EOF) return c; + fclose(fromF); fromF = 0; printf("# end fake\n"); + } + return fgetc(fromE); +} + void * Engine2GUI() { char line[1024], command[256]; + if(fromF = fopen("DefectiveEngineOptions.ini", "r")) printf("# fake engine input\n"); while(1) { int i=0, x; char *p, dummy; fflush(stdout); fflush(toE); - while((line[i] = x = fgetc(fromE)) != EOF && line[i] != '\n') i++; + while((line[i] = x = GetChar()) != EOF && line[i] != '\n') i++; line[++i] = 0; if(x == EOF) exit(0); DPRINT("# engine said: %s", line), fflush(stdout); - sscanf(line, "%s", command); + if(sscanf(line, "%s", command) != 1) continue; if(!strcmp(command, "bestmove")) { if(pause) { pondering = pause = 0; Sync(WAKEUP); continue; } // bestmove was reply to ponder miss or analysis result; ignore. // move was a move to be played