X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=9204e1b042eaf78f73fa45654bfdd01f49abe0b4;hb=5bcaf4baecc46eda033c3b86f753a4d85d1bcfec;hp=61011654c7203bd87736073cdd661d6a089bd134;hpb=30d2dde0f9524475deb12e3a32bcee41fad6aeb6;p=xboard.git diff --git a/backend.c b/backend.c index 6101165..9204e1b 100644 --- a/backend.c +++ b/backend.c @@ -249,6 +249,7 @@ char *SendMoveToBookUser P((int nr, ChessProgramState *cps, int initial)); // [H void ics_update_width P((int new_width)); extern char installDir[MSG_SIZ]; VariantClass startVariant; /* [HGM] nicks: initial variant */ +Boolean abortMatch; extern int tinyLayout, smallLayout; ChessProgramStats programStats; @@ -1372,14 +1373,16 @@ MatchEvent(int mode) { // [HGM] moved out of InitBackend3, to make it callable when match starts through menu int dummy; if(matchMode) { // already in match mode: switch it off - appData.matchGames = matchGame; // kludge to let match terminate after next game. + abortMatch = TRUE; + appData.matchGames = appData.tourneyFile[0] ? nextGame: matchGame; // kludge to let match terminate after next game. ModeHighlight(); // kludgey way to remove checkmark... return; } - if(gameMode != BeginningOfGame) { - DisplayError(_("You can only start a match from the initial position."), 0); - return; - } +// if(gameMode != BeginningOfGame) { +// DisplayError(_("You can only start a match from the initial position."), 0); +// return; +// } + abortMatch = FALSE; appData.matchGames = appData.defaultMatchGames; /* Set up machine vs. machine match */ nextGame = 0; @@ -7082,7 +7085,7 @@ TourneyStandings(int display) case '-': bScore = 2; break; case '=': wScore = bScore = 1; break; case ' ': - case '*': return NULL; // tourney not finished + case '*': return strdup("busy"); // tourney not finished } score[w] += wScore; score[b] += bScore; @@ -10026,12 +10029,12 @@ GameEnds(result, resultDetails, whosays) } if(waitingForGame) resChar = ' '; // quit while waiting for round sync: unreserve already reserved game - if(appData.tourneyFile[0]){ // [HGM] we are in a tourney; update tourney file with game result + if(appData.tourneyFile[0] && !abortMatch){ // [HGM] we are in a tourney; update tourney file with game result ReserveGame(nextGame, resChar); // sets nextGame if(nextGame > appData.matchGames) appData.tourneyFile[0] = 0, ranking = TourneyStandings(3); // tourney is done } else roundNr = nextGame = matchGame + 1; // normal match, just increment; round equals matchGame - if (nextGame <= appData.matchGames) { + if (nextGame <= appData.matchGames && !abortMatch) { gameMode = nextGameMode; matchGame = nextGame; // this will be overruled in tourney mode! GetTimeMark(&pauseStart); // [HGM] matchpause: stipulate a pause @@ -10061,9 +10064,16 @@ GameEnds(result, resultDetails, whosays) ModeHighlight(); endingGame = 0; /* [HGM] crash */ if(popupRequested) { // [HGM] crash: this calls GameEnds recursively through ExitEvent! Make it a harmless tail recursion. - if(matchMode == TRUE) DisplayFatalError(ranking ? ranking : buf, 0, 0); else { - matchMode = FALSE; appData.matchGames = matchGame = roundNr = 0; - DisplayNote(ranking ? ranking : buf); + if(matchMode == TRUE) { // match through command line: exit with or without popup + if(ranking) { + if(strcmp(ranking, "busy")) DisplayFatalError(ranking, 0, 0); + else ExitEvent(0); + } else DisplayFatalError(buf, 0, 0); + } else { // match through menu; just stop, with or without popup + matchMode = FALSE; appData.matchGames = matchGame = roundNr = 0; + if(ranking){ + if(strcmp(ranking, "busy")) DisplayNote(ranking); + } else DisplayNote(buf); } if(ranking) free(ranking); }