Merge branch 'v4.8.x'
[xboard.git] / board.c
diff --git a/board.c b/board.c
index 5c55b4f..f0cb1c6 100644 (file)
--- 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 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,23 +600,31 @@ void
 AnimateMove (Board board, int fromX, int fromY, int toX, int toY)
 {
   ChessSquare piece;
-  int hop;
+  int hop, x = toX, y = toY;
   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(killX >= 0) toX = killX, toY = killY; // [HGM] lion: first to kill square
+
+again:
+
 #if DONT_HOP
   hop = FALSE;
 #else
@@ -653,6 +662,8 @@ AnimateMove (Board board, int fromX, int fromY, int toX, int toY)
 
   /* Be sure end square is redrawn */
   damage[0][toY][toX] |= True;
+
+  if(toX != x || toY != y) { fromX = toX; fromY = toY; toX = x; toY = y; goto again; } // second leg
 }
 
 void
@@ -660,6 +671,7 @@ ChangeDragPiece (ChessSquare piece)
 {
   anims[Player].dragPiece = piece;
   SetDragPiece(Player, piece);
+  damage[0][fromY][fromX] = True;
 }
 
 void
@@ -817,6 +829,7 @@ DrawSquare (int row, int column, ChessSquare piece, int do_flash)
        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) {
@@ -1178,10 +1191,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 +1213,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 {