From 8227cf843e0eb19916b9e3a7460fa970a5e6958c Mon Sep 17 00:00:00 2001 From: "H.G. Muller" Date: Thu, 28 Oct 2010 18:42:25 +0200 Subject: [PATCH] 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. --- winboard/winboard.c | 10 +++++----- xboard.c | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/winboard/winboard.c b/winboard/winboard.c index ec17e474..73a36b62 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 0d11eae4..fc6ba3a2 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 { -- 2.17.1