X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=b8cfa92f2ceacc4fbf810305c9e9b49ecc4c22ef;hb=fa76217dec3666d46e537483a60ea7b9e9568e33;hp=54967970583092393999eca7cb0c37f304577eea;hpb=762e18baef5f815cc46019ba3e082bd5ec1980f6;p=xboard.git diff --git a/backend.c b/backend.c index 5496797..b8cfa92 100644 --- a/backend.c +++ b/backend.c @@ -55,7 +55,7 @@ #else -#define DoSleep( n ) +#define DoSleep( n ) if( (n) >= 0) sleep(n) #endif @@ -120,6 +120,16 @@ extern int gettimeofday(struct timeval *, struct timezone *); # include "zippy.h" #endif #include "backendz.h" +#include "gettext.h" + +#ifdef ENABLE_NLS +# define _(s) gettext (s) +# define N_(s) gettext_noop (s) +#else +# define _(s) (s) +# define N_(s) s +#endif + /* A point in time */ typedef struct { @@ -127,23 +137,6 @@ typedef struct { int ms; /* Assuming this is >= 16 bits */ } TimeMark; -/* Search stats from chessprogram */ -typedef struct { - char movelist[2*MSG_SIZ]; /* Last PV we were sent */ - int depth; /* Current search depth */ - int nr_moves; /* Total nr of root moves */ - int moves_left; /* Moves remaining to be searched */ - char move_name[MOVE_LEN]; /* Current move being searched, if provided */ - unsigned long nodes; /* # of nodes searched */ - int time; /* Search time (centiseconds) */ - int score; /* Score (centipawns) */ - int got_only_move; /* If last msg was "(only move)" */ - int got_fail; /* 0 - nothing, 1 - got "--", 2 - got "++" */ - int ok_to_send; /* handshaking between send & recv */ - int line_is_book; /* 1 if movelist is book moves */ - int seen_stat; /* 1 if we've seen the stat01: line */ -} ChessProgramStats; - int establish P((void)); void read_from_player P((InputSourceRef isr, VOIDSTAR closure, char *buf, int count, int error)); @@ -215,7 +208,14 @@ void ParseFeatures P((char* args, ChessProgramState *cps)); void InitBackEnd3 P((void)); void FeatureDone P((ChessProgramState* cps, int val)); void InitChessProgram P((ChessProgramState *cps, int setup)); + +#ifdef WIN32 + extern void ConsoleCreate(); +#endif + ChessProgramState *WhitePlayer(); +void InsertIntoMemo P((int which, char *text)); // [HGM] kibitz: in engineo.c +int VerifyDisplayMode P(()); char *GetInfoFromComment( int, char * ); // [HGM] PV time: returns stripped comment void InitEngineUCI( const char * iniDir, ChessProgramState * cps ); // [HGM] moved here from winboard.c @@ -224,7 +224,7 @@ char *SendMoveToBookUser P((int nr, ChessProgramState *cps, int initial)); // [H extern char installDir[MSG_SIZ]; extern int tinyLayout, smallLayout; -static ChessProgramStats programStats; +ChessProgramStats programStats; static int exiting = 0; /* [HGM] moved to top */ static int setboardSpoiledMachineBlack = 0, errorExitFlag = 0; extern int startedFromPositionFile; @@ -233,6 +233,7 @@ char endingGame = 0; /* [HGM] crash: flag to prevent recursion of GameEnds() int whiteNPS, blackNPS; /* [HGM] nps: for easily making clocks aware of NPS */ VariantClass currentlyInitializedVariant; /* [HGM] variantswitch */ int lastIndex = 0; /* [HGM] autoinc: last game/position used in match mode */ +int opponentKibitzes; /* States for ics_getting_history */ #define H_FALSE 0 @@ -304,6 +305,26 @@ static char * safeStrCat( char * dst, const char * src, size_t count ) return dst; } +/* Some compiler can't cast u64 to double + * This function do the job for us: + + * We use the highest bit for cast, this only + * works if the highest bit is not + * in use (This should not happen) + * + * We used this for all compiler + */ +double +u64ToDouble(u64 value) +{ + double r; + u64 tmp = value & u64Const(0x7fffffffffffffff); + r = (double)(s64)tmp; + if (value & u64Const(0x8000000000000000)) + r += 9.2233720368547758080e18; /* 2^63 */ + return r; +} + /* Fake up flags for now, as we aren't keeping track of castling availability yet. [HGM] Change of logic: the flag now only indicates the type of castlings allowed by the rule of the game. @@ -318,9 +339,9 @@ PosFlags(index) if ((index % 2) == 0) flags |= F_WHITE_ON_MOVE; switch (gameInfo.variant) { case VariantSuicide: - case VariantGiveaway: - flags |= F_IGNORE_CHECK; flags &= ~F_ALL_CASTLE_OK; + case VariantGiveaway: // [HGM] moved this case label one down: seems Giveaway does have castling on ICC! + flags |= F_IGNORE_CHECK; break; case VariantAtomic: flags |= F_IGNORE_CHECK | F_ATOMIC_CAPTURE; @@ -369,12 +390,8 @@ int gotPremove = 0; Boolean alarmSounded; /* end premove variables */ -#define ICS_GENERIC 0 -#define ICS_ICC 1 -#define ICS_FICS 2 -#define ICS_CHESSNET 3 /* not really supported */ -int ics_type = ICS_GENERIC; char *ics_prefix = "$"; +int ics_type = ICS_GENERIC; int currentMove = 0, forwardMostMove = 0, backwardMostMove = 0; int pauseExamForwardMostMove = 0; @@ -495,6 +512,13 @@ ChessSquare CapablancaArray[2][BOARD_SIZE] = { BlackKing, BlackBishop, BlackMarshall, BlackKnight, BlackRook } }; +ChessSquare GreatArray[2][BOARD_SIZE] = { + { WhiteDragon, WhiteKnight, WhiteAlfil, WhiteGrasshopper, WhiteKing, + WhiteSilver, WhiteCardinal, WhiteAlfil, WhiteKnight, WhiteDragon }, + { BlackDragon, BlackKnight, BlackAlfil, BlackGrasshopper, BlackKing, + BlackSilver, BlackCardinal, BlackAlfil, BlackKnight, BlackDragon }, +}; + ChessSquare JanusArray[2][BOARD_SIZE] = { { WhiteRook, WhiteAngel, WhiteKnight, WhiteBishop, WhiteKing, WhiteQueen, WhiteBishop, WhiteKnight, WhiteAngel, WhiteRook }, @@ -528,6 +552,7 @@ ChessSquare FalconArray[2][BOARD_SIZE] = { #define XiangqiPosition FIDEArray #define CapablancaArray FIDEArray #define GothicArray FIDEArray +#define GreatArray FIDEArray #endif // !(BOARD_SIZE>=10) #if (BOARD_SIZE>=12) @@ -632,7 +657,7 @@ InitBackEnd1() if (!ParseTimeControl(appData.timeControl, appData.timeIncrement, appData.movesPerSession)) { char buf[MSG_SIZ]; - sprintf(buf, "bad timeControl option %s", appData.timeControl); + sprintf(buf, _("bad timeControl option %s"), appData.timeControl); DisplayFatalError(buf, 0, 2); } @@ -647,7 +672,7 @@ InitBackEnd1() searchTime = min * 60 + sec; } else { char buf[MSG_SIZ]; - sprintf(buf, "bad searchTime option %s", appData.searchTime); + sprintf(buf, _("bad searchTime option %s"), appData.searchTime); DisplayFatalError(buf, 0, 2); } } @@ -744,7 +769,7 @@ InitBackEnd1() if (appData.firstProtocolVersion > PROTOVER || appData.firstProtocolVersion < 1) { char buf[MSG_SIZ]; - sprintf(buf, "protocol version %d not supported", + sprintf(buf, _("protocol version %d not supported"), appData.firstProtocolVersion); DisplayFatalError(buf, 0, 2); } else { @@ -754,7 +779,7 @@ InitBackEnd1() if (appData.secondProtocolVersion > PROTOVER || appData.secondProtocolVersion < 1) { char buf[MSG_SIZ]; - sprintf(buf, "protocol version %d not supported", + sprintf(buf, _("protocol version %d not supported"), appData.secondProtocolVersion); DisplayFatalError(buf, 0, 2); } else { @@ -812,7 +837,7 @@ InitBackEnd1() case VariantBughouse: /* need four players and two boards */ case VariantKriegspiel: /* need to hide pieces and move details */ /* case VariantFischeRandom: (Fabien: moved below) */ - sprintf(buf, "Variant %s supported only in ICS mode", appData.variant); + sprintf(buf, _("Variant %s supported only in ICS mode"), appData.variant); DisplayFatalError(buf, 0, 2); return; @@ -827,7 +852,7 @@ InitBackEnd1() case Variant35: case Variant36: default: - sprintf(buf, "Unknown variant name %s", appData.variant); + sprintf(buf, _("Unknown variant name %s"), appData.variant); DisplayFatalError(buf, 0, 2); return; @@ -860,6 +885,7 @@ InitBackEnd1() case VariantCapaRandom: /* should work */ case VariantJanus: /* should work */ case VariantSuper: /* experimental */ + case VariantGreat: /* experimental, requires legality testing to be off */ break; } } @@ -1054,7 +1080,7 @@ InitBackEnd2() } else { /* kludge: allow timeout for initial "feature" commands */ FreezeUI(); - DisplayMessage("", "Starting chess program"); + DisplayMessage("", _("Starting chess program")); ScheduleDelayedEvent(InitBackEnd3, FEATURE_TIMEOUT); } } @@ -1068,14 +1094,19 @@ InitBackEnd3 P((void)) InitChessProgram(&first, startedFromSetupPosition); + if (appData.icsActive) { +#ifdef WIN32 + /* [DM] Make a console window if needed [HGM] merged ifs */ + ConsoleCreate(); +#endif err = establish(); if (err != 0) { if (*appData.icsCommPort != NULLCHAR) { - sprintf(buf, "Could not open comm port %s", + sprintf(buf, _("Could not open comm port %s"), appData.icsCommPort); } else { - sprintf(buf, "Could not connect to host %s, port %s", + sprintf(buf, _("Could not connect to host %s, port %s"), appData.icsHost, appData.icsPort); } DisplayFatalError(buf, err, 1); @@ -1120,7 +1151,7 @@ InitBackEnd3 P((void)) } else if (StrCaseCmp(appData.initialMode, "Training") == 0) { initialMode = Training; } else { - sprintf(buf, "Unknown initialMode %s", appData.initialMode); + sprintf(buf, _("Unknown initialMode %s"), appData.initialMode); DisplayFatalError(buf, 0, 2); return; } @@ -1128,7 +1159,7 @@ InitBackEnd3 P((void)) if (appData.matchMode) { /* Set up machine vs. machine match */ if (appData.noChessProgram) { - DisplayFatalError("Can't have a match with no chess programs", + DisplayFatalError(_("Can't have a match with no chess programs"), 0, 2); return; } @@ -1140,7 +1171,7 @@ InitBackEnd3 P((void)) if (!LoadGameFromFile(appData.loadGameFile, index, appData.loadGameFile, FALSE)) { - DisplayFatalError("Bad game file", 0, 1); + DisplayFatalError(_("Bad game file"), 0, 1); return; } } else if (*appData.loadPositionFile != NULLCHAR) { @@ -1149,7 +1180,7 @@ InitBackEnd3 P((void)) if (!LoadPositionFromFile(appData.loadPositionFile, index, appData.loadPositionFile)) { - DisplayFatalError("Bad position file", 0, 1); + DisplayFatalError(_("Bad position file"), 0, 1); return; } } @@ -1161,7 +1192,7 @@ InitBackEnd3 P((void)) /* Set up other modes */ if (initialMode == AnalyzeFile) { if (*appData.loadGameFile == NULLCHAR) { - DisplayFatalError("AnalyzeFile mode requires a game file", 0, 1); + DisplayFatalError(_("AnalyzeFile mode requires a game file"), 0, 1); return; } } @@ -1189,11 +1220,11 @@ InitBackEnd3 P((void)) } if (initialMode == AnalyzeMode) { if (appData.noChessProgram) { - DisplayFatalError("Analysis mode requires a chess engine", 0, 2); + DisplayFatalError(_("Analysis mode requires a chess engine"), 0, 2); return; } if (appData.icsActive) { - DisplayFatalError("Analysis mode does not work with ICS mode",0,2); + DisplayFatalError(_("Analysis mode does not work with ICS mode"),0,2); return; } AnalyzeModeEvent(); @@ -1204,36 +1235,36 @@ InitBackEnd3 P((void)) AnalysisPeriodicEvent(1); } else if (initialMode == MachinePlaysWhite) { if (appData.noChessProgram) { - DisplayFatalError("MachineWhite mode requires a chess engine", + DisplayFatalError(_("MachineWhite mode requires a chess engine"), 0, 2); return; } if (appData.icsActive) { - DisplayFatalError("MachineWhite mode does not work with ICS mode", + DisplayFatalError(_("MachineWhite mode does not work with ICS mode"), 0, 2); return; } MachineWhiteEvent(); } else if (initialMode == MachinePlaysBlack) { if (appData.noChessProgram) { - DisplayFatalError("MachineBlack mode requires a chess engine", + DisplayFatalError(_("MachineBlack mode requires a chess engine"), 0, 2); return; } if (appData.icsActive) { - DisplayFatalError("MachineBlack mode does not work with ICS mode", + DisplayFatalError(_("MachineBlack mode does not work with ICS mode"), 0, 2); return; } MachineBlackEvent(); } else if (initialMode == TwoMachinesPlay) { if (appData.noChessProgram) { - DisplayFatalError("TwoMachines mode requires a chess engine", + DisplayFatalError(_("TwoMachines mode requires a chess engine"), 0, 2); return; } if (appData.icsActive) { - DisplayFatalError("TwoMachines mode does not work with ICS mode", + DisplayFatalError(_("TwoMachines mode does not work with ICS mode"), 0, 2); return; } @@ -1244,7 +1275,7 @@ InitBackEnd3 P((void)) EditPositionEvent(); } else if (initialMode == Training) { if (*appData.loadGameFile == NULLCHAR) { - DisplayFatalError("Training mode requires a game file", 0, 2); + DisplayFatalError(_("Training mode requires a game file"), 0, 2); return; } TrainingEvent(); @@ -1392,14 +1423,14 @@ read_from_player(isr, closure, message, count, error) gotEof = 0; outCount = OutputMaybeTelnet(icsPR, message, count, &outError); if (outCount < count) { - DisplayFatalError("Error writing to ICS", outError, 1); + DisplayFatalError(_("Error writing to ICS"), outError, 1); } } else if (count < 0) { RemoveInputSource(isr); - DisplayFatalError("Error reading from keyboard", error, 1); + DisplayFatalError(_("Error reading from keyboard"), error, 1); } else if (gotEof++ > 0) { RemoveInputSource(isr); - DisplayFatalError("Got end of file from keyboard", 0, 0); + DisplayFatalError(_("Got end of file from keyboard"), 0, 0); } } @@ -1414,7 +1445,7 @@ SendToICS(s) count = strlen(s); outCount = OutputMaybeTelnet(icsPR, s, count, &outError); if (outCount < count) { - DisplayFatalError("Error writing to ICS", outError, 1); + DisplayFatalError(_("Error writing to ICS"), outError, 1); } } @@ -1439,7 +1470,7 @@ SendToICSDelayed(s,msdelay) outCount = OutputToProcessDelayed(icsPR, s, count, &outError, msdelay); if (outCount < count) { - DisplayFatalError("Error writing to ICS", outError, 1); + DisplayFatalError(_("Error writing to ICS"), outError, 1); } } @@ -1531,7 +1562,8 @@ StringToVariant(e) if (!found) { if ((StrCaseStr(e, "fischer") && StrCaseStr(e, "random")) - || StrCaseStr(e, "wild/fr")) { + || StrCaseStr(e, "wild/fr") + || StrCaseStr(e, "frc") || StrCaseStr(e, "960")) { v = VariantFischeRandom; } else if ((i = 4, p = StrCaseStr(e, "wild")) || (i = 1, p = StrCaseStr(e, "w"))) { @@ -1673,13 +1705,16 @@ StringToVariant(e) case 49: v = VariantSuper; break; + case 50: + v = VariantGreat; + break; case -1: /* Found "wild" or "w" in the string but no number; must assume it's normal chess. */ v = VariantNormal; break; default: - sprintf(buf, "Unknown wild type %d", wnum); + sprintf(buf, _("Unknown wild type %d"), wnum); DisplayError(buf, 0); v = VariantUnknown; break; @@ -1687,7 +1722,7 @@ StringToVariant(e) } } if (appData.debugMode) { - fprintf(debugFP, "recognized '%s' (%d) as variant %s\n", + fprintf(debugFP, _("recognized '%s' (%d) as variant %s\n"), e, wnum, VariantName(v)); } return v; @@ -1752,7 +1787,7 @@ SendToPlayer(data, length) int error, outCount; outCount = OutputToProcess(NoProc, data, length, &error); if (outCount < length) { - DisplayFatalError("Error writing to display", error, 1); + DisplayFatalError(_("Error writing to display"), error, 1); } } @@ -1838,7 +1873,7 @@ TelnetRequest(ddww, option) msg[2] = option; outCount = OutputToProcess(icsPR, (char *)msg, 3, &outError); if (outCount < 3) { - DisplayFatalError("Error writing to ICS", outError, 1); + DisplayFatalError(_("Error writing to ICS"), outError, 1); } } @@ -1889,7 +1924,7 @@ CopyHoldings(Board board, char *holdings, ChessSquare lowestPiece) j = PieceToNumber(piece); if(j >= gameInfo.holdingsSize) continue; /* ignore pieces that do not fit */ if(j < 0) continue; /* should not happen */ - piece = (ChessSquare) ( j + (int)lowestPiece ); + piece = (ChessSquare) ( (int)piece + (int)lowestPiece ); board[holdingsStartRow+j*direction][holdingsColumn] = piece; board[holdingsStartRow+j*direction][countsColumn]++; } @@ -1996,6 +2031,7 @@ static int player2Rating = -1; /*----------------------------*/ ColorClass curColor = ColorNormal; +int suppressKibitz = 0; void read_from_ics(isr, closure, data, count, error) @@ -2027,9 +2063,9 @@ read_from_ics(isr, closure, data, count, error) int buf_len; int next_out; int tkind; + int backup; /* [DM] For zippy color lines */ char *p; -#ifdef WIN32 if (appData.debugMode) { if (!error) { fprintf(debugFP, " MSG_SIZ - 30) // defuse unreasonably long input + { parse_pos = MSG_SIZ-30; parse[parse_pos - 1] = '\n'; } + parse[parse_pos] = NULLCHAR; + // try to be smart: if it does not look like search info, it should go to + // ICS interaction window after all, not to engine-output window. + for(i=0; i= '0' && parse[i] <= '9'); + nrAlph += (parse[i] >= 'a' && parse[i] <= 'z'); + nrAlph += (parse[i] >= 'A' && parse[i] <= 'Z'); + } + if(nrAlph < 9*nrDigit) { // if more than 10% digit we assume search info + OutputKibitz(suppressKibitz, parse); + } else { + char tmp[MSG_SIZ]; + sprintf(tmp, _("your opponent kibitzes: %s"), parse); + SendToPlayer(tmp, strlen(tmp)); + } + } started = STARTED_NONE; } else { /* Don't match patterns against characters in chatter */ @@ -2289,17 +2345,53 @@ read_from_ics(isr, closure, data, count, error) } oldi = i; + // [HGM] kibitz: try to recognize opponent engine-score kibitzes, to divert them to engine-output window + if (appData.autoKibitz && started == STARTED_NONE && + !appData.icsEngineAnalyze && // [HGM] [DM] ICS analyze + (gameMode == IcsPlayingWhite || gameMode == IcsPlayingBlack || gameMode == IcsObserving)) { + if(looking_at(buf, &i, "* kibitzes: ") && + (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; + if((StrStr(star_match[0], gameInfo.white) == star_match[0]) + && (gameMode == IcsPlayingWhite) || + (StrStr(star_match[0], gameInfo.black) == star_match[0]) + && (gameMode == IcsPlayingBlack) ) // opponent kibitz + started = STARTED_CHATTER; // own kibitz we simply discard + else { + started = STARTED_COMMENT; // make sure it will be collected in parse[] + parse_pos = 0; parse[0] = NULLCHAR; + savingComment = TRUE; + suppressKibitz = gameMode != IcsObserving ? 2 : + (StrStr(star_match[0], gameInfo.white) == NULL) + 1; + } + continue; + } else + if(looking_at(buf, &i, "kibitzed to")) { // suppress the acknowledgements of our own autoKibitz + started = STARTED_CHATTER; + suppressKibitz = TRUE; + } + } // [HGM] kibitz: end of patch + if (appData.zippyTalk || appData.zippyPlay) { + /* [DM] Backup address for color zippy lines */ + backup = i; #if ZIPPY - if (ZippyControl(buf, &i) || - ZippyConverse(buf, &i) || - (appData.zippyPlay && ZippyMatch(buf, &i))) { - loggedOn = TRUE; - continue; + #ifdef WIN32 + if (loggedOn == TRUE) + if (ZippyControl(buf, &backup) || ZippyConverse(buf, &backup) || + (appData.zippyPlay && ZippyMatch(buf, &backup))); + #else + if (ZippyControl(buf, &i) || + ZippyConverse(buf, &i) || + (appData.zippyPlay && ZippyMatch(buf, &i))) { + loggedOn = TRUE; + if (!appData.colorize) continue; } + #endif #endif - } else { - if (/* Don't color "message" or "messages" output */ + } // [DM] 'else { ' deleted + if (/* Don't color "message" or "messages" output */ (tkind = 5, looking_at(buf, &i, "*. * (*:*): ")) || looking_at(buf, &i, "*. * at *:*: ") || looking_at(buf, &i, "--* (*:*): ") || @@ -2454,7 +2546,6 @@ read_from_ics(isr, closure, data, count, error) curColor = ColorSeek; } continue; - } } if (looking_at(buf, &i, "\\ ")) { @@ -2565,7 +2656,7 @@ read_from_ics(isr, closure, data, count, error) case H_GOT_UNWANTED_HEADER: case H_GETTING_MOVES: /* Should not happen */ - DisplayError("Error gathering move list: two headers", 0); + DisplayError(_("Error gathering move list: two headers"), 0); ics_getting_history = H_FALSE; break; } @@ -2579,7 +2670,7 @@ read_from_ics(isr, closure, data, count, error) gameInfo.whiteRating = string_to_rating(star_match[1]); gameInfo.blackRating = string_to_rating(star_match[3]); if (appData.debugMode) - fprintf(debugFP, "Ratings from header: W %d, B %d\n", + fprintf(debugFP, _("Ratings from header: W %d, B %d\n"), gameInfo.whiteRating, gameInfo.blackRating); } continue; @@ -2612,7 +2703,7 @@ read_from_ics(isr, closure, data, count, error) break; case H_GETTING_MOVES: /* Should not happen */ - DisplayError("Error gathering move list: nested", 0); + DisplayError(_("Error gathering move list: nested"), 0); ics_getting_history = H_FALSE; break; case H_GOT_REQ_HEADER: @@ -2637,7 +2728,7 @@ read_from_ics(isr, closure, data, count, error) if (looking_at(buf, &i, "% ") || ((started == STARTED_MOVES || started == STARTED_MOVES_NOHIDE) - && looking_at(buf, &i, "}*"))) { + && looking_at(buf, &i, "}*"))) { char *bookHit = NULL; // [HGM] book savingComment = FALSE; switch (started) { case STARTED_MOVES: @@ -2656,11 +2747,18 @@ read_from_ics(isr, closure, data, count, error) } SendTimeRemaining(&first, TRUE); } +#if 0 if (first.useColors) { SendToProgram("white\ngo\n", &first); } else { SendToProgram("go\n", &first); } +#else + if (first.useColors) { + SendToProgram("white\n", &first); // [HGM] book: made sending of "go\n" book dependent + } + bookHit = SendMoveToBookUser(forwardMostMove-1, &first, TRUE); // [HGM] book: probe book for initial pos +#endif first.maybeThinking = TRUE; } else { if (first.usePlayother) { @@ -2681,11 +2779,18 @@ read_from_ics(isr, closure, data, count, error) } SendTimeRemaining(&first, FALSE); } +#if 0 if (first.useColors) { SendToProgram("black\ngo\n", &first); } else { SendToProgram("go\n", &first); } +#else + if (first.useColors) { + SendToProgram("black\n", &first); + } + bookHit = SendMoveToBookUser(forwardMostMove-1, &first, TRUE); +#endif first.maybeThinking = TRUE; } else { if (first.usePlayother) { @@ -2738,6 +2843,17 @@ read_from_ics(isr, closure, data, count, error) default: break; } + if(bookHit) { // [HGM] book: simulate book reply + static char bookMove[MSG_SIZ]; // a bit generous? + + programStats.depth = programStats.nodes = programStats.time = + programStats.score = programStats.got_only_move = 0; + sprintf(programStats.movelist, "%s (xbook)", bookHit); + + strcpy(bookMove, "move "); + strcat(bookMove, bookHit); + HandleMachineMove(bookMove, &first); + } continue; } @@ -2824,7 +2940,7 @@ read_from_ics(isr, closure, data, count, error) if (forwardMostMove > backwardMostMove) { currentMove = --forwardMostMove; DisplayMove(currentMove - 1); /* before DMError */ - DisplayMoveError("Illegal move (rejected by ICS)"); + DisplayMoveError(_("Illegal move (rejected by ICS)")); DrawPosition(FALSE, boards[currentMove]); SwitchClocks(); DisplayBothClocks(); @@ -2979,6 +3095,11 @@ read_from_ics(isr, closure, data, count, error) if (gameMode == IcsObserving && atoi(star_match[0]) == ics_gamenum) { + /* icsEngineAnalyze */ + if (appData.icsEngineAnalyze) { + ExitAnalyzeMode(); + ModeHighlight(); + } StopClocks(); gameMode = IcsIdle; ics_gamenum = -1; @@ -3120,11 +3241,12 @@ read_from_ics(isr, closure, data, count, error) i++; /* skip unparsed character and loop back */ } - if (started != STARTED_MOVES && started != STARTED_BOARD && + if (started != STARTED_MOVES && started != STARTED_BOARD && !suppressKibitz && // [HGM] kibitz suppress printing in ICS interaction window started != STARTED_HOLDINGS && i > next_out) { SendToPlayer(&buf[next_out], i - next_out); next_out = i; } + suppressKibitz = FALSE; // [HGM] kibitz: has done its duty in if-statement above leftover_len = buf_len - leftover_start; /* if buffer ends with something we couldn't parse, @@ -3132,9 +3254,9 @@ read_from_ics(isr, closure, data, count, error) } else if (count == 0) { RemoveInputSource(isr); - DisplayFatalError("Connection closed by ICS", 0, 0); + DisplayFatalError(_("Connection closed by ICS"), 0, 0); } else { - DisplayFatalError("Error reading from ICS", error, 1); + DisplayFatalError(_("Error reading from ICS"), error, 1); } } @@ -3164,8 +3286,8 @@ ParseBoard12(string) char *string; { GameMode newGameMode; - int gamenum, newGame, newMove, relation, basetime, increment, ics_flip = 0; - int j, k, n, moveNum, white_stren, black_stren, white_time, black_time; + int gamenum, newGame, newMove, relation, basetime, increment, ics_flip = 0, i; + int j, k, n, moveNum, white_stren, black_stren, white_time, black_time, takeback; int double_push, castle_ws, castle_wl, castle_bs, castle_bl, irrev_count; char to_play, board_chars[200]; char move_str[500], str[500], elapsed_time[500]; @@ -3184,7 +3306,7 @@ ParseBoard12(string) newGame = FALSE; if (appData.debugMode) - fprintf(debugFP, "Parsing board: %s\n", string); + fprintf(debugFP, _("Parsing board: %s\n"), string); move_str[0] = NULLCHAR; elapsed_time[0] = NULLCHAR; @@ -3207,7 +3329,7 @@ ParseBoard12(string) &ticking); if (n < 21) { - sprintf(str, "Failed to parse board string:\n\"%s\"", string); + sprintf(str, _("Failed to parse board string:\n\"%s\""), string); DisplayError(str, 0); return; } @@ -3216,7 +3338,7 @@ ParseBoard12(string) moveNum = (moveNum - 1) * 2; if (to_play == 'B') moveNum++; if (moveNum >= MAX_MOVES) { - DisplayFatalError("Game too long; increase MAX_MOVES and recompile", + DisplayFatalError(_("Game too long; increase MAX_MOVES and recompile"), 0, 1); return; } @@ -3278,7 +3400,7 @@ ParseBoard12(string) return; case H_GETTING_MOVES: /* Should not happen */ - DisplayError("Error gathering move list: extra board", 0); + DisplayError(_("Error gathering move list: extra board"), 0); ics_getting_history = H_FALSE; return; } @@ -3479,6 +3601,16 @@ ParseBoard12(string) /* Update currentMove and known move number limits */ newMove = newGame || moveNum > forwardMostMove; + + /* [DM] If we found takebacks during icsEngineAnalyze try send to engine */ + if (!newGame && appData.icsEngineAnalyze && moveNum < forwardMostMove) { + takeback = forwardMostMove - moveNum; + for (i = 0; i < takeback; i++) { + if (appData.debugMode) fprintf(debugFP, "take back move\n"); + SendToProgram("undo\n", &first); + } + } + if (newGame) { forwardMostMove = backwardMostMove = currentMove = moveNum; if (gameMode == IcsExamining && moveNum == 0) { @@ -3548,8 +3680,37 @@ ParseBoard12(string) strcat(parseList[moveNum - 1], " "); strcat(parseList[moveNum - 1], elapsed_time); moveList[moveNum - 1][0] = NULLCHAR; - } else if (ParseOneMove(move_str, moveNum - 1, &moveType, - &fromX, &fromY, &toX, &toY, &promoChar)) { + } else if (strcmp(move_str, "none") == 0) { + // [HGM] long SAN: swapped order; test for 'none' before parsing move + /* Again, we don't know what the board looked like; + this is really the start of the game. */ + parseList[moveNum - 1][0] = NULLCHAR; + moveList[moveNum - 1][0] = NULLCHAR; + backwardMostMove = moveNum; + startedFromSetupPosition = TRUE; + fromX = fromY = toX = toY = -1; + } else { + // [HGM] long SAN: if legality-testing is off, disambiguation might not work or give wrong move. + // So we parse the long-algebraic move string in stead of the SAN move + int valid; char buf[MSG_SIZ], *prom; + + // str looks something like "Q/a1-a2"; kill the slash + if(str[1] == '/') + sprintf(buf, "%c%s", str[0], str+2); + else strcpy(buf, str); // might be castling + if((prom = strstr(move_str, "=")) && !strstr(buf, "=")) + strcat(buf, prom); // long move lacks promo specification! + if(!appData.testLegality) { + if(appData.debugMode) + fprintf(debugFP, "replaced ICS move '%s' by '%s'\n", move_str, buf); + strcpy(move_str, buf); + } + valid = ParseOneMove(move_str, moveNum - 1, &moveType, + &fromX, &fromY, &toX, &toY, &promoChar) + || ParseOneMove(buf, moveNum - 1, &moveType, + &fromX, &fromY, &toX, &toY, &promoChar); + // end of long SAN patch + if (valid) { (void) CoordsToAlgebraic(boards[moveNum - 1], PosFlags(moveNum - 1), EP_UNKNOWN, fromY, fromX, toY, toX, promoChar, @@ -3573,15 +3734,7 @@ ParseBoard12(string) /* currentMoveString is set as a side-effect of ParseOneMove */ strcpy(moveList[moveNum - 1], currentMoveString); strcat(moveList[moveNum - 1], "\n"); - } else if (strcmp(move_str, "none") == 0) { - /* Again, we don't know what the board looked like; - this is really the start of the game. */ - parseList[moveNum - 1][0] = NULLCHAR; - moveList[moveNum - 1][0] = NULLCHAR; - backwardMostMove = moveNum; - startedFromSetupPosition = TRUE; - fromX = fromY = toX = toY = -1; - } else { + } else { /* Move from ICS was illegal!? Punt. */ if (appData.debugMode) { fprintf(debugFP, "Illegal move from ICS '%s'\n", move_str); @@ -3598,6 +3751,7 @@ ParseBoard12(string) strcat(parseList[moveNum - 1], elapsed_time); moveList[moveNum - 1][0] = NULLCHAR; fromX = fromY = toX = toY = -1; + } } if (appData.debugMode) { fprintf(debugFP, "Move parsed to '%s'\n", parseList[moveNum - 1]); @@ -3612,7 +3766,7 @@ ParseBoard12(string) if ((gameMode == IcsPlayingWhite && WhiteOnMove(moveNum)) || (gameMode == IcsPlayingBlack && !WhiteOnMove(moveNum))) { if (moveList[moveNum - 1][0] == NULLCHAR) { - sprintf(str, "Couldn't parse move \"%s\" from ICS", + sprintf(str, _("Couldn't parse move \"%s\" from ICS"), move_str); DisplayError(str, 0); } else { @@ -3634,7 +3788,7 @@ ParseBoard12(string) } } else if (gameMode == IcsObserving || gameMode == IcsExamining) { if (moveList[moveNum - 1][0] == NULLCHAR) { - sprintf(str, "Couldn't parse move \"%s\" from ICS", move_str); + sprintf(str, _("Couldn't parse move \"%s\" from ICS"), move_str); DisplayError(str, 0); } else { if(gameInfo.variant == currentlyInitializedVariant) // [HGM] refrain sending moves engine can't understand! @@ -3724,7 +3878,7 @@ ParseBoard12(string) programStats.depth = programStats.nodes = programStats.time = programStats.score = programStats.got_only_move = 0; - sprintf(programStats.movelist, "%s (xbook)", bookMove); + sprintf(programStats.movelist, "%s (xbook)", bookHit); strcpy(bookMove, "move "); strcat(bookMove, bookHit); @@ -3836,7 +3990,7 @@ SendMoveToICS(moveType, fromX, fromY, toX, toY) switch (moveType) { default: - sprintf(user_move, "say Internal error; bad moveType %d (%d,%d-%d,%d)", + sprintf(user_move, _("say Internal error; bad moveType %d (%d,%d-%d,%d)"), (int)moveType, fromX, fromY, toX, toY); DisplayError(user_move + strlen("say "), 0); break; @@ -3874,10 +4028,14 @@ SendMoveToICS(moveType, fromX, fromY, toX, toY) case BlackPromotionChancellor: case WhitePromotionArchbishop: case BlackPromotionArchbishop: - if(gameInfo.variant == VariantShatranj) + if(gameInfo.variant == VariantShatranj || gameInfo.variant == VariantCourier) sprintf(user_move, "%c%c%c%c=%c\n", AAA + fromX, ONE + fromY, AAA + toX, ONE + toY, PieceToChar(WhiteFerz)); + else if(gameInfo.variant == VariantGreat) + sprintf(user_move, "%c%c%c%c=%c\n", + AAA + fromX, ONE + fromY, AAA + toX, ONE + toY, + PieceToChar(WhiteMan)); else sprintf(user_move, "%c%c%c%c=%c\n", AAA + fromX, ONE + fromY, AAA + toX, ONE + toY, @@ -4521,6 +4679,12 @@ InitPosition(redraw) pieces = fairyArray; SetCharTable(pieceToChar, "PNBRQFEACWMOHIJGDVSLUKpnbrqfeacwmohijgdvsluk"); break; + case VariantGreat: + pieces = GreatArray; + gameInfo.boardWidth = 10; + SetCharTable(pieceToChar, "PN....E...S..HWGMKpn....e...s..hwgmk"); + gameInfo.holdingsSize = 8; + break; case VariantSuper: pieces = FIDEArray; SetCharTable(pieceToChar, "PNBRQ..SE.......V.AKpnbrq..se.......v.ak"); @@ -4562,7 +4726,7 @@ InitPosition(redraw) } if(gameInfo.holdingsSize) gameInfo.holdingsWidth = 2; if(BOARD_HEIGHT > BOARD_SIZE || BOARD_WIDTH > BOARD_SIZE) - DisplayFatalError("Recompile to support this BOARD_SIZE!", 0, 2); + DisplayFatalError(_("Recompile to support this BOARD_SIZE!"), 0, 2); pawnRow = gameInfo.boardHeight - 7; /* seems to work in all common variants */ if(pawnRow < 1) pawnRow = 1; @@ -4619,6 +4783,12 @@ InitPosition(redraw) } if(gameInfo.variant == VariantSuper) Prelude(initialPosition); + if(gameInfo.variant == VariantGreat) { // promotion commoners + initialPosition[PieceToNumber(WhiteMan)][BOARD_RGHT-1] = WhiteMan; + initialPosition[PieceToNumber(WhiteMan)][BOARD_RGHT-2] = 9; + initialPosition[BOARD_HEIGHT-1-PieceToNumber(WhiteMan)][0] = BlackMan; + initialPosition[BOARD_HEIGHT-1-PieceToNumber(WhiteMan)][1] = 9; + } #if 0 if(gameInfo.variant == VariantFischeRandom) { if( appData.defaultFrcPosition < 0 ) { @@ -4822,7 +4992,7 @@ OKToStartUserMove(x, y) case IcsPlayingBlack: if (appData.zippyPlay) return FALSE; if (white_piece) { - DisplayMoveError("You are playing Black"); + DisplayMoveError(_("You are playing Black")); return FALSE; } break; @@ -4831,18 +5001,18 @@ OKToStartUserMove(x, y) case IcsPlayingWhite: if (appData.zippyPlay) return FALSE; if (!white_piece) { - DisplayMoveError("You are playing White"); + DisplayMoveError(_("You are playing White")); return FALSE; } break; case EditGame: if (!white_piece && WhiteOnMove(currentMove)) { - DisplayMoveError("It is White's turn"); + DisplayMoveError(_("It is White's turn")); return FALSE; } if (white_piece && !WhiteOnMove(currentMove)) { - DisplayMoveError("It is Black's turn"); + DisplayMoveError(_("It is Black's turn")); return FALSE; } if (cmailMsgLoaded && (currentMove < cmailOldMove)) { @@ -4862,7 +5032,7 @@ OKToStartUserMove(x, y) if (appData.icsActive) return FALSE; if (!appData.noChessProgram) { if (!white_piece) { - DisplayMoveError("You are playing White"); + DisplayMoveError(_("You are playing White")); return FALSE; } } @@ -4870,11 +5040,11 @@ OKToStartUserMove(x, y) case Training: if (!white_piece && WhiteOnMove(currentMove)) { - DisplayMoveError("It is White's turn"); + DisplayMoveError(_("It is White's turn")); return FALSE; } if (white_piece && !WhiteOnMove(currentMove)) { - DisplayMoveError("It is Black's turn"); + DisplayMoveError(_("It is Black's turn")); return FALSE; } break; @@ -4885,7 +5055,7 @@ OKToStartUserMove(x, y) } if (currentMove != forwardMostMove && gameMode != AnalyzeMode && gameMode != AnalyzeFile && gameMode != Training) { - DisplayMoveError("Displayed position is not current"); + DisplayMoveError(_("Displayed position is not current")); return FALSE; } return TRUE; @@ -4955,7 +5125,7 @@ UserMoveTest(fromX, fromY, toX, toY, promoChar) case MachinePlaysWhite: /* User is moving for Black */ if (WhiteOnMove(currentMove)) { - DisplayMoveError("It is White's turn"); + DisplayMoveError(_("It is White's turn")); return ImpossibleMove; } break; @@ -4963,7 +5133,7 @@ UserMoveTest(fromX, fromY, toX, toY, promoChar) case MachinePlaysBlack: /* User is moving for White */ if (!WhiteOnMove(currentMove)) { - DisplayMoveError("It is Black's turn"); + DisplayMoveError(_("It is Black's turn")); return ImpossibleMove; } break; @@ -4977,13 +5147,13 @@ UserMoveTest(fromX, fromY, toX, toY, promoChar) (int) boards[currentMove][fromY][fromX] < (int) EmptySquare) { /* User is moving for Black */ if (WhiteOnMove(currentMove)) { - DisplayMoveError("It is White's turn"); + DisplayMoveError(_("It is White's turn")); return ImpossibleMove; } } else { /* User is moving for White */ if (!WhiteOnMove(currentMove)) { - DisplayMoveError("It is Black's turn"); + DisplayMoveError(_("It is Black's turn")); return ImpossibleMove; } } @@ -4993,7 +5163,7 @@ UserMoveTest(fromX, fromY, toX, toY, promoChar) /* User is moving for Black */ if (WhiteOnMove(currentMove)) { if (!appData.premove) { - DisplayMoveError("It is White's turn"); + DisplayMoveError(_("It is White's turn")); } else if (toX >= 0 && toY >= 0) { premoveToX = toX; premoveToY = toY; @@ -5014,7 +5184,7 @@ UserMoveTest(fromX, fromY, toX, toY, promoChar) /* User is moving for White */ if (!WhiteOnMove(currentMove)) { if (!appData.premove) { - DisplayMoveError("It is Black's turn"); + DisplayMoveError(_("It is Black's turn")); } else if (toX >= 0 && toY >= 0) { premoveToX = toX; premoveToY = toY; @@ -5073,11 +5243,11 @@ UserMoveTest(fromX, fromY, toX, toY, promoChar) /* [HGM] but possibly ignore an IllegalMove result */ if (appData.testLegality) { if (moveType == IllegalMove || moveType == ImpossibleMove) { - DisplayMoveError("Illegal move"); + DisplayMoveError(_("Illegal move")); return ImpossibleMove; } } - +if(appData.debugMode) fprintf(debugFP, "moveType 3 = %d, promochar = %x\n", moveType, promoChar); return moveType; /* [HGM] in stead of calling FinishMove directly, this function is made into one that returns an OK move type if FinishMove @@ -5096,8 +5266,8 @@ FinishMove(moveType, fromX, fromY, toX, toY, promoChar) /*char*/int promoChar; { char *bookHit = 0; - - if(gameInfo.variant == VariantSuper && promoChar != NULLCHAR) { +if(appData.debugMode) fprintf(debugFP, "moveType 5 = %d, promochar = %x\n", moveType, promoChar); + if((gameInfo.variant == VariantSuper || gameInfo.variant == VariantGreat) && promoChar != NULLCHAR) { // [HGM] superchess: suppress promotions to non-available piece int k = PieceToNumber(CharToPiece(ToUpper(promoChar))); if(WhiteOnMove(currentMove)) { @@ -5111,7 +5281,7 @@ FinishMove(moveType, fromX, fromY, toX, toY, promoChar) move type in caller when we know the move is a legal promotion */ if(moveType == NormalMove && promoChar) moveType = PromoCharToMoveType(WhiteOnMove(currentMove), promoChar); - +if(appData.debugMode) fprintf(debugFP, "moveType 1 = %d, promochar = %x\n", moveType, promoChar); /* [HGM] convert drag-and-drop piece drops to standard form */ if( fromX == BOARD_LEFT-2 || fromX == BOARD_RGHT+1) { moveType = WhiteOnMove(currentMove) ? WhiteDrop : BlackDrop; @@ -5150,10 +5320,10 @@ FinishMove(moveType, fromX, fromY, toX, toY, promoChar) gameMode = PlayFromGameFile; ModeHighlight(); SetTrainingModeOff(); - DisplayInformation("End of game"); + DisplayInformation(_("End of game")); } } else { - DisplayError("Incorrect move", 0); + DisplayError(_("Incorrect move"), 0); } return 1; } @@ -5175,7 +5345,8 @@ FinishMove(moveType, fromX, fromY, toX, toY, promoChar) MakeMove(fromX, fromY, toX, toY, promoChar); /*updates forwardMostMove*/ - if(gameInfo.variant == VariantSuper && promoChar != NULLCHAR && gameInfo.holdingsSize) { + if((gameInfo.variant == VariantSuper || gameInfo.variant == VariantGreat) + && promoChar != NULLCHAR && gameInfo.holdingsSize) { // [HGM] superchess: take promotion piece out of holdings int k = PieceToNumber(CharToPiece(ToUpper(promoChar))); if(WhiteOnMove(forwardMostMove-1)) { @@ -5206,7 +5377,7 @@ FinishMove(moveType, fromX, fromY, toX, toY, promoChar) } ModeHighlight(); } - +if(appData.debugMode) fprintf(debugFP, "moveType 2 = %d, promochar = %x\n", moveType, promoChar); /* Relay move to ICS or chess engine */ if (appData.icsActive) { if (gameMode == IcsPlayingWhite || gameMode == IcsPlayingBlack || @@ -5267,7 +5438,7 @@ FinishMove(moveType, fromX, fromY, toX, toY, promoChar) programStats.depth = programStats.nodes = programStats.time = programStats.score = programStats.got_only_move = 0; - sprintf(programStats.movelist, "%s (xbook)", bookMove); + sprintf(programStats.movelist, "%s (xbook)", bookHit); strcpy(bookMove, "move "); strcat(bookMove, bookHit); @@ -5291,7 +5462,7 @@ UserMoveEvent(fromX, fromY, toX, toY, promoChar) to do anything in between, can call this routine the old way. */ ChessMove moveType = UserMoveTest(fromX, fromY, toX, toY, promoChar); - +if(appData.debugMode) fprintf(debugFP, "moveType 4 = %d, promochar = %x\n", moveType, promoChar); if(moveType != ImpossibleMove) FinishMove(moveType, fromX, fromY, toX, toY, promoChar); } @@ -5327,7 +5498,7 @@ char *SendMoveToBookUser(int moveNr, ChessProgramState *cps, int initial) //first determine if the incoming move brings opponent into his book if(appData.usePolyglotBook && (cps == &first ? !appData.firstHasOwnBookUCI : !appData.secondHasOwnBookUCI)) bookHit = ProbeBook(moveNr+1, appData.polyglotBook); // returns move - if(appData.debugMode && bookHit) fprintf(debugFP, "book hit = %s\n", bookHit); + if(appData.debugMode) fprintf(debugFP, "book hit = %s\n", bookHit ? bookHit : "(NULL)"); if(bookHit != NULL && !cps->bookSuspend) { // make sure opponent is not going to reply after receiving move to book position SendToProgram("force\n", cps); @@ -5489,7 +5660,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h if (!ParseOneMove(machineMove, forwardMostMove, &moveType, &fromX, &fromY, &toX, &toY, &promoChar)) { /* Machine move could not be parsed; ignore it. */ - sprintf(buf1, "Illegal move \"%s\" from %s machine", + sprintf(buf1, _("Illegal move \"%s\" from %s machine"), machineMove, cps->which); DisplayError(buf1, 0); sprintf(buf1, "Xboard: Forfeit due to invalid move: %s (%c%c%c%c) res=%d%c", @@ -5553,7 +5724,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h first.initDone) { SendMoveToICS(moveType, fromX, fromY, toX, toY); ics_user_moved = 1; - if(appData.autoKibitz) { /* [HGM] kibitz: send most-recent PV info to ICS */ + if(appData.autoKibitz && !appData.icsEngineAnalyze ) { /* [HGM] kibitz: send most-recent PV info to ICS */ char buf[3*MSG_SIZ]; sprintf(buf, "kibitz %d/%+.2f (%.2f sec, %.0f nodes, %1.0f knps) PV = %s\n", @@ -5614,7 +5785,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h if( gameMode == TwoMachinesPlay ) { // [HGM] some adjudications useful with buggy engines int k, count = 0, epFile = epStatus[forwardMostMove]; static int bare = 1; - if(gameInfo.holdingsSize == 0 || gameInfo.variant == VariantSuper) { + if(gameInfo.holdingsSize == 0 || gameInfo.variant == VariantSuper || gameInfo.variant == VariantGreat) { if(appData.testLegality) // don't wait for engine to announce game end if we can judge ourselves @@ -5628,6 +5799,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h case MT_STALEMATE: epStatus[forwardMostMove] = EP_STALEMATE; if(appData.checkMates) { + SendMoveToProgram(forwardMostMove-1, cps->other); /* make sure opponent gets to see move */ ShowMove(fromX, fromY, toX, toY); /*updates currentMove*/ GameEnds( GameIsDrawn, "Xboard adjudication: Stalemate", GE_XBOARD ); @@ -5636,6 +5808,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h case MT_CHECKMATE: epStatus[forwardMostMove] = EP_CHECKMATE; if(appData.checkMates) { + SendMoveToProgram(forwardMostMove-1, cps->other); /* make sure opponent gets to see move */ ShowMove(fromX, fromY, toX, toY); /*updates currentMove*/ GameEnds( WhiteOnMove(forwardMostMove) ? BlackWins : WhiteWins, "Xboard adjudication: Checkmate", @@ -5661,11 +5834,13 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h case WhiteKnight: NrWN++; break; case WhiteBishop: + case WhiteFerz: // [HGM] shatranj: kludge to mke it work in shatranj bishopsColor |= 1 << ((i^j)&1); NrWB++; break; case BlackKnight: NrBN++; break; case BlackBishop: + case BlackFerz: // [HGM] shatranj: kludge to mke it work in shatranj bishopsColor |= 1 << ((i^j)&1); NrBB++; break; case WhiteRook: @@ -5685,10 +5860,16 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h } NrPieces += (p != EmptySquare); NrW += ((int)p < (int)BlackPawn); + if(gameInfo.variant == VariantXiangqi && + (p == WhiteFerz || p == WhiteAlfil || p == BlackFerz || p == BlackAlfil)) { + NrPieces--; // [HGM] XQ: do not count purely defensive pieces + NrW -= ((int)p < (int)BlackPawn); + } } - if( NrPieces == 3 && NrWN+NrBN+NrWB+NrBB == 1 || NrPieces == 2 - || NrPieces == 4 && NrBB+NrWB == NrPieces-2 && bishopsColor != 3) + if( NrPieces == 2 || gameInfo.variant != VariantXiangqi && + (NrPieces == 3 && NrWN+NrBN+NrWB+NrBB == 1 || + NrPieces == NrBB+NrWB+2 && bishopsColor != 3)) // [HGM] all Bishops (Ferz!) same color { /* KBK, KNK, KK of KBKB with like Bishops */ /* always flag draws, for judging claims */ @@ -5696,6 +5877,8 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h if(appData.materialDraws) { /* but only adjudicate them if adjudication enabled */ + SendToProgram("force\n", cps->other); // suppress reply + SendMoveToProgram(forwardMostMove-1, cps->other); /* make sure opponent gets to see last move */ ShowMove(fromX, fromY, toX, toY); /*updates currentMove*/ GameEnds( GameIsDrawn, "Xboard adjudication: Insufficient mating material", GE_XBOARD ); return; @@ -5708,6 +5891,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h if(--bare < 0 && appData.checkMates) { /* but only adjudicate them if adjudication enabled */ + SendMoveToProgram(forwardMostMove-1, cps->other); /* make sure opponent gets to see move */ ShowMove(fromX, fromY, toX, toY); /*updates currentMove*/ GameEnds( NrW > 1 ? WhiteWins : NrPieces - NrW > 1 ? BlackWins : GameIsDrawn, "Xboard adjudication: Bare king", GE_XBOARD ); @@ -5724,6 +5908,8 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h ) ) { if(--moveCount < 0 && appData.trivialDraws) { /* if the first 3 moves do not show a tactical win, declare draw */ + SendToProgram("force\n", cps->other); // suppress reply + SendMoveToProgram(forwardMostMove-1, cps->other); /* make sure opponent gets to see move */ ShowMove(fromX, fromY, toX, toY); /*updates currentMove*/ GameEnds( GameIsDrawn, "Xboard adjudication: Trivial draw", GE_XBOARD ); return; @@ -5790,7 +5976,30 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h if( rights == 0 && ++count > appData.drawRepeats-2 && appData.drawRepeats > 1) { /* adjudicate after user-specified nr of repeats */ + SendToProgram("force\n", cps->other); // suppress reply + SendMoveToProgram(forwardMostMove-1, cps->other); /* make sure opponent gets to see move */ ShowMove(fromX, fromY, toX, toY); /*updates currentMove*/ + if(gameInfo.variant == VariantXiangqi && appData.testLegality) { + // [HGM] xiangqi: check for forbidden perpetuals + int m, ourPerpetual = 1, hisPerpetual = 1; + for(m=forwardMostMove; m>k; m-=2) { + if(MateTest(boards[m], PosFlags(m), + EP_NONE, castlingRights[m]) != MT_CHECK) + ourPerpetual = 0; // the current mover did not always check + if(MateTest(boards[m-1], PosFlags(m-1), + EP_NONE, castlingRights[m-1]) != MT_CHECK) + hisPerpetual = 0; // the opponent did not always check + } + if(ourPerpetual && !hisPerpetual) { // we are actively checking him: forfeit + GameEnds( WhiteOnMove(forwardMostMove) ? WhiteWins : BlackWins, + "Xboard adjudication: perpetual checking", GE_XBOARD ); + return; + } + if(hisPerpetual && !ourPerpetual) // he is checking us, but did not repeat yet + break; // (or we would have caught him before). Abort repetition-checking loop. + // if neither of us is checking all the time, or both are, it is draw + // (illegal-chase forfeits not implemented yet!) + } GameEnds( GameIsDrawn, "Xboard adjudication: repetition draw", GE_XBOARD ); return; } @@ -5812,6 +6021,8 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h epStatus[forwardMostMove] = EP_RULE_DRAW; /* this is used to judge if draw claims are legal */ if(appData.ruleMoves > 0 && count >= 2*appData.ruleMoves) { + SendToProgram("force\n", cps->other); // suppress reply + SendMoveToProgram(forwardMostMove-1, cps->other); /* make sure opponent gets to see move */ ShowMove(fromX, fromY, toX, toY); /*updates currentMove*/ GameEnds( GameIsDrawn, "Xboard adjudication: 50-move rule", GE_XBOARD ); return; @@ -5831,6 +6042,8 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h if(epStatus[forwardMostMove] == EP_INSUF_DRAW) p = "Draw claim: insufficient mating material"; if( p != NULL ) { + SendToProgram("force\n", cps->other); // suppress reply + SendMoveToProgram(forwardMostMove-1, cps->other); /* make sure opponent gets to see move */ GameEnds( GameIsDrawn, p, GE_XBOARD ); ShowMove(fromX, fromY, toX, toY); /*updates currentMove*/ return; @@ -5838,14 +6051,15 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h } - } - - if( appData.adjudicateDrawMoves > 0 && forwardMostMove > (2*appData.adjudicateDrawMoves) ) { - ShowMove(fromX, fromY, toX, toY); /*updates currentMove*/ + if( appData.adjudicateDrawMoves > 0 && forwardMostMove > (2*appData.adjudicateDrawMoves) ) { + SendToProgram("force\n", cps->other); // suppress reply + SendMoveToProgram(forwardMostMove-1, cps->other); /* make sure opponent gets to see move */ + ShowMove(fromX, fromY, toX, toY); /*updates currentMove*/ - GameEnds( GameIsDrawn, "Xboard adjudication: long game", GE_XBOARD ); + GameEnds( GameIsDrawn, "Xboard adjudication: long game", GE_XBOARD ); - return; + return; + } } bookHit = NULL; @@ -5895,7 +6109,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h cps = cps->other; programStats.depth = programStats.nodes = programStats.time = programStats.score = programStats.got_only_move = 0; - sprintf(programStats.movelist, "%s (xbook)", bookMove); + sprintf(programStats.movelist, "%s (xbook)", bookHit); if(cps->lastPing != cps->lastPong) { savedMessage = message; // args for deferred call @@ -5928,7 +6142,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h GameEnds(GameUnfinished, "Engine aborts game", GE_XBOARD); if (!ParseFEN(initial_position, &blackPlaysFirst, message + 9)) { - DisplayError("Bad FEN received from engine", 0); + DisplayError(_("Bad FEN received from engine"), 0); return ; } else { Reset(FALSE, FALSE); @@ -6070,7 +6284,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h cps->analysisSupport = FALSE; cps->analyzing = FALSE; Reset(FALSE, TRUE); - sprintf(buf2, "%s does not support analysis", cps->tidy); + sprintf(buf2, _("%s does not support analysis"), cps->tidy); DisplayError(buf2, 0); return; } @@ -6116,7 +6330,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h DisplayMove(currentMove-1); /* before DisplayMoveError */ SwitchClocks(); DisplayBothClocks(); - sprintf(buf1, "Illegal move \"%s\" (rejected by %s chess program)", + sprintf(buf1, _("Illegal move \"%s\" (rejected by %s chess program)"), parseList[currentMove], cps->which); DisplayMoveError(buf1); DrawPosition(FALSE, boards[currentMove]); @@ -6148,7 +6362,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h || (StrStr(message, "Permission denied") != NULL)) { cps->maybeThinking = FALSE; - sprintf(buf1, "Failed to start %s chess program %s on %s: %s\n", + sprintf(buf1, _("Failed to start %s chess program %s on %s: %s\n"), cps->which, cps->program, cps->host, message); RemoveInputSource(cps->isr); DisplayFatalError(buf1, 0, 1); @@ -6166,12 +6380,12 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h (void) CoordsToAlgebraic(boards[forwardMostMove], PosFlags(forwardMostMove), EP_UNKNOWN, fromY, fromX, toY, toX, promoChar, buf1); - sprintf(buf2, "Hint: %s", buf1); + sprintf(buf2, _("Hint: %s"), buf1); DisplayInformation(buf2); } else { /* Hint move could not be parsed!? */ sprintf(buf2, - "Illegal hint move \"%s\"\nfrom %s chess program", + _("Illegal hint move \"%s\"\nfrom %s chess program"), buf1, cps->which); DisplayError(buf2, 0); } @@ -6353,10 +6567,10 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h } else if (gameMode == MachinePlaysWhite || gameMode == MachinePlaysBlack) { if (userOfferedDraw) { - DisplayInformation("Machine accepts your draw offer"); + DisplayInformation(_("Machine accepts your draw offer")); GameEnds(GameIsDrawn, "Draw agreed", GE_XBOARD); } else { - DisplayInformation("Machine offers a draw\nSelect Action / Draw to agree"); + DisplayInformation(_("Machine offers a draw\nSelect Action / Draw to agree")); } } } @@ -6370,7 +6584,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h ) { int plylev, mvleft, mvtot, curscore, time; char mvname[MOVE_LEN]; - unsigned long nodes; + u64 nodes; // [DM] char plyext; int ignore = FALSE; int prefixHint = FALSE; @@ -6387,6 +6601,9 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h break; case AnalyzeMode: case AnalyzeFile: + break; + case IcsObserving: /* [DM] icsEngineAnalyze */ + if (!appData.icsEngineAnalyze) ignore = TRUE; break; case TwoMachinesPlay: if ((cps->twoMachinesColor[0] == 'w') != WhiteOnMove(forwardMostMove)) { @@ -6400,7 +6617,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h if (!ignore) { buf1[0] = NULLCHAR; - if (sscanf(message, "%d%c %d %d %lu %[^\n]\n", + if (sscanf(message, "%d%c %d %d " u64Display " %[^\n]\n", &plylev, &plyext, &curscore, &time, &nodes, buf1) >= 5) { if (plyext != ' ' && plyext != '\t') { @@ -6484,7 +6701,8 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h strcat( thinkOutput, buf1 ); } - if (currentMove == forwardMostMove || gameMode == AnalyzeMode || gameMode == AnalyzeFile) { + if (currentMove == forwardMostMove || gameMode == AnalyzeMode + || gameMode == AnalyzeFile || appData.icsEngineAnalyze) { DisplayMove(currentMove - 1); DisplayAnalysis(); } @@ -6511,12 +6729,13 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h SendProgramStatsToFrontend( cps, &programStats ); - if (currentMove == forwardMostMove || gameMode==AnalyzeMode || gameMode == AnalyzeFile) { + if (currentMove == forwardMostMove || gameMode==AnalyzeMode || + gameMode == AnalyzeFile || appData.icsEngineAnalyze) { DisplayMove(currentMove - 1); DisplayAnalysis(); } return; - } else if (sscanf(message,"stat01: %d %lu %d %d %d %s", + } else if (sscanf(message,"stat01: %d " u64Display " %d %d %d %s", &time, &nodes, &plylev, &mvleft, &mvtot, mvname) >= 5) { /* The stat01: line is from Crafty (9.29+) in response @@ -6571,7 +6790,8 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h strcat(programStats.movelist, p); } - if (currentMove == forwardMostMove || gameMode==AnalyzeMode || gameMode == AnalyzeFile) { + if (currentMove == forwardMostMove || gameMode==AnalyzeMode || + gameMode == AnalyzeFile || appData.icsEngineAnalyze) { DisplayMove(currentMove - 1); DisplayAnalysis(); } @@ -6715,7 +6935,7 @@ ParseGameHistory(game) break; case AmbiguousMove: /* bug? */ - sprintf(buf, "Ambiguous move in ICS output: \"%s\"", yy_text); + sprintf(buf, _("Ambiguous move in ICS output: \"%s\""), yy_text); if (appData.debugMode) { fprintf(debugFP, "Ambiguous move from ICS: '%s'\n", yy_text); fprintf(debugFP, "board L=%d, R=%d, H=%d, holdings=%d\n", BOARD_LEFT, BOARD_RGHT, BOARD_HEIGHT, gameInfo.holdingsWidth); @@ -6725,7 +6945,7 @@ ParseGameHistory(game) return; case ImpossibleMove: /* bug? */ - sprintf(buf, "Illegal move in ICS output: \"%s\"", yy_text); + sprintf(buf, _("Illegal move in ICS output: \"%s\""), yy_text); if (appData.debugMode) { fprintf(debugFP, "Impossible move from ICS: '%s'\n", yy_text); fprintf(debugFP, "board L=%d, R=%d, H=%d, holdings=%d\n", BOARD_LEFT, BOARD_RGHT, BOARD_HEIGHT, gameInfo.holdingsWidth); @@ -6736,7 +6956,7 @@ ParseGameHistory(game) case (ChessMove) 0: /* end of file */ if (boardIndex < backwardMostMove) { /* Oops, gap. How did that happen? */ - DisplayError("Gap in move list", 0); + DisplayError(_("Gap in move list"), 0); return; } backwardMostMove = blackPlaysFirst ? 1 : 0; @@ -6836,24 +7056,28 @@ ApplyMove(fromX, fromY, toX, toY, promoChar, board) epStatus[p] = EP_CAPTURE; if( board[fromY][fromX] == WhitePawn ) { - epStatus[p] = EP_PAWN_MOVE; - if( toY-fromY==2) + if(fromY != toY) // [HGM] Xiangqi sideway Pawn moves should not count as 50-move breakers + epStatus[p] = EP_PAWN_MOVE; + if( toY-fromY==2) { if(toX>BOARD_LEFT && board[toY][toX-1] == BlackPawn && gameInfo.variant != VariantBerolina || toX < fromX) epStatus[p] = toX | berolina; if(toX fromX) epStatus[p] = toX; + } } else if( board[fromY][fromX] == BlackPawn ) { - epStatus[p] = EP_PAWN_MOVE; - if( toY-fromY== -2) + if(fromY != toY) // [HGM] Xiangqi sideway Pawn moves should not count as 50-move breakers + epStatus[p] = EP_PAWN_MOVE; + if( toY-fromY== -2) { if(toX>BOARD_LEFT && board[toY][toX-1] == WhitePawn && gameInfo.variant != VariantBerolina || toX < fromX) epStatus[p] = toX | berolina; if(toX fromX) epStatus[p] = toX; + } } for(i=0; i 0 && gameInfo.variant != VariantBughouse ) { /* [HGM] holdings: Add to holdings, if holdings exist */ - if(gameInfo.variant == VariantSuper) { + if(gameInfo.variant == VariantSuper || gameInfo.variant == VariantGreat) { // [HGM] superchess: suppress flipping color of captured pieces by reverse pre-flip captured = (int) captured >= (int) BlackPawn ? BLACK_TO_WHITE captured : WHITE_TO_BLACK captured; } @@ -7152,7 +7376,7 @@ MakeMove(fromX, fromY, toX, toY, promoChar) } if (forwardMostMove >= MAX_MOVES) { - DisplayFatalError("Game too long; increase MAX_MOVES and recompile", + DisplayFatalError(_("Game too long; increase MAX_MOVES and recompile"), 0, 1); return; } @@ -7203,6 +7427,7 @@ ShowMove(fromX, fromY, toX, toY) { int instant = (gameMode == PlayFromGameFile) ? (matchMode || (appData.timeDelay == 0 && !pausing)) : pausing; + if(appData.noGUI) return; if (!pausing || gameMode == PlayFromGameFile || gameMode == AnalyzeFile) { if (!instant) { if (forwardMostMove == currentMove + 1) { @@ -7288,7 +7513,7 @@ InitChessProgram(cps, setup) char *v = VariantName(gameInfo.variant); if (cps->protocolVersion != 1 && StrStr(cps->variants, v) == NULL) { /* [HGM] in protocol 1 we have to assume all variants valid */ - sprintf(buf, "Variant %s not supported by %s", v, cps->tidy); + sprintf(buf, _("Variant %s not supported by %s"), v, cps->tidy); DisplayFatalError(buf, 0, 1); return; } @@ -7308,6 +7533,8 @@ InitChessProgram(cps, setup) overruled = gameInfo.boardWidth != 12 || gameInfo.boardHeight != 8 || gameInfo.holdingsSize != 0; if( gameInfo.variant == VariantSuper ) overruled = gameInfo.boardWidth != 8 || gameInfo.boardHeight != 8 || gameInfo.holdingsSize != 8; + if( gameInfo.variant == VariantGreat ) + overruled = gameInfo.boardWidth != 10 || gameInfo.boardHeight != 8 || gameInfo.holdingsSize != 8; if(overruled) { sprintf(b, "%dx%d+%d_%s", gameInfo.boardWidth, gameInfo.boardHeight, @@ -7398,7 +7625,7 @@ StartChessProgram(cps) } if (err != 0) { - sprintf(buf, "Startup failure on '%s'", cps->program); + sprintf(buf, _("Startup failure on '%s'"), cps->program); DisplayFatalError(buf, err, 1); cps->pr = NoProc; cps->isr = NULL; @@ -7408,6 +7635,8 @@ StartChessProgram(cps) cps->isr = AddInputSource(cps->pr, TRUE, ReceiveFromProgram, cps); if (cps->protocolVersion > 1) { sprintf(buf, "xboard\nprotover %d\n", cps->protocolVersion); + cps->nrOptions = 0; // [HGM] options: clear all engine-specific options + cps->comboCnt = 0; // and values of combo boxes SendToProgram(buf, cps); } else { SendToProgram("xboard\n", cps); @@ -7419,13 +7648,13 @@ void TwoMachinesEventIfReady P((void)) { if (first.lastPing != first.lastPong) { - DisplayMessage("", "Waiting for first chess program"); - ScheduleDelayedEvent(TwoMachinesEventIfReady, 1000); + DisplayMessage("", _("Waiting for first chess program")); + ScheduleDelayedEvent(TwoMachinesEventIfReady, 10); // [HGM] fast: lowered from 1000 return; } if (second.lastPing != second.lastPong) { - DisplayMessage("", "Waiting for second chess program"); - ScheduleDelayedEvent(TwoMachinesEventIfReady, 1000); + DisplayMessage("", _("Waiting for second chess program")); + ScheduleDelayedEvent(TwoMachinesEventIfReady, 10); // [HGM] fast: lowered from 1000 return; } ThawUI(); @@ -7545,7 +7774,7 @@ GameEnds(result, resultDetails, whosays) claimer = whosays == GE_ENGINE1 ? /* color of claimer */ first.twoMachinesColor[0] : second.twoMachinesColor[0] ; - if( (gameInfo.holdingsWidth == 0 || gameInfo.variant == VariantSuper) && + if( (gameInfo.holdingsWidth == 0 || gameInfo.variant == VariantSuper || gameInfo.variant == VariantGreat) && (result == WhiteWins && claimer == 'w' || result == BlackWins && claimer == 'b' ) ) { if (appData.debugMode) { @@ -7573,7 +7802,8 @@ GameEnds(result, resultDetails, whosays) /* (Claiming a loss is accepted no questions asked!) */ } /* [HGM] bare: don't allow bare King to win */ - if((gameInfo.holdingsWidth == 0 || gameInfo.variant == VariantSuper) && result != GameIsDrawn) + if((gameInfo.holdingsWidth == 0 || gameInfo.variant == VariantSuper || gameInfo.variant == VariantGreat) + && result != GameIsDrawn) { int i, j, k=0, color = (result==WhiteWins ? (int)WhitePawn : (int)BlackPawn); for(j=BOARD_LEFT; jnumber > 1) { GameListPopUp(f, title); @@ -8390,7 +8621,7 @@ CmailLoadGame(f, gameNumber, title, useList) int retVal; if (gameNumber > nCmailGames) { - DisplayError("No more games in this message", 0); + DisplayError(_("No more games in this message"), 0); return FALSE; } if (f == lastLoadGameFP) { @@ -8431,11 +8662,11 @@ ReloadGame(offset) { int gameNumber = lastLoadGameNumber + offset; if (lastLoadGameFP == NULL) { - DisplayError("No game has been loaded yet", 0); + DisplayError(_("No game has been loaded yet"), 0); return FALSE; } if (gameNumber <= 0) { - DisplayError("Can't back up any further", 0); + DisplayError(_("Can't back up any further"), 0); return FALSE; } if (cmailMsgLoaded) { @@ -8491,7 +8722,7 @@ LoadGame(f, gameNumber, title, useList) gn = 1; } else { - DisplayError("Game number out of range", 0); + DisplayError(_("Game number out of range"), 0); return FALSE; } } else { @@ -8502,7 +8733,7 @@ LoadGame(f, gameNumber, title, useList) gameNumber == 1) { gn = 1; } else { - DisplayError("Can't seek on game file", 0); + DisplayError(_("Can't seek on game file"), 0); return FALSE; } } @@ -8560,7 +8791,7 @@ LoadGame(f, gameNumber, title, useList) nCmailGames = CMAIL_MAX_GAMES - gn; } else { Reset(TRUE, TRUE); - DisplayError("Game not found in file", 0); + DisplayError(_("Game not found in file"), 0); } return FALSE; @@ -8687,7 +8918,7 @@ LoadGame(f, gameNumber, title, useList) startedFromSetupPosition = TRUE; if (!ParseFEN(initial_position, &blackPlaysFirst, gameInfo.fen)) { Reset(TRUE, TRUE); - DisplayError("Bad FEN position in file", 0); + DisplayError(_("Bad FEN position in file"), 0); return FALSE; } CopyBoard(boards[0], initial_position); @@ -8845,7 +9076,7 @@ LoadGame(f, gameNumber, title, useList) if ((cm == (ChessMove) 0 && lastLoadGameStart != (ChessMove) 0) || cm == WhiteWins || cm == BlackWins || cm == GameIsDrawn || cm == GameUnfinished) { - DisplayMessage("", "No moves in game"); + DisplayMessage("", _("No moves in game")); if (cmailMsgLoaded) { if (appData.debugMode) fprintf(debugFP, "Setting flipView to %d.\n", FALSE); @@ -8916,11 +9147,11 @@ ReloadPosition(offset) { int positionNumber = lastLoadPositionNumber + offset; if (lastLoadPositionFP == NULL) { - DisplayError("No position has been loaded yet", 0); + DisplayError(_("No position has been loaded yet"), 0); return FALSE; } if (positionNumber <= 0) { - DisplayError("Can't back up any further", 0); + DisplayError(_("Can't back up any further"), 0); return FALSE; } return LoadPosition(lastLoadPositionFP, positionNumber, @@ -8942,7 +9173,7 @@ LoadPositionFromFile(filename, n, title) } else { f = fopen(filename, "rb"); if (f == NULL) { - sprintf(buf, "Can't open \"%s\"", filename); + sprintf(buf, _("Can't open \"%s\""), filename); DisplayError(buf, errno); return FALSE; } else { @@ -8983,7 +9214,7 @@ LoadPosition(f, positionNumber, title) if (positionNumber < 0) { /* Negative position number means to seek to that byte offset */ if (fseek(f, -positionNumber, 0) == -1) { - DisplayError("Can't seek on position file", 0); + DisplayError(_("Can't seek on position file"), 0); return FALSE; }; pn = 1; @@ -8994,14 +9225,14 @@ LoadPosition(f, positionNumber, title) positionNumber == 1) { pn = 1; } else { - DisplayError("Can't seek on position file", 0); + DisplayError(_("Can't seek on position file"), 0); return FALSE; } } } /* See if this file is FEN or old-style xboard */ if (fgets(line, MSG_SIZ, f) == NULL) { - DisplayError("Position not found in file", 0); + DisplayError(_("Position not found in file"), 0); return FALSE; } #if 0 @@ -9031,7 +9262,7 @@ LoadPosition(f, positionNumber, title) /* skip positions before number pn */ if (fgets(line, MSG_SIZ, f) == NULL) { Reset(TRUE, TRUE); - DisplayError("Position not found in file", 0); + DisplayError(_("Position not found in file"), 0); return FALSE; } if (fenMode || line[0] == '#') pn--; @@ -9040,7 +9271,7 @@ LoadPosition(f, positionNumber, title) if (fenMode) { if (!ParseFEN(initial_position, &blackPlaysFirst, line)) { - DisplayError("Bad FEN position in file", 0); + DisplayError(_("Bad FEN position in file"), 0); return FALSE; } } else { @@ -9072,10 +9303,10 @@ LoadPosition(f, positionNumber, title) strcpy(moveList[0], ""); strcpy(parseList[0], ""); CopyBoard(boards[1], initial_position); - DisplayMessage("", "Black to play"); + DisplayMessage("", _("Black to play")); } else { currentMove = forwardMostMove = backwardMostMove = 0; - DisplayMessage("", "White to play"); + DisplayMessage("", _("White to play")); } /* [HGM] copy FEN attributes as well */ { int i; @@ -9156,7 +9387,7 @@ SaveGameToFile(filename, append) } else { f = fopen(filename, append ? "a" : "w"); if (f == NULL) { - sprintf(buf, "Can't open \"%s\"", filename); + sprintf(buf, _("Can't open \"%s\""), filename); DisplayError(buf, errno); return FALSE; } else { @@ -9527,7 +9758,7 @@ SavePositionToFile(filename) } else { f = fopen(filename, "a"); if (f == NULL) { - sprintf(buf, "Can't open \"%s\"", filename); + sprintf(buf, _("Can't open \"%s\""), filename); DisplayError(buf, errno); return FALSE; } else { @@ -9657,17 +9888,17 @@ RegisterMove() } if (cmailOldMove == -1) { - DisplayError("You have edited the game history.\nUse Reload Same Game and make your move again.", 0); + DisplayError(_("You have edited the game history.\nUse Reload Same Game and make your move again."), 0); return FALSE; } if (currentMove > cmailOldMove + 1) { - DisplayError("You have entered too many moves.\nBack up to the correct position and try again.", 0); + DisplayError(_("You have entered too many moves.\nBack up to the correct position and try again."), 0); return FALSE; } if (currentMove < cmailOldMove) { - DisplayError("Displayed position is not current.\nStep forward to the correct position and try again.", 0); + DisplayError(_("Displayed position is not current.\nStep forward to the correct position and try again."), 0); return FALSE; } @@ -9715,7 +9946,7 @@ RegisterMove() cmailMoveRegistered[lastLoadGameNumber - 1] = TRUE; nCmailMovesRegistered ++; } else if (nCmailGames == 1) { - DisplayError("You have not made a move yet", 0); + DisplayError(_("You have not made a move yet"), 0); return FALSE; } @@ -9736,18 +9967,18 @@ MailMoveEvent() char *arcDir; if (! cmailMsgLoaded) { - DisplayError("The cmail message is not loaded.\nUse Reload CMail Message and make your move again.", 0); + DisplayError(_("The cmail message is not loaded.\nUse Reload CMail Message and make your move again."), 0); return; } if (nCmailGames == nCmailResults) { - DisplayError("No unfinished games", 0); + DisplayError(_("No unfinished games"), 0); return; } #if CMAIL_PROHIBIT_REMAIL if (cmailMailedMove) { - sprintf(msg, "You have already mailed a move.\nWait until a move arrives from your opponent.\nTo resend the same move, type\n\"cmail -remail -game %s\"\non the command line.", appData.cmailGameName); + sprintf(msg, _("You have already mailed a move.\nWait until a move arrives from your opponent.\nTo resend the same move, type\n\"cmail -remail -game %s\"\non the command line."), appData.cmailGameName); DisplayError(msg, 0); return; } @@ -9759,10 +9990,10 @@ MailMoveEvent() || (nCmailMovesRegistered + nCmailResults == nCmailGames)) { sprintf(string, partCommandString, appData.debugMode ? " -v" : "", appData.cmailGameName); - commandOutput = popen(string, "rb"); + commandOutput = popen(string, "r"); if (commandOutput == NULL) { - DisplayError("Failed to invoke cmail", 0); + DisplayError(_("Failed to invoke cmail"), 0); } else { for (nBuffers = 0; (! feof(commandOutput)); nBuffers ++) { nBytes = fread(buffer, 1, MSG_SIZ - 1, commandOutput); @@ -9824,7 +10055,7 @@ CmailMsg() if (!cmailMsgLoaded) return ""; if (cmailMailedMove) { - sprintf(cmailMsg, "Waiting for reply from opponent\n"); + sprintf(cmailMsg, _("Waiting for reply from opponent\n")); } else { /* Create a list of games left */ sprintf(string, "["); @@ -9847,17 +10078,17 @@ CmailMsg() switch (nCmailGames) { case 1: sprintf(cmailMsg, - "Still need to make move for game\n"); + _("Still need to make move for game\n")); break; case 2: sprintf(cmailMsg, - "Still need to make moves for both games\n"); + _("Still need to make moves for both games\n")); break; default: sprintf(cmailMsg, - "Still need to make moves for all %d games\n", + _("Still need to make moves for all %d games\n"), nCmailGames); break; } @@ -9865,21 +10096,21 @@ CmailMsg() switch (nCmailGames - nCmailMovesRegistered - nCmailResults) { case 1: sprintf(cmailMsg, - "Still need to make a move for game %s\n", + _("Still need to make a move for game %s\n"), string); break; case 0: if (nCmailResults == nCmailGames) { - sprintf(cmailMsg, "No unfinished games\n"); + sprintf(cmailMsg, _("No unfinished games\n")); } else { - sprintf(cmailMsg, "Ready to send mail\n"); + sprintf(cmailMsg, _("Ready to send mail\n")); } break; default: sprintf(cmailMsg, - "Still need to make moves for games %s\n", + _("Still need to make moves for games %s\n"), string); } } @@ -10047,9 +10278,9 @@ EditCommentEvent() char title[MSG_SIZ]; if (currentMove < 1 || parseList[currentMove - 1][0] == NULLCHAR) { - strcpy(title, "Edit comment"); + strcpy(title, _("Edit comment")); } else { - sprintf(title, "Edit comment on %d.%s%s", (currentMove - 1) / 2 + 1, + sprintf(title, _("Edit comment on %d.%s%s"), (currentMove - 1) / 2 + 1, WhiteOnMove(currentMove - 1) ? " " : ".. ", parseList[currentMove - 1]); } @@ -10073,17 +10304,19 @@ AnalyzeModeEvent() return; if (gameMode != AnalyzeFile) { - EditGameEvent(); - if (gameMode != EditGame) return; + if (!appData.icsEngineAnalyze) { + EditGameEvent(); + if (gameMode != EditGame) return; + } ResurrectChessProgram(); SendToProgram("analyze\n", &first); first.analyzing = TRUE; /*first.maybeThinking = TRUE;*/ first.maybeThinking = FALSE; /* avoid killing GNU Chess */ - AnalysisPopUp("Analysis", - "Starting analysis mode...\nIf this message stays up, your chess program does not support analysis."); + AnalysisPopUp(_("Analysis"), + _("Starting analysis mode...\nIf this message stays up, your chess program does not support analysis.")); } - gameMode = AnalyzeMode; + if (!appData.icsEngineAnalyze) gameMode = AnalyzeMode; pausing = FALSE; ModeHighlight(); SetGameInfo(); @@ -10107,8 +10340,8 @@ AnalyzeFileEvent() first.analyzing = TRUE; /*first.maybeThinking = TRUE;*/ first.maybeThinking = FALSE; /* avoid killing GNU Chess */ - AnalysisPopUp("Analysis", - "Starting analysis mode...\nIf this message stays up, your chess program does not support analysis."); + AnalysisPopUp(_("Analysis"), + _("Starting analysis mode...\nIf this message stays up, your chess program does not support analysis.")); } gameMode = AnalyzeFile; pausing = FALSE; @@ -10141,7 +10374,7 @@ MachineWhiteEvent() EditPositionDone(); if (!WhiteOnMove(currentMove)) { - DisplayError("It is not White's turn", 0); + DisplayError(_("It is not White's turn"), 0); return; } @@ -10184,6 +10417,7 @@ MachineWhiteEvent() if (appData.autoFlipView && !flipView) { flipView = !flipView; DrawPosition(FALSE, NULL); + DisplayBothClocks(); // [HGM] logo: clocks might have to be exchanged; } if(bookHit) { // [HGM] book: simulate book reply @@ -10191,7 +10425,7 @@ MachineWhiteEvent() programStats.depth = programStats.nodes = programStats.time = programStats.score = programStats.got_only_move = 0; - sprintf(programStats.movelist, "%s (xbook)", bookMove); + sprintf(programStats.movelist, "%s (xbook)", bookHit); strcpy(bookMove, "move "); strcat(bookMove, bookHit); @@ -10220,7 +10454,7 @@ MachineBlackEvent() EditPositionDone(); if (WhiteOnMove(currentMove)) { - DisplayError("It is not Black's turn", 0); + DisplayError(_("It is not Black's turn"), 0); return; } @@ -10259,13 +10493,14 @@ MachineBlackEvent() if (appData.autoFlipView && flipView) { flipView = !flipView; DrawPosition(FALSE, NULL); + DisplayBothClocks(); // [HGM] logo: clocks might have to be exchanged; } if(bookHit) { // [HGM] book: simulate book reply static char bookMove[MSG_SIZ]; // a bit generous? programStats.depth = programStats.nodes = programStats.time = programStats.score = programStats.got_only_move = 0; - sprintf(programStats.movelist, "%s (xbook)", bookMove); + sprintf(programStats.movelist, "%s (xbook)", bookHit); strcpy(bookMove, "move "); strcat(bookMove, bookHit); @@ -10312,7 +10547,7 @@ TwoMachinesEvent P((void)) case MachinePlaysWhite: case MachinePlaysBlack: if (WhiteOnMove(forwardMostMove) == (gameMode == MachinePlaysWhite)) { - DisplayError("Wait until your turn,\nor select Move Now", 0); + DisplayError(_("Wait until your turn,\nor select Move Now"), 0); return; } /* fall through */ @@ -10344,7 +10579,7 @@ TwoMachinesEvent P((void)) } else { /* kludge: allow timeout for initial "feature" command */ FreezeUI(); - DisplayMessage("", "Starting second chess program"); + DisplayMessage("", _("Starting second chess program")); ScheduleDelayedEvent(TwoMachinesEventIfReady, FEATURE_TIMEOUT); } return; @@ -10411,7 +10646,7 @@ TwoMachinesEvent P((void)) programStats.depth = programStats.nodes = programStats.time = programStats.score = programStats.got_only_move = 0; - sprintf(programStats.movelist, "%s (xbook)", bookMove); + sprintf(programStats.movelist, "%s (xbook)", bookHit); strcpy(bookMove, "move "); strcat(bookMove, bookHit); @@ -10425,7 +10660,7 @@ TrainingEvent() if (gameMode == Training) { SetTrainingModeOff(); gameMode = PlayFromGameFile; - DisplayMessage("", "Training mode off"); + DisplayMessage("", _("Training mode off")); } else { gameMode = Training; animateTraining = appData.animate; @@ -10433,10 +10668,10 @@ TrainingEvent() /* make sure we are not already at the end of the game */ if (currentMove < forwardMostMove) { SetTrainingModeOn(); - DisplayMessage("", "Training mode on"); + DisplayMessage("", _("Training mode on")); } else { gameMode = PlayFromGameFile; - DisplayError("Already at end of game", 0); + DisplayError(_("Already at end of game"), 0); } } ModeHighlight(); @@ -10517,13 +10752,13 @@ EditGameEvent() break; case IcsPlayingBlack: case IcsPlayingWhite: - DisplayError("Warning: You are still playing a game", 0); + DisplayError(_("Warning: You are still playing a game"), 0); break; case IcsObserving: - DisplayError("Warning: You are still observing a game", 0); + DisplayError(_("Warning: You are still observing a game"), 0); break; case IcsExamining: - DisplayError("Warning: You are still examining a game", 0); + DisplayError(_("Warning: You are still examining a game"), 0); break; case IcsIdle: break; @@ -10593,6 +10828,12 @@ EditPositionEvent() void ExitAnalyzeMode() { + /* [DM] icsEngineAnalyze - possible call from other functions */ + if (appData.icsEngineAnalyze) { + appData.icsEngineAnalyze = FALSE; + + DisplayMessage("",_("Close ICS engine analyze...")); + } if (first.analysisSupport && first.analyzing) { SendToProgram("exit\n", &first); first.analyzing = FALSE; @@ -10813,7 +11054,7 @@ DropMenuEvent(selection, x, y) case IcsPlayingWhite: case MachinePlaysBlack: if (!WhiteOnMove(currentMove)) { - DisplayMoveError("It is Black's turn"); + DisplayMoveError(_("It is Black's turn")); return; } moveType = WhiteDrop; @@ -10821,7 +11062,7 @@ DropMenuEvent(selection, x, y) case IcsPlayingBlack: case MachinePlaysWhite: if (WhiteOnMove(currentMove)) { - DisplayMoveError("It is White's turn"); + DisplayMoveError(_("It is White's turn")); return; } moveType = BlackDrop; @@ -10838,7 +11079,7 @@ DropMenuEvent(selection, x, y) + (int) BlackPawn - (int) WhitePawn); } if (boards[currentMove][y][x] != EmptySquare) { - DisplayMoveError("That square is occupied"); + DisplayMoveError(_("That square is occupied")); return; } @@ -10862,7 +11103,7 @@ AcceptEvent() GameEnds(GameIsDrawn, "Draw agreed", GE_PLAYER); cmailMoveType[lastLoadGameNumber - 1] = CMAIL_ACCEPT; } else { - DisplayError("There is no pending offer on this move", 0); + DisplayError(_("There is no pending offer on this move"), 0); cmailMoveType[lastLoadGameNumber - 1] = CMAIL_MOVE; } } else { @@ -10888,7 +11129,7 @@ DeclineEvent() DisplayComment(cmailOldMove - 1, "Draw declined"); #endif /*NOTDEF*/ } else { - DisplayError("There is no pending offer on this move", 0); + DisplayError(_("There is no pending offer on this move"), 0); } } else { /* Not used for offers from chess program */ @@ -10924,7 +11165,7 @@ CallFlagEvent() else GameEnds(BlackWins, "Black wins on time", GE_PLAYER); } else { - DisplayError("Your opponent is not out of time", 0); + DisplayError(_("Your opponent is not out of time"), 0); } break; case MachinePlaysBlack: @@ -10935,7 +11176,7 @@ CallFlagEvent() else GameEnds(WhiteWins, "White wins on time", GE_PLAYER); } else { - DisplayError("Your opponent is not out of time", 0); + DisplayError(_("Your opponent is not out of time"), 0); } break; } @@ -10970,7 +11211,7 @@ DrawEvent() DisplayComment(currentMove - 1, offer); cmailMoveType[lastLoadGameNumber - 1] = CMAIL_DRAW; } else { - DisplayError("You must make your move before offering a draw", 0); + DisplayError(_("You must make your move before offering a draw"), 0); cmailMoveType[lastLoadGameNumber - 1] = CMAIL_MOVE; } } else if (first.offeredDraw) { @@ -11284,11 +11525,11 @@ void RevertEvent() { if (gameMode != IcsExamining) { - DisplayError("You are not examining a game", 0); + DisplayError(_("You are not examining a game"), 0); return; } if (pausing) { - DisplayError("You can't revert while pausing", 0); + DisplayError(_("You can't revert while pausing"), 0); return; } SendToICS(ics_prefix); @@ -11302,7 +11543,7 @@ RetractMoveEvent() case MachinePlaysWhite: case MachinePlaysBlack: if (WhiteOnMove(forwardMostMove) == (gameMode == MachinePlaysWhite)) { - DisplayError("Wait until your turn,\nor select Move Now", 0); + DisplayError(_("Wait until your turn,\nor select Move Now"), 0); return; } if (forwardMostMove < 2) return; @@ -11342,14 +11583,14 @@ MoveNowEvent() switch (gameMode) { case MachinePlaysWhite: if (!WhiteOnMove(forwardMostMove)) { - DisplayError("It is your turn", 0); + DisplayError(_("It is your turn"), 0); return; } cps = &first; break; case MachinePlaysBlack: if (WhiteOnMove(forwardMostMove)) { - DisplayError("It is your turn", 0); + DisplayError(_("It is your turn"), 0); return; } cps = &first; @@ -11399,19 +11640,19 @@ HintEvent() switch (gameMode) { case MachinePlaysWhite: if (WhiteOnMove(forwardMostMove)) { - DisplayError("Wait until your turn", 0); + DisplayError(_("Wait until your turn"), 0); return; } break; case BeginningOfGame: case MachinePlaysBlack: if (!WhiteOnMove(forwardMostMove)) { - DisplayError("Wait until your turn", 0); + DisplayError(_("Wait until your turn"), 0); return; } break; default: - DisplayError("No hint available", 0); + DisplayError(_("No hint available"), 0); return; } SendToProgram("hint\n", &first); @@ -11425,14 +11666,14 @@ BookEvent() switch (gameMode) { case MachinePlaysWhite: if (WhiteOnMove(forwardMostMove)) { - DisplayError("Wait until your turn", 0); + DisplayError(_("Wait until your turn"), 0); return; } break; case BeginningOfGame: case MachinePlaysBlack: if (!WhiteOnMove(forwardMostMove)) { - DisplayError("Wait until your turn", 0); + DisplayError(_("Wait until your turn"), 0); return; } break; @@ -11814,7 +12055,7 @@ SendToProgram(message, cps) outCount = OutputToProcess(cps->pr, message, count, &error); if (outCount < count && !exiting && !endingGame) { /* [HGM] crash: to not hang GameEnds() writing to deceased engines */ - sprintf(buf, "Error writing to %s chess program", cps->which); + sprintf(buf, _("Error writing to %s chess program"), cps->which); if(gameInfo.resultDetails==NULL) { /* [HGM] crash: if game in progress, give reason for abort */ if(epStatus[forwardMostMove] <= EP_DRAWS) { gameInfo.result = GameIsDrawn; /* [HGM] accept exit as draw claim */ @@ -11844,12 +12085,12 @@ ReceiveFromProgram(isr, closure, message, count, error) if (count <= 0) { if (count == 0) { sprintf(buf, - "Error: %s chess program (%s) exited unexpectedly", + _("Error: %s chess program (%s) exited unexpectedly"), cps->which, cps->program); if(gameInfo.resultDetails==NULL) { /* [HGM] crash: if game in progress, give reason for abort */ if(epStatus[forwardMostMove] <= EP_DRAWS) { gameInfo.result = GameIsDrawn; /* [HGM] accept exit as draw claim */ - sprintf(buf, "%s program exits in draw position (%s)", cps->which, cps->program); + sprintf(buf, _("%s program exits in draw position (%s)"), cps->which, cps->program); } else { gameInfo.result = cps->twoMachinesColor[0]=='w' ? BlackWins : WhiteWins; } @@ -11859,7 +12100,7 @@ ReceiveFromProgram(isr, closure, message, count, error) DisplayFatalError(buf, 0, 1); } else { sprintf(buf, - "Error reading from %s chess program (%s)", + _("Error reading from %s chess program (%s)"), cps->which, cps->program); RemoveInputSource(cps->isr); @@ -11903,6 +12144,14 @@ ReceiveFromProgram(isr, closure, message, count, error) message); } } + + /* [DM] if icsEngineAnalyze is active we block all whisper and kibitz output, because nobody want to see this */ + if (appData.icsEngineAnalyze) { + if (strstr(message, "whisper") != NULL || + strstr(message, "kibitz") != NULL || + strstr(message, "tellics") != NULL) return; + } + HandleMachineMove(message, cps); } @@ -12082,6 +12331,55 @@ StringFeature(p, name, loc, cps) return FALSE; } +int +ParseOption(Option *opt, ChessProgramState *cps) +// [HGM] options: process the string that defines an engine option, and determine +// name, type, default value, and allowed value range +{ + char *p, *q, buf[MSG_SIZ]; + int n, min = (-1)<<31, max = 1<<31, def; + + if(p = strstr(opt->name, " -spin ")) { + if((n = sscanf(p, " -spin %d %d %d", &def, &min, &max)) < 3 ) return FALSE; + if(max < min) max = min; // enforce consistency + if(def < min) def = min; + if(def > max) def = max; + opt->value = def; + opt->min = min; + opt->max = max; + opt->type = Spin; + } else if(p = strstr(opt->name, " -string ")) { + opt->textValue = p+9; + opt->type = TextBox; + } else if(p = strstr(opt->name, " -check ")) { + if(sscanf(p, " -check %d", &def) < 1) return FALSE; + opt->value = (def != 0); + opt->type = CheckBox; + } else if(p = strstr(opt->name, " -combo ")) { + opt->textValue = (char*) (&cps->comboList[cps->comboCnt]); // cheat with pointer type + cps->comboList[cps->comboCnt++] = q = p+8; // holds possible choices + opt->value = n = 0; + while(q = StrStr(q, " /// ")) { + n++; *q = 0; // count choices, and null-terminate each of them + q += 5; + if(*q == '*') { // remember default, which is marked with * prefix + q++; + opt->value = n; + } + cps->comboList[cps->comboCnt++] = q; + } + cps->comboList[cps->comboCnt++] = NULL; + opt->max = n + 1; + opt->type = ComboBox; + } else if(p = strstr(opt->name, " -button")) { + opt->type = Button; + } else if(p = strstr(opt->name, " -save")) { + opt->type = SaveButton; + } else return FALSE; + *p = 0; // terminate option name + return TRUE; +} + void FeatureDone(cps, val) ChessProgramState* cps; @@ -12155,6 +12453,16 @@ ParseFeatures(args, cps) 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)) { + ParseOption(&(cps->option[cps->nrOptions++]), cps); // [HGM] options: add option feature + if(cps->nrOptions >= MAX_OPTIONS) { + cps->nrOptions--; + sprintf(buf, "%s engine has too many options\n", cps->which); + DisplayError(buf, 0); + } + continue; + } + if (BoolFeature(&p, "smp", &cps->maxCores, cps)) continue; /* End of additions by HGM */ /* unknown feature: complain and skip */ @@ -12330,7 +12638,8 @@ DisplayAnalysisText(text) { char buf[MSG_SIZ]; - if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) { + if (gameMode == AnalyzeMode || gameMode == AnalyzeFile + || appData.icsEngineAnalyze) { sprintf(buf, "Analysis (%s)", first.tidy); AnalysisPopUp(buf, text); } @@ -12366,8 +12675,8 @@ DisplayAnalysis() } else { safeStrCpy( lst, programStats.movelist, sizeof(lst)); - nps = (((double)programStats.nodes) / - (((double)programStats.time)/100.0)); + nps = (u64ToDouble(programStats.nodes) / + ((double)programStats.time /100.0)); cs = programStats.time % 100; s = programStats.time / 100; @@ -12378,32 +12687,32 @@ DisplayAnalysis() if (programStats.moves_left > 0 && appData.periodicUpdates) { if (programStats.move_name[0] != NULLCHAR) { - sprintf(buf, "depth=%d %d/%d(%s) %+.2f %s%s\nNodes: %lu NPS: %d\nTime: %02d:%02d:%02d.%02d", + sprintf(buf, "depth=%d %d/%d(%s) %+.2f %s%s\nNodes: " u64Display " NPS: %d\nTime: %02d:%02d:%02d.%02d", programStats.depth, programStats.nr_moves-programStats.moves_left, programStats.nr_moves, programStats.move_name, ((float)programStats.score)/100.0, lst, only_one_move(lst)? xtra[programStats.got_fail] : "", - programStats.nodes, (int)nps, h, m, s, cs); + (u64)programStats.nodes, (int)nps, h, m, s, cs); } else { - sprintf(buf, "depth=%d %d/%d %+.2f %s%s\nNodes: %lu NPS: %d\nTime: %02d:%02d:%02d.%02d", + sprintf(buf, "depth=%d %d/%d %+.2f %s%s\nNodes: " u64Display " NPS: %d\nTime: %02d:%02d:%02d.%02d", programStats.depth, programStats.nr_moves-programStats.moves_left, programStats.nr_moves, ((float)programStats.score)/100.0, lst, only_one_move(lst)? xtra[programStats.got_fail] : "", - programStats.nodes, (int)nps, h, m, s, cs); + (u64)programStats.nodes, (int)nps, h, m, s, cs); } } else { - sprintf(buf, "depth=%d %+.2f %s%s\nNodes: %lu NPS: %d\nTime: %02d:%02d:%02d.%02d", + sprintf(buf, "depth=%d %+.2f %s%s\nNodes: " u64Display " NPS: %d\nTime: %02d:%02d:%02d.%02d", programStats.depth, ((float)programStats.score)/100.0, lst, only_one_move(lst)? xtra[programStats.got_fail] : "", - programStats.nodes, (int)nps, h, m, s, cs); + (u64)programStats.nodes, (int)nps, h, m, s, cs); } } DisplayAnalysisText(buf); @@ -12488,9 +12797,9 @@ CheckFlags() } } else { if (blackFlag) { - if(gameMode != TwoMachinesPlay) DisplayTitle("Both flags fell"); + if(gameMode != TwoMachinesPlay) DisplayTitle(_("Both flags fell")); } else { - if(gameMode != TwoMachinesPlay) DisplayTitle("White's flag fell"); + if(gameMode != TwoMachinesPlay) DisplayTitle(_("White's flag fell")); if (appData.autoCallFlag) { GameEnds(BlackWins, "Black wins on time", GE_XBOARD); return TRUE; @@ -12510,9 +12819,9 @@ CheckFlags() } } else { if (whiteFlag) { - if(gameMode != TwoMachinesPlay) DisplayTitle("Both flags fell"); + if(gameMode != TwoMachinesPlay) DisplayTitle(_("Both flags fell")); } else { - if(gameMode != TwoMachinesPlay) DisplayTitle("Black's flag fell"); + if(gameMode != TwoMachinesPlay) DisplayTitle(_("Black's flag fell")); if (appData.autoCallFlag) { GameEnds(WhiteWins, "White wins on time", GE_XBOARD); return TRUE; @@ -13389,7 +13698,7 @@ EditPositionPasteFEN(char *fen) Board initial_position; if (!ParseFEN(initial_position, &blackPlaysFirst, fen)) { - DisplayError("Bad FEN position in clipboard", 0); + DisplayError(_("Bad FEN position in clipboard"), 0); return ; } else { int savedBlackPlaysFirst = blackPlaysFirst;