From f410ea90e1a5e7255f4d5466477e1b6883de59ca Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Tue, 26 Jan 2010 19:00:54 +0100 Subject: [PATCH] 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. --- backend.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) 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]++; } -- 1.7.0.4