X-Git-Url: http://winboard.nl/cgi-bin?p=uci2wb.git;a=blobdiff_plain;f=UCI2WB.c;h=e0570a299636ac915123bfb42a661d337e6839b5;hp=cf506317485042a37575ddc470a896031444b68c;hb=c40a62807f5efb7b42a6136b1c31f11be26078df;hpb=ec2b5e72ae93d42e3556469abde71f90d2c09254 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