Fix bare King adjudication
authorH.G.Muller <hgm@hgm-xboard.(none)>
Fri, 22 Jul 2016 07:12:36 +0000 (09:12 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Fri, 22 Jul 2016 07:12:36 +0000 (09:12 +0200)
The increase of the number of piece types to 66 gave the BlackKing code
131, wich is > 127, so that using a signed char for it makes it < 0.
This cause the black King in the adjudication code to be seen as a white
piece. When black then checkmates with 2 pieces, only 1 piece is seen
(Q), and then assumed to be a bare King! Now the piece value is passed
through an (int) to prevent this.

backend.c

index c5d9e9a..48695ad 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -11672,7 +11672,7 @@ GameEnds (ChessMove result, char *resultDetails, int whosays)
               && result != GameIsDrawn)
            {   int i, j, k=0, oppoKings = 0, color = (result==WhiteWins ? (int)WhitePawn : (int)BlackPawn);
                for(j=BOARD_LEFT; j<BOARD_RGHT; j++) for(i=0; i<BOARD_HEIGHT; i++) {
-                       int p = (signed char)boards[forwardMostMove][i][j] - color;
+                       int p = (int)boards[forwardMostMove][i][j] - color;
                        if(p >= 0 && p <= (int)WhiteKing) k++;
                        oppoKings += (p + color == WhiteKing + BlackPawn - color);
                }