From 9337560fbda4278a04213d85947445218fd01621 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Mon, 1 Feb 2016 21:51:04 +0100 Subject: [PATCH] Fix castling rights The expansion of the number of piece types to > 64 had broken the accounting of castling rights, because the code for NoRights is also a piece code (as it is stored in the board), and had gotten a value so high that it could no longer be stored as signed char. This is solved by declaring the initialRights array as unsigned char instead. --- backend.c | 2 +- moves.c | 1 - parser.h | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/backend.c b/backend.c index 6fca83d..38b4e54 100644 --- a/backend.c +++ b/backend.c @@ -516,7 +516,7 @@ AppData appData; Board boards[MAX_MOVES]; /* [HGM] Following 7 needed for accurate legality tests: */ signed char castlingRank[BOARD_FILES]; // and corresponding ranks -signed char initialRights[BOARD_FILES]; +unsigned char initialRights[BOARD_FILES]; int nrCastlingRights; // For TwoKings, or to implement castling-unknown status int initialRulePlies, FENrulePlies; FILE *serverMoves = NULL; // next two for broadcasting (/serverMoves option) diff --git a/moves.c b/moves.c index f00e712..67a23ac 100644 --- a/moves.c +++ b/moves.c @@ -71,7 +71,6 @@ int BlackPiece P((ChessSquare)); int SameColor P((ChessSquare, ChessSquare)); int PosFlags(int index); -extern signed char initialRights[BOARD_FILES]; /* [HGM] all rights enabled, set in InitPosition */ int quickFlag; char *pieceDesc[EmptySquare]; char *defaultDesc[EmptySquare] = { diff --git a/parser.h b/parser.h index 2147f3c..87226f1 100644 --- a/parser.h +++ b/parser.h @@ -62,6 +62,6 @@ extern int yyskipmoves; /* If TRUE, all moves are reported as AmbiguousMove extern char *yy_text; /* Needed because yytext can be either a char[] or a (non-constant) char* */ extern int yyoffset P((void)); -extern signed char initialRights[BOARD_FILES]; +extern unsigned char initialRights[BOARD_FILES]; extern signed char castlingRank[BOARD_FILES]; -- 1.7.0.4