From f1bb6918df1a6168456bba4b0fe47c4440f93abc Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Fri, 4 Sep 2009 22:39:45 -0700 Subject: [PATCH] set castling rights after setting up a position I was going through old WB forum posts, and I encountered a bug report for a bug that I never fixed: The castling rights should be properly set (actually: cleared) after setting up a position in Edit Position mode (as opposed to pasting a FEN). --- backend.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/backend.c b/backend.c index b0d9351..90021ce 100644 --- a/backend.c +++ b/backend.c @@ -10912,8 +10912,19 @@ ExitAnalyzeMode() void EditPositionDone() { + int king = gameInfo.variant == VariantKnightmate ? WhiteUnicorn : WhiteKing; + startedFromSetupPosition = TRUE; InitChessProgram(&first, FALSE); + castlingRights[0][2] = castlingRights[0][5] = BOARD_WIDTH>>1; + if(boards[0][0][BOARD_WIDTH>>1] == king) { + castlingRights[0][1] = boards[0][0][BOARD_LEFT] == WhiteRook ? 0 : -1; + castlingRights[0][0] = boards[0][0][BOARD_RGHT-1] == WhiteRook ? BOARD_RGHT-1 : -1; + } else castlingRights[0][2] = -1; + if(boards[0][BOARD_HEIGHT-1][BOARD_WIDTH>>1] == WHITE_TO_BLACK king) { + castlingRights[0][4] = boards[0][BOARD_HEIGHT-1][BOARD_LEFT] == BlackRook ? 0 : -1; + castlingRights[0][3] = boards[0][BOARD_HEIGHT-1][BOARD_RGHT-1] == BlackRook ? BOARD_RGHT-1 : -1; + } else castlingRights[0][5] = -1; SendToProgram("force\n", &first); if (blackPlaysFirst) { strcpy(moveList[0], ""); -- 1.7.0.4