From: H.G. Muller Date: Thu, 27 Sep 2012 16:11:23 +0000 (+0200) Subject: Add options -fe, -se, -is to load installed engines/ics from list X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=b9ca4bb374bb650af227573139c30630d85d47da;p=xboard.git Add options -fe, -se, -is to load installed engines/ics from list The volatile string options -fe, -se ('first/second engine') load the first and second engine of the given nickname in the -firstChessProgramNames list, including all options that were installed with it (similar to when in WinBoard the that engine line had been selected through the Startup Dialog's combobox). The option -is is similarly used to retrieve the line for an ICS in the -icsNames list. --- diff --git a/args.h b/args.h index 1a16ed2..d9df08c 100644 --- a/args.h +++ b/args.h @@ -104,6 +104,9 @@ IcsTextMenuEntry icsTextMenuEntry[ICS_TEXT_MENU_SIZE]; int junk; Boolean singleList; char *homeDir; +char *firstEngineLine; +char *secondEngineLine; +char *icsNick; void EnsureOnScreen(int *x, int *y, int minX, int minY); char StringGet(void *getClosure); @@ -172,6 +175,8 @@ ArgDescriptor argDescriptors[] = { { "secondChessProgram", ArgFilename, (void *) &appData.secondChessProgram, FALSE, (ArgIniType) SECOND_CHESS_PROGRAM }, { "scp", ArgFilename, (void *) &appData.secondChessProgram, FALSE, INVALID }, + { "fe", ArgString, (void *) &firstEngineLine, FALSE, "" }, + { "se", ArgString, (void *) &secondEngineLine, FALSE, "" }, { "firstPlaysBlack", ArgBoolean, (void *) &appData.firstPlaysBlack, FALSE, FALSE }, { "fb", ArgTrue, (void *) &appData.firstPlaysBlack, FALSE, FALSE }, { "xfb", ArgFalse, (void *) &appData.firstPlaysBlack, FALSE, INVALID }, @@ -230,6 +235,7 @@ ArgDescriptor argDescriptors[] = { { "ics", ArgTrue, (void *) &appData.icsActive, FALSE, (ArgIniType) FALSE }, { "xics", ArgFalse, (void *) &appData.icsActive, FALSE, INVALID }, { "-ics", ArgFalse, (void *) &appData.icsActive, FALSE, INVALID }, + { "is", ArgString, (void *) &icsNick, FALSE, "" }, { "internetChessServerHost", ArgString, (void *) &appData.icsHost, FALSE, (ArgIniType) "" }, { "icshost", ArgString, (void *) &appData.icsHost, FALSE, INVALID }, { "internetChessServerPort", ArgString, (void *) &appData.icsPort, FALSE, (ArgIniType) ICS_PORT }, @@ -1280,6 +1286,8 @@ InitAppData(char *lpCmdLine) if(appData.viewer && appData.viewerOptions[0]) ParseArgsFromString(appData.viewerOptions); if(appData.tourney && appData.tourneyOptions[0]) ParseArgsFromString(appData.tourneyOptions); + chessProgram = GetEngineLine(firstEngineLine, 0) || GetEngineLine(secondEngineLine, 1); + appData.icsActive = GetEngineLine(icsNick, 10); /* [HGM] make sure board size is acceptable */ if(appData.NrFiles > BOARD_FILES || diff --git a/backend.c b/backend.c index 242d064..8837d97 100644 --- a/backend.c +++ b/backend.c @@ -10180,6 +10180,27 @@ SwapEngines (int n) } int +GetEngineLine (char *s, int n) +{ + int i; + char buf[MSG_SIZ]; + extern char *icsNames; + if(!s || !*s) return 0; + NamesToList(n == 10 ? icsNames : firstChessProgramNames, command, mnemonic, "all"); + for(i=1; mnemonic[i]; i++) if(!strcmp(s, mnemonic[i])) break; + if(!mnemonic[i]) return 0; + snprintf(buf, MSG_SIZ, "-%s %s", n == 10 ? "icshost" : "fcp", command[i]); + if(n == 1) SwapEngines(n); + ParseArgsFromString(buf); + if(n == 1) SwapEngines(n); + if(n == 0 && *appData.secondChessProgram == NULLCHAR) { + SwapEngines(1); // set second same as first if not yet set (to suppress WB startup dialog) + ParseArgsFromString(buf); + } + return 1; +} + +int SetPlayer (int player, char *p) { // [HGM] find the engine line of the partcipant given by number, and parse its options. int i; diff --git a/backend.h b/backend.h index 94031d2..d21379f 100644 --- a/backend.h +++ b/backend.h @@ -244,6 +244,7 @@ Boolean ParseFEN P((Board board, int *blackPlaysFirst, char *fen)); void ApplyMove P((int fromX, int fromY, int toX, int toY, int promoChar, Board board)); void PackMove P((int fromX, int fromY, int toX, int toY, ChessSquare promoPiece)); void ics_printf P((char *format, ...)); +int GetEngineLine P((char *nick, int engine)); char *StrStr P((char *string, char *match)); char *StrCaseStr P((char *string, char *match));