X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=93f79d37335d0f2314a0c286cd789f3ad34d66a5;hb=3845dc6e578a5e2ca1df4ed90a5db36f7529ac30;hp=2ed15a330019fa2655e6481555cd8020a184dbbe;hpb=00d7f7869e045cbed5037d39e1e56224692eb766;p=xboard.git diff --git a/backend.c b/backend.c index 2ed15a3..93f79d3 100644 --- a/backend.c +++ b/backend.c @@ -1410,7 +1410,7 @@ MatchEvent(int mode) // return; // } abortMatch = FALSE; - appData.matchGames = appData.defaultMatchGames; + if(mode == 2) appData.matchGames = appData.defaultMatchGames; /* Set up machine vs. machine match */ nextGame = 0; NextTourneyGame(-1, &dummy); // sets appData.matchGames if this is tourney, to make sure ReserveGame knows it @@ -9553,6 +9553,35 @@ TwoMachinesEventIfReady P((void)) TwoMachinesEvent(); } +char * +MakeName(char *template) +{ + time_t clock; + struct tm *tm; + static char buf[MSG_SIZ]; + char *p = buf; + int i; + + clock = time((time_t *)NULL); + tm = localtime(&clock); + + while(*p++ = *template++) if(p[-1] == '%') { + switch(*template++) { + case 0: *p = 0; return buf; + case 'Y': i = tm->tm_year+1900; break; + case 'y': i = tm->tm_year-100; break; + case 'M': i = tm->tm_mon+1; break; + case 'd': i = tm->tm_mday; break; + case 'h': i = tm->tm_hour; break; + case 'm': i = tm->tm_min; break; + case 's': i = tm->tm_sec; break; + default: i = 0; + } + snprintf(p-1, MSG_SIZ-10 - (p - buf), "%02d", i); p += strlen(p); + } + return buf; +} + int CountPlayers(char *p) { @@ -9596,17 +9625,21 @@ CreateTourney(char *name) { FILE *f; if(name[0] == NULLCHAR) { - DisplayError(_("You must supply a tournament file,\nfor storing the tourney progress"), 0); + if(appData.participants[0]) + DisplayError(_("You must supply a tournament file,\nfor storing the tourney progress"), 0); return 0; } - f = fopen(appData.tourneyFile, "r"); + f = fopen(name, "r"); if(f) { // file exists + ASSIGN(appData.tourneyFile, name); ParseArgsFromFile(f); // parse it } else { - if(CountPlayers(appData.participants) < appData.tourneyType + (!appData.tourneyType) + 1) { + if(!appData.participants[0]) return 0; // ignore tourney file if non-existing & no participants + if(CountPlayers(appData.participants) < (appData.tourneyType>0 ? appData.tourneyType+1 : 2)) { DisplayError(_("Not enough participants"), 0); return 0; } + ASSIGN(appData.tourneyFile, name); if((f = WriteTourneyFile("")) == NULL) return 0; } fclose(f); @@ -12658,6 +12691,12 @@ DisplayTwoMachinesTitle() { char buf[MSG_SIZ]; if (appData.matchGames > 0) { + if(appData.tourneyFile[0]) { + snprintf(buf, MSG_SIZ, "%s vs. %s (%d/%d%s)", + gameInfo.white, gameInfo.black, + nextGame+1, appData.matchGames+1, + appData.tourneyType>0 ? "gt" : appData.tourneyType<0 ? "sw" : "rr"); + } else if (first.twoMachinesColor[0] == 'w') { snprintf(buf, MSG_SIZ, "%s vs. %s (%d-%d-%d)", gameInfo.white, gameInfo.black,