X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=board.c;h=9bce22fbe5662b3ce357549bf11e708a370d85d9;hb=7d99a4a8766a9399180bfa6c5292e16fac70d4e4;hp=a0aa2fc79e54caf0b04df061c6033b7950c9b784;hpb=053dc1f79f78ff5d5d4d0f625f68a7d8076a30a0;p=xboard.git diff --git a/board.c b/board.c index a0aa2fc..9bce22f 100644 --- a/board.c +++ b/board.c @@ -5,7 +5,8 @@ * Massachusetts. * * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006, - * 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. + * 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Free + * Software Foundation, Inc. * * The following terms apply to Digital Equipment Corporation's copyright * interest in XBoard: @@ -163,7 +164,7 @@ SetHighlights (int fromX, int fromY, int toX, int toY) drawHighlight(hi2X, hi2Y, 0); } } - + if(arrow) // there currently is an arrow displayed ArrowDamage(hi1X, hi1Y, hi2X, hi2Y); // mark which squares it damaged @@ -599,23 +600,32 @@ void AnimateMove (Board board, int fromX, int fromY, int toX, int toY) { ChessSquare piece; - int hop; + int hop, x = toX, y = toY, x2 = kill2X; Pnt start, finish, mid; Pnt frames[kFactor * 2 + 1]; int nFrames, startColor, endColor; + if(killX >= 0 && IS_LION(board[fromY][fromX])) Roar(); + /* Are we animating? */ if (!appData.animate || appData.blindfold) return; if(board[toY][toX] == WhiteRook && board[fromY][fromX] == WhiteKing || - board[toY][toX] == BlackRook && board[fromY][fromX] == BlackKing) + board[toY][toX] == BlackRook && board[fromY][fromX] == BlackKing || + board[toY][toX] == WhiteKing && board[fromY][fromX] == WhiteRook || // [HGM] seirawan + board[toY][toX] == BlackKing && board[fromY][fromX] == BlackRook) return; // [HGM] FRC: no animtion of FRC castlings, as to-square is not true to-square if (fromY < 0 || fromX < 0 || toX < 0 || toY < 0) return; piece = board[fromY][fromX]; if (piece >= EmptySquare) return; + if(x2 >= 0) toX = kill2X, toY = kill2Y; else + if(killX >= 0) toX = killX, toY = killY; // [HGM] lion: first to kill square + +again: + #if DONT_HOP hop = FALSE; #else @@ -653,6 +663,9 @@ AnimateMove (Board board, int fromX, int fromY, int toX, int toY) /* Be sure end square is redrawn */ damage[0][toY][toX] |= True; + + if(toX == x2 && toY == kill2Y) { fromX = toX; fromY = toY; toX = killX; toY = killY; x2 = -1; goto again; } // second leg + if(toX != x || toY != y) { fromX = toX; fromY = toY; toX = x; toY = y; goto again; } // second leg } void @@ -660,6 +673,7 @@ ChangeDragPiece (ChessSquare piece) { anims[Player].dragPiece = piece; SetDragPiece(Player, piece); + damage[0][fromY][fromX] = True; } void @@ -771,7 +785,7 @@ DrawDragPiece () it's being dragged around the board. So we erase the square that the piece is on and draw it at the last known drag point. */ DrawOneSquare(anims[Player].startSquare.x, anims[Player].startSquare.y, - EmptySquare, anims[Player].startColor, 0, NULL, 0); + EmptySquare, anims[Player].startColor, 0, NULL, NULL, 0); AnimationFrame(Player, &anims[Player].prevFrame, anims[Player].dragPiece); damage[0][anims[Player].startBoardY][anims[Player].startBoardX] = TRUE; } @@ -781,7 +795,7 @@ DrawSquare (int row, int column, ChessSquare piece, int do_flash) { int square_color, x, y, align=0; int i; - char string[2]; + char tString[3], bString[2]; int flash_delay; /* Calculate delay in milliseconds (2-delays per complete flash) */ @@ -799,37 +813,38 @@ DrawSquare (int row, int column, ChessSquare piece, int do_flash) square_color = SquareColor(row, column); - string[1] = NULLCHAR; + bString[1] = bString[0] = NULLCHAR; if (appData.showCoords && row == (flipView ? BOARD_HEIGHT-1 : 0) && column >= BOARD_LEFT && column < BOARD_RGHT) { - string[0] = 'a' + column - BOARD_LEFT; + bString[0] = 'a' + column - BOARD_LEFT; align = 1; // coord in lower-right corner } if (appData.showCoords && column == (flipView ? BOARD_RGHT-1 : BOARD_LEFT)) { - string[0] = ONE + row; + snprintf(tString, 3, "%d", ONE - '0' + row); align = 2; // coord in upper-left corner } if (column == (flipView ? BOARD_LEFT-1 : BOARD_RGHT) && piece > 1 ) { - string[0] = '0' + piece; + snprintf(tString, 3, "%d", piece); align = 3; // holdings count in upper-right corner } if (column == (flipView ? BOARD_RGHT : BOARD_LEFT-1) && piece > 1) { - string[0] = '0' + piece; + snprintf(tString, 3, "%d", piece); align = 4; // holdings count in upper-left corner } + if(piece == DarkSquare) square_color = 2; if(square_color == 2 || appData.blindfold) piece = EmptySquare; if (do_flash && piece != EmptySquare && appData.flashCount > 0) { for (i=0; i= 0 && pm1Y >= 0) { drawHighlight(pm1X, pm1Y, 2); - damage[nr][pm1Y][pm1X] = False; + if(lineGap) damage[nr][pm1Y][pm1X] = False; } if (pm2X >= 0 && pm2Y >= 0) { drawHighlight(pm2X, pm2Y, 2); - damage[nr][pm2Y][pm2X] = False; + if(lineGap) damage[nr][pm2Y][pm2X] = False; } if (hi1X >= 0 && hi1Y >= 0) { drawHighlight(hi1X, hi1Y, 1); - damage[nr][hi1Y][hi1X] = False; + if(lineGap) damage[nr][hi1Y][hi1X] = False; } if (hi2X >= 0 && hi2Y >= 0) { drawHighlight(hi2X, hi2Y, 1); - damage[nr][hi2Y][hi2X] = False; + if(lineGap) damage[nr][hi2Y][hi2X] = False; } DrawArrowHighlight(hi1X, hi1Y, hi2X, hi2Y); } @@ -1029,12 +1044,12 @@ DrawPosition (int repaint, Board board) GraphExpose(currBoard, x - lineGap, y - lineGap, squareSize + 2*lineGap, squareSize + 2*lineGap); else GraphExpose(currBoard, x, y, squareSize, squareSize); - damage[nr][i][j] &= ~2; // remember damage by newly drawn error in '2' bit, to schedule it for erasure next draw + damage[nr][i][j] &= 2; // remember damage by newly drawn error in '2' bit, to schedule it for erasure next draw } } FlashDelay(0); // this flushes drawing queue; - if(nr) SwitchWindow(); + if(nr) SwitchWindow(1); } /* [AS] Arrow highlighting support */ @@ -1178,10 +1193,10 @@ ArrowDamage (int s_col, int s_row, int d_col, int d_row) int hor, vert, i, n = partnerUp * twoBoards; hor = 64*s_col + 32; vert = 64*s_row + 32; for(i=0; i<= 64; i++) { - damage[n][vert+6>>6][hor+6>>6] |= 2; - damage[n][vert-6>>6][hor+6>>6] |= 2; - damage[n][vert+6>>6][hor-6>>6] |= 2; - damage[n][vert-6>>6][hor-6>>6] |= 2; + damage[n][vert+8>>6][hor+8>>6] |= 2; + damage[n][vert-8>>6][hor+8>>6] |= 2; + damage[n][vert+8>>6][hor-8>>6] |= 2; + damage[n][vert-8>>6][hor-8>>6] |= 2; hor += d_col - s_col; vert += d_row - s_row; } } @@ -1200,20 +1215,20 @@ DrawArrowBetweenSquares (int s_col, int s_row, int d_col, int d_row) SquareToPos( s_row, s_col, &s_x, &s_y); SquareToPos( d_row, d_col, &d_x, &d_y); - if( d_y > s_y ) { + if( d_y > s_y && d_y - s_y > abs(d_x - s_x)/2) { d_y += squareSize / 2 - squareSize / 4; // [HGM] round towards same centers on all sides! } - else if( d_y < s_y ) { + else if( d_y < s_y && s_y - d_y > abs(d_x - d_y)/2) { d_y += squareSize / 2 + squareSize / 4; } else { d_y += squareSize / 2; } - if( d_x > s_x ) { + if( d_x > s_x && d_x - s_x > abs(d_y - s_y)/2) { d_x += squareSize / 2 - squareSize / 4; } - else if( d_x < s_x ) { + else if( d_x < s_x && s_x - d_x > abs(d_y - s_y)/2) { d_x += squareSize / 2 + squareSize / 4; } else { @@ -1242,5 +1257,3 @@ DrawArrowHighlight (int fromX, int fromY, int toX,int toY) if( IsDrawArrowEnabled() && fromX >= 0 && fromY >= 0 && toX >= 0 && toY >= 0) DrawArrowBetweenSquares(fromX, fromY, toX, toY); } - -