Small fix in editing castling rights
authorH.G. Muller <h.g.muller@hccnet.nl>
Wed, 27 Jan 2010 12:34:55 +0000 (13:34 +0100)
committerArun Persaud <arun@nubati.net>
Sun, 7 Feb 2010 01:36:32 +0000 (17:36 -0800)
If there is no King with rights, the e-file is used to decide if a Rook
with rights is the K-side or Q-side Rook. This at least works with
corner Rooks, to avoid disappearence of Rook-rights on repetitive
editing of a position through intermediates with no King-rights.

backend.c

index 2c245d6..cfc9b6f 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -12023,11 +12023,13 @@ EditPositionDone(Boolean fakeRights)
       kf = NoRights; err = 0;
       for(f=BOARD_RGHT-1; f>=0; f--)
        if(rightsBoard[0][f] == 2) { if(kf != NoRights) err=10; boards[0][CASTLING][2] = kf = f; }
+      if(kf == NoRights) kf = 4;
       for(f=BOARD_RGHT-1; f>=0; f--)
        if(rightsBoard[0][f] == 1) { err++; boards[0][CASTLING][f<kf] = f; }
       kf = NoRights; err = 0;
       for(f=BOARD_RGHT-1; f>=0; f--)
        if(rightsBoard[BOARD_HEIGHT-1][f] == 2) { if(kf != NoRights) err=10; boards[0][CASTLING][5] = kf = f; }
+      if(kf == NoRights) kf = 4;
       for(f=BOARD_RGHT-1; f>=0; f--)
        if(rightsBoard[BOARD_HEIGHT-1][f] == 1) { err++; boards[0][CASTLING][3+(f<kf)] = f; }
       if(err + 2 > nrCastlingRights) DisplayError("unclear castling rights", 0);