Fix faking of castling rights after editing position with holdings
authorH.G. Muller <h.g.muller@hccnet.nl>
Tue, 17 Apr 2012 17:45:33 +0000 (19:45 +0200)
committerH.G. Muller <h.g.muller@hccnet.nl>
Mon, 23 Apr 2012 12:06:24 +0000 (14:06 +0200)
The queen-side rook was always imagined at X=0, which is in the holdings
when these exist, so that Q-side castling in such games was never allowed
after EditPosition.

backend.c

index 634b710..f86a60e 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -13932,11 +13932,11 @@ EditPositionDone (Boolean fakeRights)
       boards[0][EP_STATUS] = EP_NONE;
       boards[0][CASTLING][2] = boards[0][CASTLING][5] = BOARD_WIDTH>>1;
     if(boards[0][0][BOARD_WIDTH>>1] == king) {
-       boards[0][CASTLING][1] = boards[0][0][BOARD_LEFT] == WhiteRook ? 0 : NoRights;
+       boards[0][CASTLING][1] = boards[0][0][BOARD_LEFT] == WhiteRook ? BOARD_LEFT : NoRights;
        boards[0][CASTLING][0] = boards[0][0][BOARD_RGHT-1] == WhiteRook ? BOARD_RGHT-1 : NoRights;
       } else boards[0][CASTLING][2] = NoRights;
     if(boards[0][BOARD_HEIGHT-1][BOARD_WIDTH>>1] == WHITE_TO_BLACK king) {
-       boards[0][CASTLING][4] = boards[0][BOARD_HEIGHT-1][BOARD_LEFT] == BlackRook ? 0 : NoRights;
+       boards[0][CASTLING][4] = boards[0][BOARD_HEIGHT-1][BOARD_LEFT] == BlackRook ? BOARD_LEFT : NoRights;
        boards[0][CASTLING][3] = boards[0][BOARD_HEIGHT-1][BOARD_RGHT-1] == BlackRook ? BOARD_RGHT-1 : NoRights;
       } else boards[0][CASTLING][5] = NoRights;
     }