Update nl.po translation
[xboard.git] / board.c
diff --git a/board.c b/board.c
index ab3985e..a368356 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 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;
@@ -611,13 +612,16 @@ AnimateMove (Board board, int fromX, int fromY, int toX, int toY)
     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:
@@ -660,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
 }
 
@@ -668,6 +673,7 @@ ChangeDragPiece (ChessSquare piece)
 {
   anims[Player].dragPiece = piece;
   SetDragPiece(Player, piece);
+  damage[0][fromY][fromX] = True;
 }
 
 void
@@ -913,10 +919,12 @@ DrawPosition (int repaint, Board board)
     static int lastFlipView = 0;
     static int lastBoardValid[2] = {0, 0};
     static Board lastBoard[2];
-    static char lastMarker[BOARD_RANKS][BOARD_FILES];
+    static char lastMarker[BOARD_RANKS][BOARD_FILES], messedUp;
     int rrow, rcol;
     int nr = twoBoards*partnerUp;
 
+    repaint |= messedUp;
+
     if(DrawSeekGraph()) return; // [HGM] seekgraph: suppress any drawing if seek graph up
 
     if (board == NULL) {
@@ -1044,6 +1052,17 @@ DrawPosition (int repaint, Board board)
 
     FlashDelay(0); // this flushes drawing queue;
     if(nr) SwitchWindow(1);
+    else {
+       TimeMark now;
+       GetTimeMark(&now);
+       if(SubtractTimeMarks(&now, &programStartTime) < 1000) {
+           DrawSeekBackground(2*squareSize, 3*squareSize, 6*squareSize, 5*squareSize);
+           DrawText("Right-clicking dialog texts", 2*squareSize + 5, 3*squareSize + 5, 2);
+           DrawText("pops up help on them", 2*squareSize + 5, (int) (3.3*squareSize) + 5, 2);
+           GraphExpose(currBoard, 2*squareSize, 3*squareSize, 4*squareSize, 2*squareSize);
+           messedUp = TRUE;
+       } else messedUp = FALSE;
+    }
 }
 
 /* [AS] Arrow highlighting support */
@@ -1184,13 +1203,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;
     }
 }
@@ -1199,7 +1225,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;
@@ -1208,21 +1234,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 {