X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=board.c;h=ff5a7f2e428890e3aeea8b00fd0d9beacabf9add;hb=d52a42f3f58c509d66ea3ce1bfa22866cc86bb54;hp=e8111dd26a5cfd4fce257411728157ba17bb3c0a;hpb=6797bd9f6f43a4121ee3385a8571158c294a57d6;p=xboard.git diff --git a/board.c b/board.c index e8111dd..ff5a7f2 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, 2013, 2014, 2015 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: @@ -599,7 +600,7 @@ void AnimateMove (Board board, int fromX, int fromY, int toX, int toY) { ChessSquare piece; - int hop, x = toX, y = toY; + int hop, x = toX, y = toY, x2 = kill2X; Pnt start, finish, mid; Pnt frames[kFactor * 2 + 1]; int nFrames, startColor, endColor; @@ -620,6 +621,7 @@ AnimateMove (Board board, int fromX, int fromY, int toX, int toY) 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: @@ -662,6 +664,7 @@ again: /* 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 } @@ -1187,13 +1190,20 @@ DrawArrowBetweenPoints (int s_x, int s_y, int d_x, int d_y) static void 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; + int hor, vert, i, n = partnerUp * twoBoards, delta = abs(d_row - s_row); + + if( 2*(d_row - s_row) > abs(d_col - s_col) ) d_row = 4*d_row + 1; else + if( 2*(s_row - d_row) > abs(d_col - s_col) ) d_row = 4*d_row + 3; else d_row = 4*d_row + 2; + if( 2*(d_col - s_col) > delta ) d_col = 4*d_col + 1; else + if( 2*(s_col - d_col) > delta ) d_col = 4*d_col + 3; else d_col = 4*d_col + 2; + s_row = 4*s_row + 2; s_col = 4*s_col + 2; + + hor = 64*s_col; vert = 64*s_row; 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+30>>8][hor+30>>8] |= 2; + damage[n][vert-30>>8][hor+30>>8] |= 2; + damage[n][vert+30>>8][hor-30>>8] |= 2; + damage[n][vert-30>>8][hor-30>>8] |= 2; hor += d_col - s_col; vert += d_row - s_row; } } @@ -1202,7 +1212,7 @@ ArrowDamage (int s_col, int s_row, int d_col, int d_row) static void DrawArrowBetweenSquares (int s_col, int s_row, int d_col, int d_row) { - int s_x, s_y, d_x, d_y; + int s_x, s_y, d_x, d_y, delta_y; if( s_col == d_col && s_row == d_row ) { return; @@ -1211,21 +1221,22 @@ DrawArrowBetweenSquares (int s_col, int s_row, int d_col, int d_row) /* Get source and destination points */ SquareToPos( s_row, s_col, &s_x, &s_y); SquareToPos( d_row, d_col, &d_x, &d_y); + delta_y = abs(d_y - s_y); - if( d_y > s_y ) { + if( d_y > s_y && 2*(d_y - s_y) > abs(d_x - s_x)) { 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 && 2*(s_y - d_y) > abs(d_x - s_x)) { d_y += squareSize / 2 + squareSize / 4; } else { d_y += squareSize / 2; } - if( d_x > s_x ) { + if( d_x > s_x && 2*(d_x - s_x) > delta_y) { d_x += squareSize / 2 - squareSize / 4; } - else if( d_x < s_x ) { + else if( d_x < s_x && 2*(s_x - d_x) > delta_y) { d_x += squareSize / 2 + squareSize / 4; } else {