fixed some bugs in the animation of atomic captures
authorH.G. Muller <h.g.muller@hccnet.nl>
Tue, 16 Jun 2009 06:56:40 +0000 (23:56 -0700)
committerArun Persaud <arun@nubati.net>
Tue, 16 Jun 2009 06:56:40 +0000 (23:56 -0700)
winboard/winboard.c

index fb317b7..fe03139 100644 (file)
@@ -103,7 +103,7 @@ void DisplayHoldingsCount(HDC hdc, int x, int y, int align, int copyNumber);
 VOID NewVariantPopup(HWND hwnd);\r
 int FinishMove P((ChessMove moveType, int fromX, int fromY, int toX, int toY,\r
                   /*char*/int promoChar));\r
-void AnimateAtomicCapture(int toX, int toY, int nFrames);\r
+void AnimateAtomicCapture(int fromX, int fromY, int toX, int toY, int nFrames);\r
 \r
 typedef struct {\r
   ChessSquare piece;  \r
@@ -132,10 +132,10 @@ static HighlightInfo highlightInfo        = { {{-1, -1}, {-1, -1}} };
 static HighlightInfo premoveHighlightInfo = { {{-1, -1}, {-1, -1}} };\r
 \r
 typedef struct { // [HGM] atomic\r
-  int x, y, radius;\r
+  int fromX, fromY, toX, toY, radius;\r
 } ExplodeInfo;\r
 \r
-static ExplodeInfo explodeInfo = {0, 0, 0};\r
+static ExplodeInfo explodeInfo;\r
 \r
 /* Window class names */\r
 char szAppName[] = "WinBoard";\r
@@ -4511,7 +4511,8 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board)
   if(explodeInfo.radius) { // [HGM] atomic\r
        HBRUSH oldBrush;\r
        int x, y, r=(explodeInfo.radius * squareSize)/100;\r
-       SquareToPos(explodeInfo.y, explodeInfo.x, &x, &y);\r
+        board[explodeInfo.fromY][explodeInfo.fromX] = EmptySquare; // suppress display of capturer\r
+       SquareToPos(explodeInfo.toY, explodeInfo.toX, &x, &y);\r
        x += squareSize/2;\r
        y += squareSize/2;\r
         if(!fullrepaint) {\r
@@ -5055,7 +5056,10 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
                PromotionPopup(hwnd); /* [HGM] Popup now calls FinishMove */\r
           } else {\r
            if(saveAnimate /* ^$!%@#$!$ */  && gameInfo.variant == VariantAtomic \r
-                       && boards[currentMove][toY][toX] != EmptySquare) AnimateAtomicCapture(toX, toY, 20);\r
+                         && (boards[currentMove][toY][toX] != EmptySquare || \r
+                                       moveType == WhiteCapturesEnPassant || \r
+                                       moveType == BlackCapturesEnPassant   ) )\r
+               AnimateAtomicCapture(fromX, fromY, toX, toY, 20);\r
            FinishMove(moveType, fromX, fromY, toX, toY, NULLCHAR);\r
          }\r
       }\r
@@ -10595,13 +10599,15 @@ static void Tween( POINT * start, POINT * mid, POINT * finish, int factor,
 \r
 \r
 void\r
-AnimateAtomicCapture(int toX, int toY, int nFrames)\r
+AnimateAtomicCapture(int fromX, int fromY, int toX, int toY, int nFrames)\r
 {      // [HGM] atomic: animate blast wave\r
        int i;\r
 if(appData.debugMode) fprintf(debugFP, "exploding (%d,%d)\n", toX, toY);\r
-       explodeInfo.x = toX;\r
-       explodeInfo.y = toY;\r
-       for(i=0; i<nFrames; i++) {\r
+       explodeInfo.fromX = fromX;\r
+       explodeInfo.fromY = fromY;\r
+       explodeInfo.toX = toX;\r
+       explodeInfo.toY = toY;\r
+       for(i=1; i<nFrames; i++) {\r
            explodeInfo.radius = (i*180)/(nFrames-1);\r
            DrawPosition(FALSE, NULL);\r
            Sleep(appData.animSpeed);\r
@@ -10670,8 +10676,9 @@ AnimateMove(board, fromX, fromY, toX, toY)
   animInfo.pos = finish;\r
   DrawPosition(FALSE, NULL);\r
   animInfo.piece = EmptySquare;\r
-  if(gameInfo.variant == VariantAtomic && board[toY][toX] != EmptySquare)\r
-    AnimateAtomicCapture(toX, toY, 2*nFrames);\r
+  if(gameInfo.variant == VariantAtomic && \r
+     (board[toY][toX] != EmptySquare || fromX != toX && (piece == WhitePawn || piece == BlackPawn) ) )\r
+       AnimateAtomicCapture(fromX, fromY, toX, toY, 2*nFrames);\r
 }\r
 \r
 /*      Convert board position to corner of screen rect and color       */\r