From 3b22355af3b7755e6ada823c0ab587b75b7ed551 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Thu, 27 Sep 2012 18:02:24 +0200 Subject: [PATCH] Add check on validity of tourney participants Before allowing OK of the Tournament Options dialog, it is now checked whether all participants (which are given as nicknames) can be found in the list of installed engines, so that no problems will occurr with non-existing engines during the tourney (if typos crept in after hand- editing the list). --- backend.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/backend.c b/backend.c index b3f199a..242d064 100644 --- a/backend.c +++ b/backend.c @@ -10059,6 +10059,27 @@ Substitute (char *participants, int expunge) } int +CheckPlayers (char *participants) +{ + int i; + char buf[MSG_SIZ], *p; + NamesToList(firstChessProgramNames, command, mnemonic, "all"); + while(p = strchr(participants, '\n')) { + *p = NULLCHAR; + for(i=1; mnemonic[i]; i++) if(!strcmp(participants, mnemonic[i])) break; + if(!mnemonic[i]) { + snprintf(buf, MSG_SIZ, _("No engine %s is installed"), participants); + *p = '\n'; + DisplayError(buf, 0); + return 1; + } + *p = '\n'; + participants = p + 1; + } + return 0; +} + +int CreateTourney (char *name) { FILE *f; @@ -10080,6 +10101,7 @@ CreateTourney (char *name) DisplayError(_("Not enough participants"), 0); return 0; } + if(CheckPlayers(appData.participants)) return 0; ASSIGN(appData.tourneyFile, name); if(appData.tourneyType < 0) appData.defaultMatchGames = 1; // Swiss forces games/pairing = 1 if((f = WriteTourneyFile("", NULL)) == NULL) return 0; -- 1.7.0.4