From: Arun Persaud Date: Sat, 9 Jan 2010 22:17:21 +0000 (-0800) Subject: Merge commit 'master-20091122' into gtk X-Git-Tag: gtk-20100118~13 X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=2dee3c0dc5b669d4e5f3464866b056a5bbca252e Merge commit 'master-20091122' into gtk Conflicts: backend.c configure.ac xboard.c xengineoutput.c xhistory.c --- 2dee3c0dc5b669d4e5f3464866b056a5bbca252e diff --cc Makefile.am index bb1a656,b9d91cb..d678c54 --- a/Makefile.am +++ b/Makefile.am @@@ -28,9 -26,9 +29,9 @@@ xboard_SOURCES = backend.c backend.h ba xhistory.c xhistory.h \ xoptions.c \ $(ZPY) -xboard_LDADD = -lm @X_PRE_LIBS@ @XAW_LIBS@ @X_LIBS@ @X_EXTRA_LIBS@ +xboard_LDADD = -lm @XAW_LIBS@ @GTK_LIBS@ - EXTRA_DIST = pixmaps bitmaps shogibitmaps \ + EXTRA_DIST = pixmaps bitmaps winboard\ xboard.texi gpl.texinfo texi2man texinfo.tex xboard.man \ COPYRIGHT FAQ.html engine-intf.html ics-parsing.txt readme.htm readme_HGM.txt zippy.README diff --cc backend.c index ce49de2,dc20c26..3223279 mode 100755,100644..100644 --- a/backend.c +++ b/backend.c @@@ -441,15 -441,12 +441,12 @@@ AppData appData Board boards[MAX_MOVES]; /* [HGM] Following 7 needed for accurate legality tests: */ - signed char epStatus[MAX_MOVES]; - signed char castlingRights[MAX_MOVES][BOARD_SIZE]; // stores files for pieces with castling rights or -1 - signed char castlingRank[BOARD_SIZE]; // and corresponding ranks - signed char initialRights[BOARD_SIZE], FENcastlingRights[BOARD_SIZE], fileRights[BOARD_SIZE]; + signed char castlingRank[BOARD_FILES]; // and corresponding ranks + signed char initialRights[BOARD_FILES]; int nrCastlingRights; // For TwoKings, or to implement castling-unknown status int initialRulePlies, FENrulePlies; - char FENepStatus; FILE *serverMoves = NULL; // next two for broadcasting (/serverMoves option) -int loadFlag = 0; +int loadFlag = 0; int shuffleOpenings; int mute; // mute all sounds @@@ -504,32 -515,32 +515,32 @@@ ChessSquare XiangqiArray[2][BOARD_FILES BlackWazir, BlackFerz, BlackAlfil, BlackKnight, BlackRook } }; - ChessSquare CapablancaArray[2][BOARD_SIZE] = { + ChessSquare CapablancaArray[2][BOARD_FILES] = { - { WhiteRook, WhiteKnight, WhiteAngel, WhiteBishop, WhiteQueen, + { WhiteRook, WhiteKnight, WhiteAngel, WhiteBishop, WhiteQueen, WhiteKing, WhiteBishop, WhiteMarshall, WhiteKnight, WhiteRook }, - { BlackRook, BlackKnight, BlackAngel, BlackBishop, BlackQueen, + { BlackRook, BlackKnight, BlackAngel, BlackBishop, BlackQueen, BlackKing, BlackBishop, BlackMarshall, BlackKnight, BlackRook } }; - ChessSquare GreatArray[2][BOARD_SIZE] = { + ChessSquare GreatArray[2][BOARD_FILES] = { - { WhiteDragon, WhiteKnight, WhiteAlfil, WhiteGrasshopper, WhiteKing, + { WhiteDragon, WhiteKnight, WhiteAlfil, WhiteGrasshopper, WhiteKing, WhiteSilver, WhiteCardinal, WhiteAlfil, WhiteKnight, WhiteDragon }, - { BlackDragon, BlackKnight, BlackAlfil, BlackGrasshopper, BlackKing, + { BlackDragon, BlackKnight, BlackAlfil, BlackGrasshopper, BlackKing, BlackSilver, BlackCardinal, BlackAlfil, BlackKnight, BlackDragon }, }; - ChessSquare JanusArray[2][BOARD_SIZE] = { + ChessSquare JanusArray[2][BOARD_FILES] = { - { WhiteRook, WhiteAngel, WhiteKnight, WhiteBishop, WhiteKing, + { WhiteRook, WhiteAngel, WhiteKnight, WhiteBishop, WhiteKing, WhiteQueen, WhiteBishop, WhiteKnight, WhiteAngel, WhiteRook }, - { BlackRook, BlackAngel, BlackKnight, BlackBishop, BlackKing, + { BlackRook, BlackAngel, BlackKnight, BlackBishop, BlackKing, BlackQueen, BlackBishop, BlackKnight, BlackAngel, BlackRook } }; #ifdef GOTHIC - ChessSquare GothicArray[2][BOARD_SIZE] = { + ChessSquare GothicArray[2][BOARD_FILES] = { - { WhiteRook, WhiteKnight, WhiteBishop, WhiteQueen, WhiteMarshall, + { WhiteRook, WhiteKnight, WhiteBishop, WhiteQueen, WhiteMarshall, WhiteKing, WhiteAngel, WhiteBishop, WhiteKnight, WhiteRook }, - { BlackRook, BlackKnight, BlackBishop, BlackQueen, BlackMarshall, + { BlackRook, BlackKnight, BlackBishop, BlackQueen, BlackMarshall, BlackKing, BlackAngel, BlackBishop, BlackKnight, BlackRook } }; #else // !GOTHIC @@@ -537,10 -548,10 +548,10 @@@ #endif // !GOTHIC #ifdef FALCON - ChessSquare FalconArray[2][BOARD_SIZE] = { + ChessSquare FalconArray[2][BOARD_FILES] = { - { WhiteRook, WhiteKnight, WhiteBishop, WhiteLance, WhiteQueen, + { WhiteRook, WhiteKnight, WhiteBishop, WhiteLance, WhiteQueen, WhiteKing, WhiteLance, WhiteBishop, WhiteKnight, WhiteRook }, - { BlackRook, BlackKnight, BlackBishop, BlackLance, BlackQueen, + { BlackRook, BlackKnight, BlackBishop, BlackLance, BlackQueen, BlackKing, BlackLance, BlackBishop, BlackKnight, BlackRook } }; #else // !FALCON @@@ -3694,27 -3707,27 +3706,27 @@@ ParseBoard12(string if(gameInfo.variant == VariantKnightmate) { wKing = WhiteUnicorn; bKing = BlackUnicorn; } for(k=BOARD_LEFT; k>1; - castlingRights[0][3] = initialRights[3] = BOARD_RGHT-1; - castlingRights[0][4] = initialRights[4] = BOARD_LEFT; - castlingRights[0][5] = initialRights[5] =(BOARD_WIDTH-1)>>1; + initialPosition[CASTLING][0] = initialRights[0] = BOARD_RGHT-1; + initialPosition[CASTLING][1] = initialRights[1] = BOARD_LEFT; + initialPosition[CASTLING][2] = initialRights[2] =(BOARD_WIDTH-1)>>1; + initialPosition[CASTLING][3] = initialRights[3] = BOARD_RGHT-1; + initialPosition[CASTLING][4] = initialRights[4] = BOARD_LEFT; + initialPosition[CASTLING][5] = initialRights[5] =(BOARD_WIDTH-1)>>1; break; case VariantFalcon: pieces = FalconArray; @@@ -4806,13 -4820,13 +4818,12 @@@ /* This sets default castling rights from none to normal corners */ /* Variants with other castling rights must set them themselves above */ nrCastlingRights = 6; - - castlingRights[0][0] = initialRights[0] = BOARD_RGHT-1; - castlingRights[0][1] = initialRights[1] = BOARD_LEFT; - castlingRights[0][2] = initialRights[2] = BOARD_WIDTH>>1; - castlingRights[0][3] = initialRights[3] = BOARD_RGHT-1; - castlingRights[0][4] = initialRights[4] = BOARD_LEFT; - castlingRights[0][5] = initialRights[5] = BOARD_WIDTH>>1; - + initialPosition[CASTLING][0] = initialRights[0] = BOARD_RGHT-1; + initialPosition[CASTLING][1] = initialRights[1] = BOARD_LEFT; + initialPosition[CASTLING][2] = initialRights[2] = BOARD_WIDTH>>1; + initialPosition[CASTLING][3] = initialRights[3] = BOARD_RGHT-1; + initialPosition[CASTLING][4] = initialRights[4] = BOARD_LEFT; + initialPosition[CASTLING][5] = initialRights[5] = BOARD_WIDTH>>1; } if(gameInfo.variant == VariantSuper) Prelude(initialPosition); @@@ -5297,10 -5303,9 +5302,9 @@@ UserMoveTest(fromX, fromY, toX, toY, pr } userOfferedDraw = FALSE; - + /* [HGM] always test for legality, to get promotion info */ moveType = LegalityTest(boards[currentMove], PosFlags(currentMove), - epStatus[currentMove], castlingRights[currentMove], fromY, fromX, toY, toX, promoChar); /* [HGM] but possibly ignore an IllegalMove result */ if (appData.testLegality) { @@@ -5327,96 -5332,71 +5331,88 @@@ FinishMove(moveType, fromX, fromY, toX int fromX, fromY, toX, toY; /*char*/int promoChar; { - char *bookHit = 0; + char *bookHit = 0; - 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)) { - if(!boards[currentMove][k][BOARD_WIDTH-2]) return 0; - } else { - if(!boards[currentMove][BOARD_HEIGHT-1-k][1]) return 0; + 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)) + { + if(!boards[currentMove][k][BOARD_WIDTH-2]) + return 0; + } + else + { + if(!boards[currentMove][BOARD_HEIGHT-1-k][1]) + return 0; } } - - /* [HGM] kludge to avoid having to know the exact promotion - move type in caller when we know the move is a legal promotion */ - if(moveType == NormalMove && promoChar) - moveType = PromoCharToMoveType(WhiteOnMove(currentMove), promoChar); - - /* [HGM] convert drag-and-drop piece drops to standard form */ - if( (fromX == BOARD_LEFT-2 || fromX == BOARD_RGHT+1) && fromY != DROP_RANK ){ - moveType = WhiteOnMove(currentMove) ? WhiteDrop : BlackDrop; - if(appData.debugMode) fprintf(debugFP, "Drop move %d, curr=%d, x=%d,y=%d, p=%d\n", - moveType, currentMove, fromX, fromY, boards[currentMove][fromY][fromX]); - // holdings might not be sent yet in ICS play; we have to figure out which piece belongs here - if(fromX == 0) fromY = BOARD_HEIGHT-1 - fromY; // black holdings upside-down - fromX = fromX ? WhitePawn : BlackPawn; // first piece type in selected holdings - while(PieceToChar(fromX) == '.' || PieceToNumber(fromX) != fromY && fromX != (int) EmptySquare) fromX++; - fromY = DROP_RANK; + + /* [HGM] kludge to avoid having to know the exact promotion + 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] kludge to avoid having to know the exact promotion ++ move type in caller when we know the move is a legal promotion */ ++ if(moveType == NormalMove && promoChar) ++ moveType = PromoCharToMoveType(WhiteOnMove(currentMove), promoChar); ++ + /* [HGM] convert drag-and-drop piece drops to standard form */ - if( fromX == BOARD_LEFT-2 || fromX == BOARD_RGHT+1) ++ if( (fromX == BOARD_LEFT-2 || fromX == BOARD_RGHT+1) && fromY != DROP_RANK ) + { + moveType = WhiteOnMove(currentMove) ? WhiteDrop : BlackDrop; - if(appData.debugMode) - fprintf(debugFP, "Drop move %d, curr=%d, x=%d,y=%d, p=%d\n", - moveType, currentMove, fromX, fromY, boards[currentMove][fromY][fromX]); - // fromX = boards[currentMove][fromY][fromX]; ++ if(appData.debugMode) fprintf(debugFP, "Drop move %d, curr=%d, x=%d,y=%d, p=%d\n", ++ moveType, currentMove, fromX, fromY, boards[currentMove][fromY][fromX]); + // holdings might not be sent yet in ICS play; we have to figure out which piece belongs here - if(fromX == 0) - fromY = BOARD_HEIGHT-1 - fromY; // black holdings upside-down - ++ if(fromX == 0) fromY = BOARD_HEIGHT-1 - fromY; // black holdings upside-down + fromX = fromX ? WhitePawn : BlackPawn; // first piece type in selected holdings - - while(PieceToChar(fromX) == '.' || PieceToNumber(fromX) != fromY && fromX != (int) EmptySquare) - fromX++; - ++ while(PieceToChar(fromX) == '.' || PieceToNumber(fromX) != fromY && fromX != (int) EmptySquare) fromX++; + fromY = DROP_RANK; } -- - /* [HGM] The following if has been moved here from - UserMoveEvent(). Because it seemed to belong here (why not allow - piece drops in training games?), and because it can only be - performed after it is known to what we promote. */ - if (gameMode == Training) { ++ + /* [HGM] The following if has been moved here from - UserMoveEvent(). Because it seemed to belon here (why not allow ++ UserMoveEvent(). Because it seemed to belong here (why not allow + piece drops in training games?), and because it can only be + performed after it is known to what we promote. */ - if (gameMode == Training) ++ if (gameMode == Training) + { /* compare the move played on the board to the next move in the - * game. If they match, display the move and the opponent's response. + * game. If they match, display the move and the opponent's response. * If they don't match, display an error message. */ int saveAnimate; - Board testBoard; char testRights[BOARD_SIZE]; char testStatus; + Board testBoard; CopyBoard(testBoard, boards[currentMove]); - ApplyMove(fromX, fromY, toX, toY, promoChar, testBoard, testRights, &testStatus); + ApplyMove(fromX, fromY, toX, toY, promoChar, testBoard); - if (CompareBoards(testBoard, boards[currentMove+1])) { - ForwardInner(currentMove+1); + if (CompareBoards(testBoard, boards[currentMove+1])) + { + ForwardInner(currentMove+1); - /* Autoplay the opponent's response. - * if appData.animate was TRUE when Training mode was entered, - * the response will be animated. - */ - saveAnimate = appData.animate; - appData.animate = animateTraining; - ForwardInner(currentMove+1); - appData.animate = saveAnimate; - - /* check for the end of the game */ - if (currentMove >= forwardMostMove) { - gameMode = PlayFromGameFile; - ModeHighlight(); - SetTrainingModeOff(); - DisplayInformation(_("End of game")); + /* Autoplay the opponent's response. + * if appData.animate was TRUE when Training mode was entered, + * the response will be animated. + */ + saveAnimate = appData.animate; + appData.animate = animateTraining; + ForwardInner(currentMove+1); + appData.animate = saveAnimate; + + /* check for the end of the game */ + if (currentMove >= forwardMostMove) + { + gameMode = PlayFromGameFile; + ModeHighlight(); + SetTrainingModeOff(); + DisplayInformation(_("End of game")); + } + } + else + { + DisplayError(_("Incorrect move"), 0); } - } else { - DisplayError(_("Incorrect move"), 0); - } return 1; } @@@ -5438,115 -5418,92 +5434,98 @@@ MakeMove(fromX, fromY, toX, toY, promoChar); /*updates forwardMostMove*/ - if (gameMode == BeginningOfGame) { - if (appData.noChessProgram) { - gameMode = EditGame; - SetGameInfo(); - } else { - char buf[MSG_SIZ]; - gameMode = MachinePlaysBlack; - StartClocks(); - SetGameInfo(); - sprintf(buf, "%s vs. %s", gameInfo.white, gameInfo.black); - DisplayTitle(buf); - if (first.sendName) { - sprintf(buf, "name %s\n", gameInfo.white); - SendToProgram(buf, &first); - } - StartClocks(); + if (gameMode == BeginningOfGame) + { + if (appData.noChessProgram) + { + gameMode = EditGame; + SetGameInfo(); + } + else + { + char buf[MSG_SIZ]; + gameMode = MachinePlaysBlack; + StartClocks(); + SetGameInfo(); + sprintf(buf, "%s vs. %s", gameInfo.white, gameInfo.black); + DisplayTitle(buf); + if (first.sendName) + { + sprintf(buf, "name %s\n", gameInfo.white); + SendToProgram(buf, &first); + } + StartClocks(); + } + ModeHighlight(); } - if(appData.debugMode) fprintf(debugFP, "moveType 2 = %d, promochar = %x\n", moveType, promoChar); + ModeHighlight(); + } /* Relay move to ICS or chess engine */ - if (appData.icsActive) { - if (gameMode == IcsPlayingWhite || gameMode == IcsPlayingBlack || - gameMode == IcsExamining) { - SendMoveToICS(moveType, fromX, fromY, toX, toY); - ics_user_moved = 1; + if (appData.icsActive) + { + if (gameMode == IcsPlayingWhite || gameMode == IcsPlayingBlack || + gameMode == IcsExamining) + { + SendMoveToICS(moveType, fromX, fromY, toX, toY); + ics_user_moved = 1; + } } - } else { - if (first.sendTime && (gameMode == BeginningOfGame || - gameMode == MachinePlaysWhite || - gameMode == MachinePlaysBlack)) { - SendTimeRemaining(&first, gameMode != MachinePlaysBlack); - } - if (gameMode != EditGame && gameMode != PlayFromGameFile) { - // [HGM] book: if program might be playing, let it use book - bookHit = SendMoveToBookUser(forwardMostMove-1, &first, FALSE); - first.maybeThinking = TRUE; - } else SendMoveToProgram(forwardMostMove-1, &first); - if (currentMove == cmailOldMove + 1) { - cmailMoveType[lastLoadGameNumber - 1] = CMAIL_MOVE; + else + { + if (first.sendTime && (gameMode == BeginningOfGame || + gameMode == MachinePlaysWhite || + gameMode == MachinePlaysBlack)) + { + SendTimeRemaining(&first, gameMode != MachinePlaysBlack); + } + if (gameMode != EditGame && gameMode != PlayFromGameFile) + { + // [HGM] book: if program might be playing, let it use book + bookHit = SendMoveToBookUser(forwardMostMove-1, &first, FALSE); + first.maybeThinking = TRUE; + } + else + SendMoveToProgram(forwardMostMove-1, &first); + if (currentMove == cmailOldMove + 1) + { + cmailMoveType[lastLoadGameNumber - 1] = CMAIL_MOVE; + } } ShowMove(fromX, fromY, toX, toY); /*updates currentMove*/ - switch (gameMode) - switch (gameMode) { - case EditGame: - switch (MateTest(boards[currentMove], PosFlags(currentMove)) ) { - case MT_NONE: - case MT_CHECK: - break; - case MT_CHECKMATE: - case MT_STAINMATE: - if (WhiteOnMove(currentMove)) { - GameEnds(BlackWins, "Black mates", GE_PLAYER); - } else { - GameEnds(WhiteWins, "White mates", GE_PLAYER); - } ++ switch (gameMode) + { + case EditGame: - switch (MateTest(boards[currentMove], PosFlags(currentMove), - EP_UNKNOWN, castlingRights[currentMove]) ) - { - case MT_NONE: - case MT_CHECK: - break; - case MT_CHECKMATE: - case MT_STAINMATE: - if (WhiteOnMove(currentMove)) - { - GameEnds(BlackWins, "Black mates", GE_PLAYER); - } - else - { - GameEnds(WhiteWins, "White mates", GE_PLAYER); - } - break; - case MT_STALEMATE: - GameEnds(GameIsDrawn, "Stalemate", GE_PLAYER); - break; - } - break; ++ switch (MateTest(boards[currentMove], PosFlags(currentMove)) ) { ++ case MT_NONE: ++ case MT_CHECK: ++ break; + + case MachinePlaysBlack: + case MachinePlaysWhite: + /* disable certain menu options while machine is thinking */ + SetMachineThinkingEnables(); break; - case MT_STALEMATE: - GameEnds(GameIsDrawn, "Stalemate", GE_PLAYER); + + default: break; } - break; - - case MachinePlaysBlack: - case MachinePlaysWhite: - /* disable certain menu options while machine is thinking */ - SetMachineThinkingEnables(); - break; - - default: - break; - } - if(bookHit) { // [HGM] book: simulate book reply - static char bookMove[MSG_SIZ]; // a bit generous? + if(bookHit) + { // [HGM] book: simulate book reply + static char bookMove[MSG_SIZ]; // a bit generous? - programStats.nodes = programStats.depth = programStats.time = + programStats.nodes = programStats.depth = programStats.time = programStats.score = programStats.got_only_move = 0; - sprintf(programStats.movelist, "%s (xbook)", bookHit); + sprintf(programStats.movelist, "%s (xbook)", bookHit); + + strcpy(bookMove, "move "); + strcat(bookMove, bookHit); + HandleMachineMove(bookMove, &first); + } - strcpy(bookMove, "move "); - strcat(bookMove, bookHit); - HandleMachineMove(bookMove, &first); - } return 1; } @@@ -6363,9 -6317,9 +6339,9 @@@ if(appData.debugMode) fprintf(debugFP, /* if we hit starting position, add initial plies */ if( count == backwardMostMove ) count -= initialRulePlies; - count = forwardMostMove - count; + count = forwardMostMove - count; if( count >= 100) - epStatus[forwardMostMove] = EP_RULE_DRAW; + boards[forwardMostMove][EP_STATUS] = 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 @@@ -6499,11 -6453,8 +6475,8 @@@ Reset(TRUE, FALSE); CopyBoard(boards[0], initial_position); initialRulePlies = FENrulePlies; - epStatus[0] = FENepStatus; - for( i=0; iBOARD_LEFT && board[toY][toX-1] == BlackPawn && gameInfo.variant != VariantBerolina || toX < fromX) - *ep = toX | berolina; + board[EP_STATUS] = toX | berolina; if(toX fromX) - *ep = toX; - gameInfo.variant != VariantBerolina || toX > fromX) - board[EP_STATUS] = toX; ++ gameInfo.variant != VariantBerolina || toX > fromX) ++ board[EP_STATUS] = toX; } - } else + } else if( board[fromY][fromX] == BlackPawn ) { if(fromY != toY) // [HGM] Xiangqi sideway Pawn moves should not count as 50-move breakers - *ep = EP_PAWN_MOVE; + board[EP_STATUS] = EP_PAWN_MOVE; if( toY-fromY== -2) { if(toX>BOARD_LEFT && board[toY][toX-1] == WhitePawn && gameInfo.variant != VariantBerolina || toX < fromX) @@@ -8712,17 -8642,12 +8677,12 @@@ LoadGameOneMove(readAhead done = FALSE; switch (moveType) { case Comment: - if (appData.debugMode) + if (appData.debugMode) fprintf(debugFP, "Parsed Comment: %s\n", yy_text); p = yy_text; - if (*p == '{' || *p == '[' || *p == '(') { - p[strlen(p) - 1] = NULLCHAR; - p++; - } /* append the comment but don't display it */ - while (*p == '\n') p++; - AppendComment(currentMove, p); + AppendComment(currentMove, p, FALSE); return TRUE; case WhiteCapturesEnPassant: @@@ -9005,9 -8927,8 +8963,7 @@@ MakeRegisteredMove( promoChar = cmailMove[lastLoadGameNumber - 1][4]; MakeMove(fromX, fromY, toX, toY, promoChar); ShowMove(fromX, fromY, toX, toY); - - switch (MateTest(boards[currentMove], PosFlags(currentMove), - EP_UNKNOWN, castlingRights[currentMove]) ) { - + switch (MateTest(boards[currentMove], PosFlags(currentMove)) ) { case MT_NONE: case MT_CHECK: break; @@@ -9411,15 -9312,10 +9366,10 @@@ LoadGame(f, gameNumber, title, useList /* Handle comments interspersed among the tags */ while (cm == Comment) { char *p; - if (appData.debugMode) + if (appData.debugMode) fprintf(debugFP, "Parsed Comment: %s\n", yy_text); p = yy_text; - if (*p == '{' || *p == '[' || *p == '(') { - p[strlen(p) - 1] = NULLCHAR; - p++; - } - while (*p == '\n') p++; - AppendComment(currentMove, p); + AppendComment(currentMove, p, FALSE); yyboardindex = forwardMostMove; cm = (ChessMove) yylex(); } @@@ -9517,15 -9413,10 +9467,10 @@@ while (cm == Comment) { char *p; - if (appData.debugMode) + if (appData.debugMode) fprintf(debugFP, "Parsed Comment: %s\n", yy_text); p = yy_text; - if (*p == '{' || *p == '[' || *p == '(') { - p[strlen(p) - 1] = NULLCHAR; - p++; - } - while (*p == '\n') p++; - AppendComment(currentMove, p); + AppendComment(currentMove, p, FALSE); yyboardindex = forwardMostMove; cm = (ChessMove) yylex(); } @@@ -10209,10 -10086,11 +10140,10 @@@ SavePosition(f, dummy, dummy2 { time_t tm; char *fen; - - + if (gameMode == EditPosition) EditPositionDone(TRUE); if (appData.oldSaveStyle) { tm = time((time_t *) NULL); - + fprintf(f, "# %s position file -- %s", programName, ctime(&tm)); PrintOpponents(f); fprintf(f, "[--------------\n"); @@@ -11912,9 -11789,9 +11842,9 @@@ voi ToStartEvent() { if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) { - /* to optimze, we temporarily turn off analysis mode while we undo + /* to optimize, we temporarily turn off analysis mode while we undo * all the moves. Otherwise we get analysis output after each undo. - */ + */ if (first.analysisSupport) { SendToProgram("exit\nforce\n", &first); first.analyzing = FALSE; @@@ -13010,10 -12933,10 +12986,10 @@@ ShowThinkingEvent( int newState = appData.showThinking // [HGM] thinking: other features now need thinking output as well || !appData.hideThinkingFromHuman || appData.adjudicateLossThreshold != 0 || EngineOutputIsUp(); - + if (oldState == newState) return; oldState = newState; - if (gameMode == EditPosition) EditPositionDone(); + if (gameMode == EditPosition) EditPositionDone(TRUE); if (oldState) { SendToProgram("post\n", &first); if (gameMode == TwoMachinesPlay) { @@@ -14061,9 -13994,9 +14046,9 @@@ ParseFEN(board, blackPlaysFirst, fen /* read e.p. field in games that know e.p. capture */ if(gameInfo.variant != VariantShogi && gameInfo.variant != VariantXiangqi && - gameInfo.variant != VariantShatranj && gameInfo.variant != VariantCourier ) { + gameInfo.variant != VariantShatranj && gameInfo.variant != VariantCourier ) { if(*p=='-') { - p++; FENepStatus = EP_NONE; + p++; board[EP_STATUS] = EP_NONE; } else { char c = *p++ - AAA; diff --cc xboard.c index 1665f4c,b18b24b..a3fda95 --- a/xboard.c +++ b/xboard.c @@@ -350,8 -462,10 +347,12 @@@ Pixmap iconPixmap, wIconPixmap, bIconPi Widget shellWidget, layoutWidget, formWidget, boardWidget, messageWidget, whiteTimerWidget, blackTimerWidget, titleWidget, widgetList[16], commentShell, promotionShell, whitePieceMenu, blackPieceMenu, dropMenu, - menuBarWidget, buttonBarWidget, editShell, errorShell, analysisShell, + menuBarWidget, editShell, errorShell, analysisShell, ICSInputShell, fileNameShell, askQuestionShell; -XSegment gridSegments[BOARD_RANKS + BOARD_FILES + 2]; -XSegment jailGridSegments[BOARD_RANKS + BOARD_FILES + 6]; ++ ++//XSegment gridSegments[BOARD_RANKS + BOARD_FILES + 2]; ++//XSegment jailGridSegments[BOARD_RANKS + BOARD_FILES + 6]; ++ Font clockFontID, coordFontID, countFontID; XFontStruct *clockFontStruct, *coordFontStruct, *countFontStruct; XtAppContext appContext; @@@ -2776,7 -3302,26 +2777,21 @@@ ResetFrontEnd( return; } -typedef struct { - char *name; - Boolean value; -} Enables; - void + GreyRevert(grey) + Boolean grey; + { + Widget w; + if (!menuBarWidget) return; + w = XtNameToWidget(menuBarWidget, "menuStep.Revert"); + if (w == NULL) { + DisplayError("menuStep.Revert", 0); + } else { + XtSetSensitive(w, !grey); + } + } + + void SetMenuEnables(enab) Enables *enab; { diff --cc xhistory.c index 1a29626,6f94e62..2b861eb --- a/xhistory.c +++ b/xhistory.c @@@ -59,18 -76,41 +59,20 @@@ extern char *getenv() # define N_(s) s #endif -#define _LL_ 100 - -extern Widget formWidget, shellWidget, boardWidget, menuBarWidget; -extern Display *xDisplay; -extern int squareSize; -extern Pixmap xMarkPixmap; -extern char *layoutName; - -struct History{ - String *Nr,*white,*black; - int aNr; /* space actually alocated */ - Widget mvn,mvw,mvb,vbox,viewport,sh; - char Up; -}; +extern GtkWidget *GUI_History; +extern GtkListStore *LIST_MoveHistory; -struct History *hist=0; String dots=" ... "; + Position gameHistoryX, gameHistoryY; + Dimension gameHistoryW; void -HistoryPopDown(w, client_data, call_data) - Widget w; - XtPointer client_data, call_data; +HistoryPopDown(object, user_data) + GtkObject *object; + gpointer user_data; { - Arg args[16]; - int j; - if(hist) { - XtPopdown(hist->sh); - hist->Up=False; - } - j=0; - XtSetArg(args[j], XtNleftBitmap, None); j++; - XtSetValues(XtNameToWidget(menuBarWidget, "menuMode.Show Move History"), - args, j); + gtk_widget_hide (GUI_History); + return; } void HistoryMoveProc(Widget w, XtPointer closure, XtPointer call_data) @@@ -171,8 -275,140 +173,139 @@@ void HistoryCreate( Left: BackwardProc() \n \ Down: ForwardProc() \n \ Right: ForwardProc() \n"; - /*--- allocate memory for move-strings ---*/ - HistoryAlloc(_LL_); + return; + /*-------- create the widgets ---------------*/ - j = 0; - XtSetArg(args[j], XtNresizable, True); j++; - XtSetArg(args[j], XtNallowShellResize, True); j++; -#if TOPLEVEL - hist->sh = - XtCreatePopupShell(_("Move list"), topLevelShellWidgetClass, - shellWidget, args, j); -#else - hist->sh = - XtCreatePopupShell(_("Move list"), transientShellWidgetClass, - shellWidget, args, j); -#endif - j = 0; - XtSetArg(args[j], XtNborderWidth, 0); j++; - XtSetArg(args[j], XtNdefaultDistance, 0); j++; - layout = - XtCreateManagedWidget(layoutName, formWidgetClass, hist->sh, - args, j); - - j = 0; - XtSetArg(args[j], XtNborderWidth, 0); j++; - XtSetArg(args[j], XtNresizable, True); j++; - - form = - XtCreateManagedWidget("form", formWidgetClass, layout, args, j); - j=0; - - j = 0; - - XtSetArg(args[j], XtNtop, XtChainTop); j++; - XtSetArg(args[j], XtNbottom, XtChainBottom); j++; - XtSetArg(args[j], XtNleft, XtChainLeft); j++; - XtSetArg(args[j], XtNright, XtChainRight); j++; - - XtSetArg(args[j], XtNborderWidth, 1); j++; - XtSetArg(args[j], XtNresizable, False); j++; - XtSetArg(args[j], XtNallowVert, True); j++; - XtSetArg(args[j], XtNallowHoriz, True); j++; - XtSetArg(args[j], XtNforceBars, False); j++; - XtSetArg(args[j], XtNheight, 280); j++; - hist->viewport = - XtCreateManagedWidget("viewport", viewportWidgetClass, - form, args, j); - j=0; - XtSetArg(args[j], XtNborderWidth, 0); j++; - XtSetArg(args[j], XtNorientation,XtorientHorizontal);j++; - hist->vbox = - XtCreateManagedWidget("vbox", formWidgetClass, hist->viewport, args, j); - - j=0; - XtSetArg(args[j], XtNtop, XtChainTop); j++; - XtSetArg(args[j], XtNbottom, XtChainTop); j++; - XtSetArg(args[j], XtNleft, XtChainLeft); j++; - XtSetArg(args[j], XtNright, XtChainLeft); j++; - - XtSetArg(args[j], XtNdefaultColumns, 1); j++; - XtSetArg(args[j], XtNforceColumns, True); j++; - XtSetArg(args[j], XtNverticalList, True); j++; - XtSetArg(args[j], XtNborderWidth, 0); j++; - XtSetArg(args[j], XtNresizable,True);j++; - XtSetArg(args[j], XtNleft, XtChainLeft); j++; - hist->mvn = XtCreateManagedWidget("movesn", listWidgetClass, - hist->vbox, args, j); - XtAddCallback(hist->mvn, XtNcallback, HistoryMoveProc, (XtPointer) hist); - - j=0; - XtSetArg(args[j], XtNtop, XtChainTop); j++; - XtSetArg(args[j], XtNbottom, XtChainTop); j++; - XtSetArg(args[j], XtNleft, XtChainLeft); j++; - XtSetArg(args[j], XtNright, XtRubber); j++; - - XtSetArg(args[j], XtNdefaultColumns, 1); j++; - XtSetArg(args[j], XtNforceColumns, True); j++; - XtSetArg(args[j], XtNverticalList, True); j++; - XtSetArg(args[j], XtNborderWidth, 0); j++; - XtSetArg(args[j], XtNresizable,True);j++; - XtSetArg(args[j], XtNfromHoriz, hist->mvn); j++; - hist->mvw = XtCreateManagedWidget("movesw", listWidgetClass, - hist->vbox, args, j); - XtAddCallback(hist->mvw, XtNcallback, HistoryMoveProc, (XtPointer) hist); - - j=0; - XtSetArg(args[j], XtNtop, XtChainTop); j++; - XtSetArg(args[j], XtNbottom, XtChainTop); j++; - XtSetArg(args[j], XtNleft, XtRubber); j++; - XtSetArg(args[j], XtNright, XtRubber); j++; - - XtSetArg(args[j], XtNdefaultColumns, 1); j++; - XtSetArg(args[j], XtNforceColumns, True); j++; - XtSetArg(args[j], XtNverticalList, True); j++; - XtSetArg(args[j], XtNborderWidth, 0); j++; - XtSetArg(args[j], XtNresizable,True);j++; - XtSetArg(args[j], XtNfromHoriz, hist->mvw); j++; - hist->mvb = XtCreateManagedWidget("movesb", listWidgetClass, - hist->vbox, args, j); - XtAddCallback(hist->mvb, XtNcallback, HistoryMoveProc, (XtPointer) hist); - - j=0; - XtSetArg(args[j], XtNbottom, XtChainBottom); j++; - XtSetArg(args[j], XtNtop, XtChainBottom); j++; - XtSetArg(args[j], XtNleft, XtChainLeft); j++; - XtSetArg(args[j], XtNright, XtChainLeft); j++; - XtSetArg(args[j], XtNfromVert, hist->viewport); j++; - b_close= XtCreateManagedWidget(_("Close"), commandWidgetClass, - form, args, j); - XtAddCallback(b_close, XtNcallback, HistoryPopDown, (XtPointer) 0); - - XtAugmentTranslations(hist->sh,XtParseTranslationTable (trstr)); - - XtRealizeWidget(hist->sh); - CatchDeleteWindow(hist->sh, "HistoryPopDown"); - - for(i=1;iaNr;i++){ - strcpy(hist->white[i],dots); - strcpy(hist->black[i],""); - } - - // [HGM] restore old position - j = 0; - XtSetArg(args[j], XtNx, &gameHistoryX); j++; - XtSetArg(args[j], XtNy, &gameHistoryY); j++; - XtSetArg(args[j], XtNwidth, &gameHistoryW); j++; - XtGetValues(shellWidget, args, j); - j = 0; - XtSetArg(args[j], XtNx, gameHistoryX + gameHistoryW); j++; - XtSetArg(args[j], XtNy, gameHistoryY); j++; - XtSetValues(hist->sh, args, j); - XtRealizeWidget(hist->sh); - - return hist->sh; ++// j = 0; ++// XtSetArg(args[j], XtNresizable, True); j++; ++// XtSetArg(args[j], XtNallowShellResize, True); j++; ++//#if TOPLEVEL ++// hist->sh = ++// XtCreatePopupShell(_("Move list"), topLevelShellWidgetClass, ++// shellWidget, args, j); ++//#else ++// hist->sh = ++// XtCreatePopupShell(_("Move list"), transientShellWidgetClass, ++// shellWidget, args, j); ++//#endif ++// j = 0; ++// XtSetArg(args[j], XtNborderWidth, 0); j++; ++// XtSetArg(args[j], XtNdefaultDistance, 0); j++; ++// layout = ++// XtCreateManagedWidget(layoutName, formWidgetClass, hist->sh, ++// args, j); ++// ++// j = 0; ++// XtSetArg(args[j], XtNborderWidth, 0); j++; ++// XtSetArg(args[j], XtNresizable, True); j++; ++// ++// form = ++// XtCreateManagedWidget("form", formWidgetClass, layout, args, j); ++// j=0; ++// ++// j = 0; ++// ++// XtSetArg(args[j], XtNtop, XtChainTop); j++; ++// XtSetArg(args[j], XtNbottom, XtChainBottom); j++; ++// XtSetArg(args[j], XtNleft, XtChainLeft); j++; ++// XtSetArg(args[j], XtNright, XtChainRight); j++; ++// ++// XtSetArg(args[j], XtNborderWidth, 1); j++; ++// XtSetArg(args[j], XtNresizable, False); j++; ++// XtSetArg(args[j], XtNallowVert, True); j++; ++// XtSetArg(args[j], XtNallowHoriz, True); j++; ++// XtSetArg(args[j], XtNforceBars, False); j++; ++// XtSetArg(args[j], XtNheight, 280); j++; ++// hist->viewport = ++// XtCreateManagedWidget("viewport", viewportWidgetClass, ++// form, args, j); ++// j=0; ++// XtSetArg(args[j], XtNborderWidth, 0); j++; ++// XtSetArg(args[j], XtNorientation,XtorientHorizontal);j++; ++// hist->vbox = ++// XtCreateManagedWidget("vbox", formWidgetClass, hist->viewport, args, j); ++// ++// j=0; ++// XtSetArg(args[j], XtNtop, XtChainTop); j++; ++// XtSetArg(args[j], XtNbottom, XtChainTop); j++; ++// XtSetArg(args[j], XtNleft, XtChainLeft); j++; ++// XtSetArg(args[j], XtNright, XtChainLeft); j++; ++// ++// XtSetArg(args[j], XtNdefaultColumns, 1); j++; ++// XtSetArg(args[j], XtNforceColumns, True); j++; ++// XtSetArg(args[j], XtNverticalList, True); j++; ++// XtSetArg(args[j], XtNborderWidth, 0); j++; ++// XtSetArg(args[j], XtNresizable,True);j++; ++// XtSetArg(args[j], XtNleft, XtChainLeft); j++; ++// hist->mvn = XtCreateManagedWidget("movesn", listWidgetClass, ++// hist->vbox, args, j); ++// XtAddCallback(hist->mvn, XtNcallback, HistoryMoveProc, (XtPointer) hist); ++// ++// j=0; ++// XtSetArg(args[j], XtNtop, XtChainTop); j++; ++// XtSetArg(args[j], XtNbottom, XtChainTop); j++; ++// XtSetArg(args[j], XtNleft, XtChainLeft); j++; ++// XtSetArg(args[j], XtNright, XtRubber); j++; ++// ++// XtSetArg(args[j], XtNdefaultColumns, 1); j++; ++// XtSetArg(args[j], XtNforceColumns, True); j++; ++// XtSetArg(args[j], XtNverticalList, True); j++; ++// XtSetArg(args[j], XtNborderWidth, 0); j++; ++// XtSetArg(args[j], XtNresizable,True);j++; ++// XtSetArg(args[j], XtNfromHoriz, hist->mvn); j++; ++// hist->mvw = XtCreateManagedWidget("movesw", listWidgetClass, ++// hist->vbox, args, j); ++// XtAddCallback(hist->mvw, XtNcallback, HistoryMoveProc, (XtPointer) hist); ++// ++// j=0; ++// XtSetArg(args[j], XtNtop, XtChainTop); j++; ++// XtSetArg(args[j], XtNbottom, XtChainTop); j++; ++// XtSetArg(args[j], XtNleft, XtRubber); j++; ++// XtSetArg(args[j], XtNright, XtRubber); j++; ++// ++// XtSetArg(args[j], XtNdefaultColumns, 1); j++; ++// XtSetArg(args[j], XtNforceColumns, True); j++; ++// XtSetArg(args[j], XtNverticalList, True); j++; ++// XtSetArg(args[j], XtNborderWidth, 0); j++; ++// XtSetArg(args[j], XtNresizable,True);j++; ++// XtSetArg(args[j], XtNfromHoriz, hist->mvw); j++; ++// hist->mvb = XtCreateManagedWidget("movesb", listWidgetClass, ++// hist->vbox, args, j); ++// XtAddCallback(hist->mvb, XtNcallback, HistoryMoveProc, (XtPointer) hist); ++// ++// j=0; ++// XtSetArg(args[j], XtNbottom, XtChainBottom); j++; ++// XtSetArg(args[j], XtNtop, XtChainBottom); j++; ++// XtSetArg(args[j], XtNleft, XtChainLeft); j++; ++// XtSetArg(args[j], XtNright, XtChainLeft); j++; ++// XtSetArg(args[j], XtNfromVert, hist->viewport); j++; ++// b_close= XtCreateManagedWidget(_("Close"), commandWidgetClass, ++// form, args, j); ++// XtAddCallback(b_close, XtNcallback, HistoryPopDown, (XtPointer) 0); ++// ++// XtAugmentTranslations(hist->sh,XtParseTranslationTable (trstr)); ++// ++// XtRealizeWidget(hist->sh); ++// CatchDeleteWindow(hist->sh, "HistoryPopDown"); ++// ++// for(i=1;iaNr;i++){ ++// strcpy(hist->white[i],dots); ++// strcpy(hist->black[i],""); ++// } ++// ++// // [HGM] restore old position ++// j = 0; ++// XtSetArg(args[j], XtNx, &gameHistoryX); j++; ++// XtSetArg(args[j], XtNy, &gameHistoryY); j++; ++// XtSetArg(args[j], XtNwidth, &gameHistoryW); j++; ++// XtGetValues(shellWidget, args, j); ++// j = 0; ++// XtSetArg(args[j], XtNx, gameHistoryX + gameHistoryW); j++; ++// XtSetArg(args[j], XtNy, gameHistoryY); j++; ++// XtSetValues(hist->sh, args, j); ++// XtRealizeWidget(hist->sh); ++// ++// return hist->sh; } void