From: H.G. Muller Date: Tue, 1 Mar 2011 22:32:25 +0000 (+0100) Subject: Fix two bugs in reading position diagram X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=8fb3e845c11b2341219eb69345bc0c801bcd4bf5;p=xboard.git Fix two bugs in reading position diagram When reading a game without FEN tag, a position diagram is used to set the initial position. This calls CharToPiece() with a '.' as argument, because that is the position-diagram way to indicate empty squares. altered CharToPiece() over time this would be recognized as the first undefined piece or, more recently, the first piece without nickName, which is a white Pawn. Now it returns EmptySquare again in that case. A second problem was that for position diagrams in braces the brace was not in the list of ignored characters, and would cause the reading to get out of phase, so that the side to move was not recognized. --- diff --git a/backend.c b/backend.c index 77a1564..c724c0f 100644 --- a/backend.c +++ b/backend.c @@ -10421,6 +10421,7 @@ LoadGame(f, gameNumber, title, useList) for (i = BOARD_HEIGHT - 1; i >= 0; i--) for (j = BOARD_LEFT; j < BOARD_RGHT; p++) switch (*p) { + case '{': case '[': case '-': case ' ': diff --git a/moves.c b/moves.c index 6310201..fd05e38 100644 --- a/moves.c +++ b/moves.c @@ -126,6 +126,7 @@ ChessSquare CharToPiece(c) int c; { int i; + if(c == '.') return EmptySquare; for(i=0; i< (int) EmptySquare; i++) if(pieceNickName[i] == c) return (ChessSquare) i; for(i=0; i< (int) EmptySquare; i++)