X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=e6f48a450482513761d01c915681125f7efe1313;hb=62b9ce815b3e4ad57092f321c293895aeea4bf45;hp=3e9109993fbf57fa8644103675f36652af52cdb6;hpb=4e062d14429ed3a3a251c971690bade4c8cba946;p=xboard.git diff --git a/backend.c b/backend.c index 3e91099..e6f48a4 100644 --- a/backend.c +++ b/backend.c @@ -880,6 +880,7 @@ Load (ChessProgramState *cps, int i) snprintf(buf, MSG_SIZ, "-fcp %s", engineLine); SwapEngines(i); // kludge to parse -f* / -first* like it is -s* / -second* ParseArgsFromString(resetOptions); appData.fenOverride[0] = NULL; appData.pvSAN[0] = FALSE; + appData.firstProtocolVersion = PROTOVER; ParseArgsFromString(buf); SwapEngines(i); ReplaceEngine(cps, i); @@ -1396,9 +1397,13 @@ ReserveGame (int gameNr, char resChar) free(p); appData.results = q; if(nextGame <= appData.matchGames && resChar != ' ' && !abortMatch && (gameNr < 0 || nextGame / appData.defaultMatchGames != gameNr / appData.defaultMatchGames)) { + int round = appData.defaultMatchGames * appData.tourneyType; + if(gameNr < 0 || appData.tourneyType < 1 || // gauntlet engine can always stay loaded as first engine + appData.tourneyType > 1 && nextGame/round != gameNr/round) // in multi-gauntlet change only after round UnloadEngine(&first); // next game belongs to other pairing; UnloadEngine(&second); // already unload the engines, so TwoMachinesEvent will load new ones. } + if(appData.debugMode) fprintf(debugFP, "Reserved, next=%d, nr=%d, procs=(%x,%x)\n", nextGame, gameNr, first.pr, second.pr); } void @@ -2582,6 +2587,7 @@ int SeekGraphClick (ClickType click, int x, int y, int moving) { static int lastDown = 0, displayed = 0, lastSecond; + if(y < 0) return FALSE; if(!seekGraphUp) { // initiate cration of seek graph by requesting seek-ad list if(click == Release || moving) return FALSE; nrOfSeekAds = 0; @@ -2929,6 +2935,9 @@ read_from_ics (InputSourceRef isr, VOIDSTAR closure, char *data, int count, int OutputKibitz(suppressKibitz, parse); } else { char tmp[MSG_SIZ]; + if(gameMode == IcsObserving) // restore original ICS messages + snprintf(tmp, MSG_SIZ, "%s kibitzes: %s", star_match[0], parse); + else snprintf(tmp, MSG_SIZ, _("your opponent kibitzes: %s"), parse); SendToPlayer(tmp, strlen(tmp)); } @@ -3062,7 +3071,8 @@ read_from_ics (InputSourceRef isr, VOIDSTAR closure, char *data, int count, int if (appData.autoKibitz && started == STARTED_NONE && !appData.icsEngineAnalyze && // [HGM] [DM] ICS analyze (gameMode == IcsPlayingWhite || gameMode == IcsPlayingBlack || gameMode == IcsObserving)) { - if((looking_at(buf, &i, "* kibitzes: ") || looking_at(buf, &i, "* whispers: ")) && + if((looking_at(buf, &i, "\n* kibitzes: ") || looking_at(buf, &i, "\n* whispers: ") || + looking_at(buf, &i, "* kibitzes: ") || looking_at(buf, &i, "* whispers: ")) && (StrStr(star_match[0], gameInfo.white) == star_match[0] || StrStr(star_match[0], gameInfo.black) == star_match[0] )) { // kibitz of self or opponent suppressKibitz = TRUE; @@ -3524,7 +3534,7 @@ read_from_ics (InputSourceRef isr, VOIDSTAR closure, char *data, int count, int if (looking_at(buf, &i, "% ") || ((started == STARTED_MOVES || started == STARTED_MOVES_NOHIDE) && looking_at(buf, &i, "}*"))) { char *bookHit = NULL; // [HGM] book - if(ics_type == ICS_ICC && soughtPending) { // [HGM] seekgraph: on ICC sought-list has no termination line + if(soughtPending) { // [HGM] seekgraph: on ICC sought-list has no termination line soughtPending = FALSE; seekGraphUp = TRUE; DrawSeekGraph(); @@ -3601,8 +3611,8 @@ read_from_ics (InputSourceRef isr, VOIDSTAR closure, char *data, int count, int flipView = appData.flipView; DrawPosition(TRUE, boards[currentMove]); DisplayBothClocks(); - snprintf(str, MSG_SIZ, _("%s vs. %s"), - gameInfo.white, gameInfo.black); + snprintf(str, MSG_SIZ, "%s %s %s", + gameInfo.white, _("vs."), gameInfo.black); DisplayTitle(str); gameMode = IcsIdle; } else { @@ -4019,8 +4029,8 @@ read_from_ics (InputSourceRef isr, VOIDSTAR closure, char *data, int count, int snprintf(str, MSG_SIZ, "[%s-%s] %s-%s", wh, bh, gameInfo.white, gameInfo.black); } else { - snprintf(str, MSG_SIZ, _("%s [%s] vs. %s [%s]"), - gameInfo.white, white_holding, + snprintf(str, MSG_SIZ, "%s [%s] %s %s [%s]", + gameInfo.white, white_holding, _("vs."), gameInfo.black, black_holding); } if(!partnerUp) // [HGM] bughouse: when peeking at partner game we already know what he captured... @@ -4635,7 +4645,7 @@ ParseBoard12 (char *string) strcat(moveList[moveNum - 1], "\n"); if(gameInfo.holdingsWidth && !appData.disguise && gameInfo.variant != VariantSuper && gameInfo.variant != VariantGreat - && gameInfo.variant != VariantGrand) // inherit info that ICS does not give from previous board + && gameInfo.variant != VariantGrand&& gameInfo.variant != VariantSChess) // inherit info that ICS does not give from previous board for(k=0; k= nPlayers-1+(nPlayers&1)) *blackPlayer -= nPlayers-1+(nPlayers&1); } + } else if(appData.tourneyType > 1) { + *blackPlayer = curPairing; // in multi-gauntlet, assign gauntlet engines to second, so first an be kept loaded during round + *whitePlayer = curRound + appData.tourneyType; } else if(appData.tourneyType > 0) { *whitePlayer = curPairing; *blackPlayer = curRound + appData.tourneyType; @@ -10009,16 +10021,20 @@ NextTourneyGame (int nr, int *swapColors) matchGame = 1; roundNr = nr / syncInterval + 1; } - if(first.pr != NoProc || second.pr != NoProc) return 1; // engines already loaded + if(first.pr != NoProc && second.pr != NoProc) return 1; // engines already loaded // redefine engines, engine dir, etc. NamesToList(firstChessProgramNames, command, mnemonic); // get mnemonics of installed engines - SetPlayer(whitePlayer); // find white player amongst it, and parse its engine line - SwapEngines(1); - SetPlayer(blackPlayer); // find black player amongst it, and parse its engine line - SwapEngines(1); // and make that valid for second engine by swapping - InitEngine(&first, 0); // initialize ChessProgramStates based on new settings. - InitEngine(&second, 1); + if(first.pr == NoProc || nr < 0) { + SetPlayer(whitePlayer); // find white player amongst it, and parse its engine line + InitEngine(&first, 0); // initialize ChessProgramStates based on new settings. + } + if(second.pr == NoProc) { + SwapEngines(1); + SetPlayer(blackPlayer); // find black player amongst it, and parse its engine line + SwapEngines(1); // and make that valid for second engine by swapping + InitEngine(&second, 1); + } CommonEngineInit(); // after this TwoMachinesEvent will create correct engine processes UpdateLogos(FALSE); // leave display to ModeHiglight() return 1; @@ -11218,7 +11234,7 @@ PackGame (Board board) if(movePtr > dataSize) { if(appData.debugMode) fprintf(debugFP, "move-cache overflow, enlarge to %d MB\n", dataSize/128); dataSize *= 8; // increase size by factor 8 (512KB -> 4MB -> 32MB -> 256MB -> 2GB) - if(dataSize) newSpace = (Move*) calloc(8*dataSize + 1000, sizeof(Move)); + if(dataSize) newSpace = (Move*) calloc(dataSize + 1000, sizeof(Move)); if(newSpace) { int i; Move *p = moveDatabase, *q = newSpace; @@ -11529,7 +11545,7 @@ LoadGame (FILE *f, int gameNumber, char *title, int useList) yynewfile(f); if (lg && lg->gameInfo.white && lg->gameInfo.black) { - snprintf(buf, sizeof(buf), _("%s vs. %s"), lg->gameInfo.white, + snprintf(buf, sizeof(buf), "%s %s %s", lg->gameInfo.white, _("vs."), lg->gameInfo.black); DisplayTitle(buf); } else if (*title != NULLCHAR) { @@ -13122,7 +13138,7 @@ MachineWhiteEvent () pausing = FALSE; ModeHighlight(); SetGameInfo(); - snprintf(buf, MSG_SIZ, _("%s vs. %s"), gameInfo.white, gameInfo.black); + snprintf(buf, MSG_SIZ, "%s %s %s", gameInfo.white, _("vs."), gameInfo.black); DisplayTitle(buf); if (first.sendName) { snprintf(buf, MSG_SIZ, "name %s\n", gameInfo.black); @@ -13199,7 +13215,7 @@ MachineBlackEvent () pausing = FALSE; ModeHighlight(); SetGameInfo(); - snprintf(buf, MSG_SIZ, _("%s vs. %s"), gameInfo.white, gameInfo.black); + snprintf(buf, MSG_SIZ, "%s %s %s", gameInfo.white, _("vs."), gameInfo.black); DisplayTitle(buf); if (first.sendName) { snprintf(buf, MSG_SIZ, "name %s\n", gameInfo.white); @@ -13244,24 +13260,24 @@ DisplayTwoMachinesTitle () char buf[MSG_SIZ]; if (appData.matchGames > 0) { if(appData.tourneyFile[0]) { - snprintf(buf, MSG_SIZ, _("%s vs. %s (%d/%d%s)"), - gameInfo.white, gameInfo.black, + snprintf(buf, MSG_SIZ, "%s %s %s (%d/%d%s)", + gameInfo.white, _("vs."), gameInfo.black, nextGame+1, appData.matchGames+1, appData.tourneyType>0 ? "gt" : appData.tourneyType<0 ? "sw" : "rr"); } else if (first.twoMachinesColor[0] == 'w') { - snprintf(buf, MSG_SIZ, _("%s vs. %s (%d-%d-%d)"), - gameInfo.white, gameInfo.black, + snprintf(buf, MSG_SIZ, "%s %s %s (%d-%d-%d)", + gameInfo.white, _("vs."), gameInfo.black, first.matchWins, second.matchWins, matchGame - 1 - (first.matchWins + second.matchWins)); } else { - snprintf(buf, MSG_SIZ, _("%s vs. %s (%d-%d-%d)"), - gameInfo.white, gameInfo.black, + snprintf(buf, MSG_SIZ, "%s %s %s (%d-%d-%d)", + gameInfo.white, _("vs."), gameInfo.black, second.matchWins, first.matchWins, matchGame - 1 - (first.matchWins + second.matchWins)); } } else { - snprintf(buf, MSG_SIZ, _("%s vs. %s"), gameInfo.white, gameInfo.black); + snprintf(buf, MSG_SIZ, "%s %s %s", gameInfo.white, _("vs."), gameInfo.black); } DisplayTitle(buf); } @@ -14157,6 +14173,7 @@ ForwardInner (int target) if (gameMode == EditPosition) return; + seekGraphUp = FALSE; MarkTargetSquares(1); if (gameMode == PlayFromGameFile && !pausing) @@ -14263,6 +14280,7 @@ BackwardInner (int target) target, currentMove, forwardMostMove); if (gameMode == EditPosition) return; + seekGraphUp = FALSE; MarkTargetSquares(1); if (currentMove <= backwardMostMove) { ClearHighlights(); @@ -15366,7 +15384,7 @@ ParseFeatures (char *args, ChessProgramState *cps) continue; } if (BoolFeature(&p, "analyze", &cps->analysisSupport, cps)) continue; - if (StringFeature(&p, "myname", &cps->tidy, cps)) { + if (StringFeature(&p, "myname", cps->tidy, cps)) { if (gameMode == TwoMachinesPlay) { DisplayTwoMachinesTitle(); } else { @@ -15374,7 +15392,7 @@ ParseFeatures (char *args, ChessProgramState *cps) } continue; } - if (StringFeature(&p, "variants", &cps->variants, cps)) continue; + if (StringFeature(&p, "variants", cps->variants, cps)) continue; if (BoolFeature(&p, "san", &cps->useSAN, cps)) continue; if (BoolFeature(&p, "ping", &cps->usePing, cps)) continue; if (BoolFeature(&p, "playother", &cps->usePlayother, cps)) continue; @@ -15398,8 +15416,8 @@ ParseFeatures (char *args, ChessProgramState *cps) if (IntFeature(&p, "level", &cps->maxNrOfSessions, cps)) continue; if (BoolFeature(&p, "memory", &cps->memSize, cps)) continue; if (BoolFeature(&p, "smp", &cps->maxCores, cps)) continue; - if (StringFeature(&p, "egt", &cps->egtFormats, cps)) continue; - if (StringFeature(&p, "option", &(cps->option[cps->nrOptions].name), cps)) { + if (StringFeature(&p, "egt", cps->egtFormats, cps)) continue; + if (StringFeature(&p, "option", cps->option[cps->nrOptions].name, cps)) { if(!ParseOption(&(cps->option[cps->nrOptions++]), cps)) { // [HGM] options: add option feature snprintf(buf, MSG_SIZ, "rejected option %s\n", cps->option[--cps->nrOptions].name); SendToProgram(buf, cps);