Fix multi-leg promotions
[xboard.git] / board.c
diff --git a/board.c b/board.c
index cb6ae94..a0ce36e 100644 (file)
--- a/board.c
+++ b/board.c
@@ -194,7 +194,7 @@ SetPremoveHighlights (int fromX, int fromY, int toX, int toY)
     }
     if (pm2X != toX || pm2Y != toY) {
        if (pm2X >= 0 && pm2Y >= 0) {
-           damage[0][pm1Y][pm1X] |= 2;
+           damage[0][pm2Y][pm2X] |= 2;
        }
     }
     pm1X = fromX;
@@ -749,7 +749,7 @@ DragPieceBegin (int x, int y, Boolean instantly)
        /* Mark this square as needing to be redrawn. Note that
           we don't remove the piece though, since logically (ie
           as seen by opponent) the move hasn't been made yet. */
-       damage[0][boardY][boardX] = True;
+       damage[0][boardY][boardX] |= True;
     } else {
        anims[Player].dragActive = False;
     }
@@ -770,7 +770,7 @@ DrawDragPiece ()
   DrawOneSquare(anims[Player].startSquare.x, anims[Player].startSquare.y,
                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;
+  damage[0][anims[Player].startBoardY][anims[Player].startBoardX] |= TRUE;
 }
 
 static void
@@ -821,9 +821,11 @@ DrawSquare (int row, int column, ChessSquare piece, int do_flash)
        for (i=0; i<appData.flashCount; ++i) {
            DrawOneSquare(x, y, piece, square_color, 0, tString, bString, 0);
            GraphExpose(currBoard, x, y, squareSize, squareSize);
+           DoEvents(); // requires event processing to actually update screen :-(
            FlashDelay(flash_delay);
            DrawOneSquare(x, y, EmptySquare, square_color, 0, tString, bString, 0);
            GraphExpose(currBoard, x, y, squareSize, squareSize);
+           DoEvents();
            FlashDelay(flash_delay);
        }
     }
@@ -950,8 +952,10 @@ DrawPosition (int repaint, Board board)
        /* Special check for castling so we don't flash both the king
           and the rook (just flash the king). */
        if (do_flash) {
-           /* Mark rook for drawing with NO flashing. */
-           check_castle_draw(board, lastBoard[nr], &rrow, &rcol);
+           if(check_castle_draw(board, lastBoard[nr], &rrow, &rcol)) {
+               /* Mark rook for drawing with NO flashing. */
+               damage[nr][rrow][rcol] |= 1;
+           }
        }
 
        /* First pass -- Erase arrow and grid highlights, but keep square content unchanged. Except for new markers. */
@@ -961,7 +965,7 @@ DrawPosition (int repaint, Board board)
                DrawSquare(i, j, board[i][j], 0);
                if(lineGap && damage[nr][i][j] & 2) {
                    drawHighlight(j, i, 0);
-                   SquareExpose(i, j, 1);
+                   SquareExpose(i, j, lineGap);
                } else SquareExpose(i, j, 0);
                damage[nr][i][j] = 0;
            }
@@ -1039,7 +1043,7 @@ DrawPosition (int repaint, Board board)
                        SquareExpose(i, j, lineGap);
                    else
                        SquareExpose(i, j, 0);
-                   damage[nr][i][j] = 0;
+                   if(nr == 0) damage[nr][i][j] = 0; // on auxiliary board we retain arrow damage
                }
     }
 
@@ -1048,10 +1052,19 @@ DrawPosition (int repaint, Board board)
     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);
+       if(repaint && SubtractTimeMarks(&now, &programStartTime) < 1000) {
+           char *p = appData.message, *q;
+           i = 0;
+           while(*p) {
+               q = strchr(p, '\n');
+               if(q) *q = NULLCHAR;
+               if(!strstr(appData.suppress, p)) {
+                   if(i == 0) DrawSeekBackground(2*squareSize, 3*squareSize, 6.5*squareSize, 5*squareSize);
+                   DrawText(p, 2*squareSize + 5, (int) ((3 + 0.3*i++)*squareSize) + 5, 2);
+               }
+               if(q) *q++ = '\n'; else q = "";
+               p = q;
+           }
            GraphExpose(currBoard, 2*squareSize, 3*squareSize, 4*squareSize, 2*squareSize);
            messedUp = TRUE;
        } else messedUp = FALSE;