X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=05e60b52569bdc73b90c59b9158fdc04d0086b60;hb=c4e2d19fab41744168e92d4f9e23176689f4bc20;hp=9ba38f390c3bb596df5f4ba8a811defb565589eb;hpb=5449be52c9120b4a78a433e954569ee6a62157ff;p=xboard.git diff --git a/backend.c b/backend.c index 9ba38f3..05e60b5 100644 --- a/backend.c +++ b/backend.c @@ -7661,7 +7661,10 @@ HandleMachineMove(message, cps) 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. @@ -9776,22 +9779,7 @@ NextTourneyGame(int nr, int *swapColors) 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) { @@ -9806,6 +9794,29 @@ NextTourneyGame(int nr, int *swapColors) 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. @@ -10249,6 +10260,7 @@ GameEnds(result, resultDetails, whosays) 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);