From dcd563701f4164a6f8b2e8e8c84ddb96601e147c Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Thu, 5 Feb 2015 12:24:00 +0100 Subject: [PATCH] Fix illegal drops For illegal drops the 'from-square' was subjected to an on-board test, which of course always failed, after which the move was reclassified as an ImpossibleMove after all. (Leading to rejection even when legality testing was off, and error messages like "Could not parse move".) --- backend.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/backend.c b/backend.c index 6bf57ac..9a9d0a4 100644 --- a/backend.c +++ b/backend.c @@ -5494,6 +5494,7 @@ char yy_textstr[8000]; Boolean ParseOneMove (char *move, int moveNum, ChessMove *moveType, int *fromX, int *fromY, int *toX, int *toY, char *promoChar) { + int badFrom; *moveType = yylexstr(moveNum, move, yy_textstr, sizeof yy_textstr); switch (*moveType) { @@ -5525,7 +5526,9 @@ ParseOneMove (char *move, int moveNum, ChessMove *moveType, int *fromX, int *fro *toX = currentMoveString[2] - AAA; *toY = currentMoveString[3] - ONE; *promoChar = currentMoveString[4]; - if (*fromX < BOARD_LEFT || *fromX >= BOARD_RGHT || *fromY < 0 || *fromY >= BOARD_HEIGHT || + badFrom = (*fromX < BOARD_LEFT || *fromX >= BOARD_RGHT || *fromY < 0 || *fromY >= BOARD_HEIGHT); + if(currentMoveString[1] == '@') { badFrom = FALSE; *fromX = CharToPiece(currentMoveString[0]); *fromY = DROP_RANK; } // illegal drop + if (badFrom || *toX < BOARD_LEFT || *toX >= BOARD_RGHT || *toY < 0 || *toY >= BOARD_HEIGHT) { if (appData.debugMode) { fprintf(debugFP, "Off-board move (%d,%d)-(%d,%d)%c, type = %d\n", *fromX, *fromY, *toX, *toY, *promoChar, *moveType); -- 1.7.0.4