Make EditPosition pallette work in Asian variants
authorH.G.Muller <hgm@hgm-xboard.(none)>
Wed, 9 Apr 2014 07:19:43 +0000 (09:19 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Wed, 9 Apr 2014 07:19:43 +0000 (09:19 +0200)
Construction of the pallette position was not working in variants that
did not have Pawns start on 2nd rank, or that had multiple ranks of pieces.
Now the algorithm is applied to all ranks.

backend.c

index 88fed00..b05e795 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -15013,14 +15013,14 @@ EditPositionMenuEvent (ChessSquare selection, int x, int y)
                        boards[0][y][x] = p;
                    }
                }
                        boards[0][y][x] = p;
                    }
                }
-               menuBoard[1][x] = menuBoard[BOARD_HEIGHT-2][x] = p;
            }
            if(gameMode != IcsExamining) { // [HGM] editpos: cycle trough boards
            }
            if(gameMode != IcsExamining) { // [HGM] editpos: cycle trough boards
-               for(x = BOARD_LEFT; x < BOARD_RGHT; x++) { // create 'menu board' by removing duplicates 
-                   ChessSquare p = menuBoard[0][x];
-                   for(y = x + 1; y < BOARD_RGHT; y++) if(menuBoard[0][y] == p) menuBoard[0][y] = EmptySquare;
-                   p = menuBoard[BOARD_HEIGHT-1][x];
-                   for(y = x + 1; y < BOARD_RGHT; y++) if(menuBoard[BOARD_HEIGHT-1][y] == p) menuBoard[BOARD_HEIGHT-1][y] = EmptySquare;
+               int r;
+               for(r = 0; r < BOARD_HEIGHT; r++) {
+                 for(x = BOARD_LEFT; x < BOARD_RGHT; x++) { // create 'menu board' by removing duplicates 
+                   ChessSquare p = menuBoard[r][x];
+                   for(y = x + 1; y < BOARD_RGHT; y++) if(menuBoard[r][y] == p) menuBoard[r][y] = EmptySquare;
+                 }
                }
                DisplayMessage("Clicking clock again restores position", "");
                if(gameInfo.variant != lastVariant) lastVariant = gameInfo.variant, CopyBoard(erasedBoard, boards[0]);
                }
                DisplayMessage("Clicking clock again restores position", "");
                if(gameInfo.variant != lastVariant) lastVariant = gameInfo.variant, CopyBoard(erasedBoard, boards[0]);