From: H.G.Muller Date: Wed, 13 Jan 2016 19:35:36 +0000 (+0100) Subject: Let FENs handle Betza initial rights in castlingless variants X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=a47dabb3f4384723d696aaf26d5ce87b35df533f;p=xboard.git Let FENs handle Betza initial rights in castlingless variants When a variant has no castling, or is redefined to have no castling through a 'piece' command for the King, the FEN castling field of a written FEN will now contain the file ID of all pieces with initial ('i') moves in their Betza definition. On reading the virginity of pieces not thus mentioned in the castling field will get their virginity revoked. --- diff --git a/backend.c b/backend.c index 417d452..a7be826 100644 --- a/backend.c +++ b/backend.c @@ -17894,7 +17894,7 @@ char * PositionToFEN (int move, char *overrideCastling, int moveCounts) { int i, j, fromX, fromY, toX, toY; - int whiteToPlay; + int whiteToPlay, haveRights = nrCastlingRights; char buf[MSG_SIZ]; char *p, *q; int emptycount; @@ -17968,10 +17968,28 @@ PositionToFEN (int move, char *overrideCastling, int moveCounts) *p++ = whiteToPlay ? 'w' : 'b'; *p++ = ' '; + if(pieceDesc[WhiteKing] && strchr(pieceDesc[WhiteKing], 'i') && !strchr(pieceDesc[WhiteKing], 'O')) { // redefined without castling + haveRights = 0; q = p; + for(i=BOARD_RGHT-1; i>=BOARD_LEFT; i--) { + piece = boards[move][0][i]; + if(piece >= WhitePawn && piece <= WhiteKing && pieceDesc[piece] && strchr(pieceDesc[piece], 'i')) { // piece with initial move + if(!(boards[move][TOUCHED_W] & 1<=BOARD_LEFT; i--) { + piece = boards[move][BOARD_HEIGHT-1][i]; + if(piece >= BlackPawn && piece <= BlackKing && pieceDesc[piece] && strchr(pieceDesc[piece], 'i')) { // piece with initial move + if(!(boards[move][TOUCHED_B] & 1<