X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=f8ad17c6890514473c285a31bcfff9c66aeca110;hb=82c3965009311d49a9f565e27804b2235b8f295f;hp=79774fa7003ea717deb6d23389dd602b580be281;hpb=7937bbea6d9e0644cd8a5c39e2c6d6320368945a;p=xboard.git diff --git a/backend.c b/backend.c index 79774fa..f8ad17c 100644 --- a/backend.c +++ b/backend.c @@ -940,6 +940,16 @@ FloatToFront(char **list, char *engineLine) } void +SaveEngineList () +{ + FILE *f; + if(*engineListFile && (f = fopen(engineListFile, "w"))) { + fprintf(f, "-firstChessProgramNames {%s}\n", firstChessProgramNames); + fclose(f); + } +} + +void AddToEngineList (int i) { int len; @@ -962,6 +972,7 @@ AddToEngineList (int i) if(insert != q) insert[-1] = NULLCHAR; snprintf(firstChessProgramNames, len, "%s\n%s\n%s", q, buf, insert); if(q) free(q); + SaveEngineList(); FloatToFront(&appData.recentEngineList, buf); ASSIGN(currentEngine[i], buf); } @@ -972,7 +983,7 @@ LoadEngine () int i; if(WaitForEngine(savCps, LoadEngine)) return; if(tryNr == 1 && !isUCI) { SendToProgram("uci\n", savCps); tryNr = 2; ScheduleDelayedEvent(LoadEngine, FEATURE_TIMEOUT); return; } - if(tryNr) v1 = (tryNr == 2), tryNr = 0, AddToEngineList(0); // deferred to after protocol determination + if(tryNr) v1 |= (tryNr == 2), tryNr = 0, AddToEngineList(0); // deferred to after protocol determination CommonEngineInit(); // recalculate time odds if(gameInfo.variant != StringToVariant(appData.variant)) { // we changed variant when loading the engine; this forces us to reset @@ -1001,7 +1012,7 @@ ReplaceEngine (ChessProgramState *cps, int n) appData.clockMode = TRUE; InitEngine(cps, n); UpdateLogos(TRUE); - if(n) return; // only startup first engine immediately; second can wait + if(n && !tryNr) return; // only startup first engine immediately; second can wait (unless autodetect) savCps = cps; // parameter to LoadEngine passed as globals, to allow scheduled calling :-( LoadEngine(); } @@ -1049,13 +1060,13 @@ Load (ChessProgramState *cps, int i) } if(jar) { snprintf(buf3, MSG_SIZ, "java -jar %s", p); p = buf3; } ASSIGN(appData.chessProgram[i], p); + if(isUCI == 3) tryNr = 1, isUCI = 0; // auto-detect appData.isUCI[i] = isUCI; appData.protocolVersion[i] = v1 ? 1 : PROTOVER; appData.hasOwnBookUCI[i] = hasBook; if(!nickName[0]) useNick = FALSE; if(useNick) ASSIGN(appData.pgnName[i], nickName); safeStrCpy(newEngineCommand, p, MSG_SIZ); - tryNr = 1; ReplaceEngine(cps, i); } @@ -9446,8 +9457,9 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h return; } if(strncmp(message, "uciok", 5) == 0) { // response to "uci" probe - appData.isUCI[0] = isUCI = 1; - ReplaceEngine(&first, 0); // retry install as UCI + int nr = (cps == &second); + appData.isUCI[nr] = isUCI = 1; + ReplaceEngine(cps, nr); // retry install as UCI return; } /* @@ -11390,6 +11402,7 @@ SaveEngineSettings (int n) { int len; char *p, *q, *s, buf[MSG_SIZ], *optionSettings; if(!currentEngine[n] || !currentEngine[n][0]) { DisplayMessage("saving failed: engine not from list", ""); return; } // no engine from list is loaded + if(*engineListFile) ParseSettingsFile(engineListFile, &engineListFile); // update engine list p = strstr(firstChessProgramNames, currentEngine[n]); if(!p) { DisplayMessage("saving failed: engine not found in list", ""); return; } // sanity check; engine could be deleted from list after loading optionSettings = ResendOptions(n ? &second : &first, FALSE); @@ -11409,6 +11422,7 @@ SaveEngineSettings (int n) s = malloc(len); snprintf(s, len, "%s%s%s", firstChessProgramNames, currentEngine[n], q); FREE(firstChessProgramNames); firstChessProgramNames = s; // new list + if(*engineListFile) SaveEngineList(); } // following implemented as macro to avoid type limitations