From 0332dbee9a4458560fe2c35aef0356cabca2bebc Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Wed, 27 Jan 2010 13:19:05 +0100 Subject: [PATCH] Make XBoard grant- and revoke-rights buttons work The buttons in the new promotion popup to specify castling rights are now fully operational. A new ChessSquare enum code 'GrantRights' was added to transmit the instruction. ('NoRights' was used for revoking the rights.) --- backend.c | 12 ++++++++++++ common.h | 1 + xpromo.c | 6 ++++++ 3 files changed, 19 insertions(+), 0 deletions(-) diff --git a/backend.c b/backend.c index 35cc84d..2c245d6 100644 --- a/backend.c +++ b/backend.c @@ -12183,6 +12183,18 @@ EditPositionMenuEvent(selection, x, y) SetBlackToPlayEvent(); break; + case NoRights: + rightsBoard[y][x] = 0; + break; + + case GrantRights: + { ChessSquare p = boards[0][y][x]; + rightsBoard[y][x] = 1; + if(p == WhiteKing || p == WhiteUnicorn || p == BlackKing || p == BlackUnicorn) + rightsBoard[y][x] = 2; + } + break; + case EmptySquare: if (gameMode == IcsExamining) { if (x < BOARD_LEFT || x >= BOARD_RGHT) break; // [HGM] holdings diff --git a/common.h b/common.h index a5577e2..d15c45e 100644 --- a/common.h +++ b/common.h @@ -236,6 +236,7 @@ typedef enum { BlackSilver, BlackFalcon, BlackLance, BlackCobra, BlackUnicorn, BlackKing, EmptySquare, NoRights, // [HGM] gamestate: for castling rights hidden in board[CASTLING] + GrantRights, // [HGM] promopopup: for EditPosition menu ClearBoard, WhitePlay, BlackPlay, PromotePiece, DemotePiece /*for use on EditPosition menus*/ } ChessSquare; diff --git a/xpromo.c b/xpromo.c index 49637b2..c2d7d9e 100644 --- a/xpromo.c +++ b/xpromo.c @@ -288,6 +288,12 @@ void PromoCallback(w, client_data, call_data) if (strcmp(name, _("clear board")) == 0) { EditPositionMenuEvent(ClearBoard, 0, 0); + } else + if (strcmp(name, _("grant rights")) == 0) { + EditPositionMenuEvent(GrantRights, fromX, fromY); + } else + if (strcmp(name, _("revoke rights")) == 0) { + EditPositionMenuEvent(NoRights, fromX, fromY); } PromoPopDown(); } -- 1.7.0.4