From: H.G. Muller Date: Tue, 26 Jan 2010 18:00:54 +0000 (+0100) Subject: Fix bug in edit-position of holdings X-Git-Tag: master-20100206~21 X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=f410ea90e1a5e7255f4d5466477e1b6883de59ca;p=xboard.git Fix bug in edit-position of holdings The holdings were effectivelly taken one too large, so that a promoted shogi Pawn moved to, or created in the holdings was not demoted to Pawn, but put in the dark (which you could see by the holding count if you did it twice). The overflow tests in these two cases now have been corrected. --- diff --git a/backend.c b/backend.c index 3a36a30..a9b29e4 100644 --- a/backend.c +++ b/backend.c @@ -5891,13 +5891,13 @@ void LeftClick(ClickType clickType, int xPix, int yPix) if(x == BOARD_LEFT-2 && piece >= BlackPawn) { n = PieceToNumber(piece - (int)BlackPawn); - if(n > gameInfo.holdingsSize) { n = 0; piece = BlackPawn; } + if(n >= gameInfo.holdingsSize) { n = 0; piece = BlackPawn; } boards[currentMove][BOARD_HEIGHT-1 - n][0] = piece; boards[currentMove][BOARD_HEIGHT-1 - n][1]++; } else if(x == BOARD_RGHT+1 && piece < BlackPawn) { n = PieceToNumber(piece); - if(n > gameInfo.holdingsSize) { n = 0; piece = WhitePawn; } + if(n >= gameInfo.holdingsSize) { n = 0; piece = WhitePawn; } boards[currentMove][n][BOARD_WIDTH-1] = piece; boards[currentMove][n][BOARD_WIDTH-2]++; } @@ -11628,13 +11628,13 @@ EditPositionMenuEvent(selection, x, y) int n; if(x == BOARD_LEFT-2 && selection >= BlackPawn) { n = PieceToNumber(selection - BlackPawn); - if(n > gameInfo.holdingsSize) { n = 0; selection = BlackPawn; } + if(n >= gameInfo.holdingsSize) { n = 0; selection = BlackPawn; } boards[0][BOARD_HEIGHT-1-n][0] = selection; boards[0][BOARD_HEIGHT-1-n][1]++; } else if(x == BOARD_RGHT+1 && selection < BlackPawn) { n = PieceToNumber(selection); - if(n > gameInfo.holdingsSize) { n = 0; selection = WhitePawn; } + if(n >= gameInfo.holdingsSize) { n = 0; selection = WhitePawn; } boards[0][n][BOARD_WIDTH-1] = selection; boards[0][n][BOARD_WIDTH-2]++; }