X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=0a736e73ae49904cb66377106ce4b4ed3e0c70a4;hb=f4cc69edd466fda83f84629f40c086dd2a249616;hp=e6f48a450482513761d01c915681125f7efe1313;hpb=222c259543a8125e7391106f8a6c0f9d9720efc9;p=xboard.git diff --git a/backend.c b/backend.c index e6f48a4..0a736e7 100644 --- a/backend.c +++ b/backend.c @@ -873,6 +873,25 @@ static char resetOptions[] = "-firstOptions \"\" -firstNPS -1 -fn \"\""; void +FloatToFront(char **list, char *engineLine) +{ + char buf[MSG_SIZ], tidy[MSG_SIZ], *p = buf, *q, *r = buf; + int i=0; + if(appData.recentEngines <= 0) return; + TidyProgramName(engineLine, "localhost", tidy+1); + tidy[0] = buf[0] = '\n'; strcat(tidy, "\n"); + strncpy(buf+1, *list, MSG_SIZ-50); + if(p = strstr(buf, tidy)) { // tidy name appears in list + q = strchr(++p, '\n'); if(q == NULL) return; // malformed, don't touch + while(*p++ = *++q); // squeeze out + } + strcat(tidy, buf+1); // put list behind tidy name + p = tidy + 1; while(q = strchr(p, '\n')) i++, r = p, p = q + 1; // count entries in new list + if(i > appData.recentEngines) *r = NULLCHAR; // if maximum rached, strip off last + ASSIGN(*list, tidy+1); +} + +void Load (ChessProgramState *cps, int i) { char *p, *q, buf[MSG_SIZ], command[MSG_SIZ], buf2[MSG_SIZ]; @@ -884,6 +903,7 @@ Load (ChessProgramState *cps, int i) ParseArgsFromString(buf); SwapEngines(i); ReplaceEngine(cps, i); + FloatToFront(&appData.recentEngineList, engineLine); return; } p = engineName; @@ -926,6 +946,7 @@ Load (ChessProgramState *cps, int i) firstChessProgramNames = malloc(len = strlen(q) + strlen(buf) + 1); snprintf(firstChessProgramNames, len, "%s%s", q, buf); if(q) free(q); + FloatToFront(&appData.recentEngineList, buf); } ReplaceEngine(cps, i); } @@ -1473,6 +1494,7 @@ InitBackEnd3 P((void)) free(programVersion); programVersion = (char*) malloc(8 + strlen(PACKAGE_STRING) + strlen(first.tidy)); sprintf(programVersion, "%s + %s", PACKAGE_STRING, first.tidy); + FloatToFront(&appData.recentEngineList, appData.firstChessProgram); } if (appData.icsActive) { @@ -9904,11 +9926,11 @@ SwapEngines (int n) SWAP(engOptions, p) } -void -SetPlayer (int player) +int +SetPlayer (int player, char *p) { // [HGM] find the engine line of the partcipant given by number, and parse its options. int i; - char buf[MSG_SIZ], *engineName, *p = appData.participants; + char buf[MSG_SIZ], *engineName; for(i=0; i