if(f = fopen(appData.tourneyFile, "r")) {
ParseArgsFromFile(f); // make sure tourney parmeters re known
fclose(f);
+ appData.clockMode = TRUE;
+ SetGNUMode();
} else appData.tourneyFile[0] = NULLCHAR; // for now ignore bad tourney file
}
MatchEvent(TRUE);
if(cps == &pairing && sscanf(message, "%d-%d", &savedWhitePlayer, &savedBlackPlayer) == 2) {
// [HGM] pairing: Mega-hack! Pairing engine also uses this routine (so it could give other WB commands).
- if(savedWhitePlayer == 0 || savedBlackPlayer == 0) return;
+ if(savedWhitePlayer == 0 || savedBlackPlayer == 0) {
+ DisplayError(_("Invalid pairing from pairing engine"), 0);
+ return;
+ }
pairingReceived = 1;
NextMatchGame();
return; // Skim the pairing messages here.
*whitePlayer = curRound;
*blackPlayer = nPlayers - 1; // this is the 'bye' when nPlayer is odd
} else {
- *whitePlayer = curRound - pairingsPerRound + curPairing;
+ *whitePlayer = curRound - (nPlayers-1)/2 + curPairing;
if(*whitePlayer < 0) *whitePlayer += nPlayers-1+(nPlayers&1);
- *blackPlayer = curRound + pairingsPerRound - curPairing;
+ *blackPlayer = curRound + (nPlayers-1)/2 - curPairing;
if(*blackPlayer >= nPlayers-1+(nPlayers&1)) *blackPlayer -= nPlayers-1+(nPlayers&1);
}
} else if(appData.tourneyType > 0) {
InitTimeControls(); // TC might be altered from tourney file
nPlayers = CountPlayers(appData.participants); // count participants
- if(appData.tourneyType < 0 && appData.pairingEngine[0]) {
- if(nr>=0 && !pairingReceived) {
- char buf[1<<16];
- if(pairing.pr == NoProc) StartChessProgram(&pairing);
- snprintf(buf, 1<<16, "results %d %s\n", nPlayers, appData.results);
- SendToProgram(buf, &pairing);
- snprintf(buf, 1<<16, "pairing %d\n", nr+1);
- SendToProgram(buf, &pairing);
- return 0; // wait for pairing engine to answer (which causes NextTourneyGame to be called again...
- }
- pairingReceived = 0; // ... so we continue here
- syncInterval = nPlayers/2; *swapColors = 0;
- appData.matchGames = appData.tourneyCycles * syncInterval - 1;
- whitePlayer = savedWhitePlayer-1; blackPlayer = savedBlackPlayer-1;
- matchGame = 1; roundNr = nr / syncInterval + 1;
- } else
+ if(appData.tourneyType < 0) syncInterval = nPlayers/2; else
*swapColors = Pairing(nr<0 ? 0 : nr, nPlayers, &whitePlayer, &blackPlayer, &syncInterval);
if(syncInterval) {
waitingForGame = FALSE;
}
+ if(appData.tourneyType < 0) {
+ if(nr>=0 && !pairingReceived) {
+ char buf[1<<16];
+ if(pairing.pr == NoProc) {
+ if(!appData.pairingEngine[0]) {
+ DisplayFatalError(_("No pairing engine specified"), 0, 1);
+ return 0;
+ }
+ StartChessProgram(&pairing); // starts the pairing engine
+ }
+ snprintf(buf, 1<<16, "results %d %s\n", nPlayers, appData.results);
+ SendToProgram(buf, &pairing);
+ snprintf(buf, 1<<16, "pairing %d\n", nr+1);
+ SendToProgram(buf, &pairing);
+ return 0; // wait for pairing engine to answer (which causes NextTourneyGame to be called again...
+ }
+ pairingReceived = 0; // ... so we continue here
+ *swapColors = 0;
+ appData.matchGames = appData.tourneyCycles * syncInterval - 1;
+ whitePlayer = savedWhitePlayer-1; blackPlayer = savedBlackPlayer-1;
+ matchGame = 1; roundNr = nr / syncInterval + 1;
+ }
+
if(first.pr != NoProc) return 1; // engines already loaded
// redefine engines, engine dir, etc.
if(popupRequested) { // [HGM] crash: this calls GameEnds recursively through ExitEvent! Make it a harmless tail recursion.
if(matchMode == TRUE) { // match through command line: exit with or without popup
if(ranking) {
+ ToNrEvent(forwardMostMove);
if(strcmp(ranking, "busy")) DisplayFatalError(ranking, 0, 0);
else ExitEvent(0);
} else DisplayFatalError(buf, 0, 0);