Fix printing of piece ID in illegal SAN moves
authorH.G.Muller <hgm@hgm-xboard.(none)>
Fri, 5 Feb 2016 10:26:51 +0000 (11:26 +0100)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Fri, 5 Feb 2016 10:26:51 +0000 (11:26 +0100)
Illegal SAN moves did not add ' or ! suffixes to the piece ID,
and printed shogi-promoted pieces as a '+' without ID.

moves.c

diff --git a/moves.c b/moves.c
index bef359e..4ec0944 100644 (file)
--- a/moves.c
+++ b/moves.c
@@ -2414,7 +2414,10 @@ CoordsToAlgebraic (Board board, int flags, int rf, int ff, int rt, int ft, int p
        int r, f;
       for(r=0; r<BOARD_HEIGHT; r++) for(f=BOARD_LEFT; f<=BOARD_RGHT; f++)
                c += (board[r][f] == piece); // count on-board pieces of given type
-       *outp++ = ToUpper(PieceToChar(piece));
+        *outp = PieceToChar(piece);
+        if(*outp == '+') outp++, piece = CHUDEMOTED(piece);
+        *outp++ = ToUpper(PieceToChar(piece));
+        if(*outp = PieceSuffix(piece)) outp++;
     }
   if(c != 1) { // [HGM] but if there is only one piece of the mentioned type, no from-square, thank you!
     *outp++ = ff + AAA;