From ecd851c92b21c55ac41a91870deabeff6409fb96 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Tue, 3 May 2011 00:14:22 +0200 Subject: [PATCH] Calculate and display tourney result --- backend.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 50 insertions(+), 4 deletions(-) diff --git a/backend.c b/backend.c index f234beb..f2c0c98 100644 --- a/backend.c +++ b/backend.c @@ -232,6 +232,7 @@ int EngineOutputIsUp(); void InitDrawingSizes(int x, int y); void NextMatchGame P((void)); int NextTourneyGame P((int nr, int *swap)); +int Pairing P((int nr, int nPlayers, int *w, int *b, int *sync)); #ifdef WIN32 extern void ConsoleCreate(); @@ -7036,6 +7037,50 @@ void SendProgramStatsToFrontend( ChessProgramState * cps, ChessProgramStats * cp SetProgramStats( &stats ); } +#define MAXPLAYERS 500 + +char * +TourneyStandings(int display) +{ + int i, w, b, color, wScore, bScore, dummy, nr=0, nPlayers=0; + int score[MAXPLAYERS], ranking[MAXPLAYERS], points[MAXPLAYERS], games[MAXPLAYERS]; + char result, *p, *names[MAXPLAYERS]; + + names[0] = p = strdup(appData.participants); + while(p = strchr(p, '\n')) *p++ = NULLCHAR, names[++nPlayers] = p; // count participants + + for(i=0; i 0) nPlayers = appData.tourneyType; // in gauntlet, list only gauntlet engine(s) + for(w=0; w bScore) bScore = score[i], b = i; + ranking[w] = b; points[w] = bScore; score[b] = -2; + } + p = malloc(nPlayers*34+1); + for(w=0; w appData.matchGames) appData.tourneyFile[0] = 0; // tourney is done + 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) { @@ -9994,10 +10039,11 @@ 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(buf, 0, 0); else { + if(matchMode == TRUE) DisplayFatalError(ranking ? ranking : buf, 0, 0); else { matchMode = FALSE; appData.matchGames = matchGame = roundNr = 0; - DisplayNote(buf); + DisplayNote(ranking ? ranking : buf); } + if(ranking) free(ranking); } } -- 1.7.0.4