Fix writing of Chu-Shogi FENs
authorH.G. Muller <h.g.muller@hccnet.nl>
Sat, 5 Apr 2014 18:39:55 +0000 (20:39 +0200)
committerH.G. Muller <h.g.muller@hccnet.nl>
Sat, 5 Apr 2014 18:39:55 +0000 (20:39 +0200)
Promoted pieces were getting the wrong ID letter, of the piece demoted
by 11, rather than 22.

backend.c
common.h

index 5771996..88fed00 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -17639,12 +17639,12 @@ PositionToFEN (int move, char *overrideCastling, int moveCounts)
                 if(PieceToChar(piece) == '+') {
                     /* [HGM] write promoted pieces as '+<unpromoted>' (Shogi) */
                     *p++ = '+';
-                    piece = (ChessSquare)(DEMOTED piece);
+                    piece = (ChessSquare)(CHUDEMOTED piece);
                 }
                 *p++ = (piece == DarkSquare ? '*' : PieceToChar(piece));
                 if(p[-1] == '~') {
                     /* [HGM] flag promoted pieces as '<promoted>~' (Crazyhouse) */
-                    p[-1] = PieceToChar((ChessSquare)(DEMOTED piece));
+                    p[-1] = PieceToChar((ChessSquare)(CHUDEMOTED piece));
                     *p++ = '~';
                 }
            }
index 3d92dc0..132c48d 100644 (file)
--- a/common.h
+++ b/common.h
@@ -313,6 +313,7 @@ typedef enum {
 #define DEMOTED        (int)WhiteRook - (int)WhiteDragon + (int)
 #define SHOGI          (int)EmptySquare + (int)
 #define CHUPROMOTED    ((int)WhitePDragon - (int)WhiteDragon)*(gameInfo.variant == VariantChu) + PROMOTED
+#define CHUDEMOTED     ((int)WhiteDragon - (int)WhitePDragon)*(gameInfo.variant == VariantChu) + DEMOTED
 #define IS_SHOGI(V)    ((V) == VariantShogi || (V) == VariantChu)
 #define IS_LION(V)     ((V) == WhiteLion || (V) == BlackLion)