From: H.G. Muller Date: Thu, 28 Oct 2010 16:42:25 +0000 (+0200) Subject: Make Knight hop first straight, then diagonal X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=8227cf843e0eb19916b9e3a7460fa970a5e6958c;p=xboard.git Make Knight hop first straight, then diagonal It used to be the other way around, which looked pretty illogical in Xiangqi: to see Horses, which are blockable pieces there, move over an occupied square. --- diff --git a/winboard/winboard.c b/winboard/winboard.c index ec17e47..73a36b6 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -9658,17 +9658,17 @@ AnimateMove(board, fromX, fromY, toX, toY) ScreenSquare(fromX, fromY, &start); ScreenSquare(toX, toY, &finish); - /* All pieces except knights move in straight line */ - if (piece != WhiteKnight && piece != BlackKnight) { + /* All moves except knight jumps move in straight line */ + if (!(abs(fromX-toX) == 1 && abs(fromY-toY) == 2 || abs(fromX-toX) == 2 && abs(fromY-toY) == 1)) { mid.x = start.x + (finish.x - start.x) / 2; mid.y = start.y + (finish.y - start.y) / 2; } else { - /* Knight: make diagonal movement then straight */ + /* Knight: make straight movement then diagonal */ if (abs(toY - fromY) < abs(toX - fromX)) { mid.x = start.x + (finish.x - start.x) / 2; - mid.y = finish.y; + mid.y = start.y; } else { - mid.x = finish.x; + mid.x = start.x; mid.y = start.y + (finish.y - start.y) / 2; } } diff --git a/xboard.c b/xboard.c index 0d11eae..fc6ba3a 100644 --- a/xboard.c +++ b/xboard.c @@ -8947,7 +8947,7 @@ AnimateMove(board, fromX, fromY, toX, toY) #if DONT_HOP hop = FALSE; #else - hop = (piece == WhiteKnight || piece == BlackKnight); + hop = abs(fromX-toX) == 1 && abs(fromY-toY) == 2 || abs(fromX-toX) == 2 && abs(fromY-toY) == 1; #endif if (appData.debugMode) { @@ -8959,12 +8959,12 @@ AnimateMove(board, fromX, fromY, toX, toY) ScreenSquare(toX, toY, &finish, &endColor); if (hop) { - /* Knight: make diagonal movement then straight */ + /* Knight: make straight movement then diagonal */ if (abs(toY - fromY) < abs(toX - fromX)) { mid.x = start.x + (finish.x - start.x) / 2; - mid.y = finish.y; + mid.y = start.y; } else { - mid.x = finish.x; + mid.x = start.x; mid.y = start.y + (finish.y - start.y) / 2; } } else {