From 50b75711089c434a89fcb126a5db86e7eb8246a3 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Mon, 8 Sep 2014 16:20:26 +0200 Subject: [PATCH] Animate multi-leg in auto-play and forward event Replaying multi-leg moves is now also done by animating both legs. In addition, the highlights are set on final and intermediate square, rather than from-square. (There seems to be a great deal of code duplication here. Why doesn't AutoPlayOneMove simply call ForwardInner?) --- backend.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/backend.c b/backend.c index 36eca33..1c4bddc 100644 --- a/backend.c +++ b/backend.c @@ -11755,11 +11755,20 @@ AutoPlayOneMove () SetHighlights(-1, -1, toX, toY); } } else { + int viaX = moveList[currentMove][5] - AAA; + int viaY = moveList[currentMove][6] - ONE; fromX = moveList[currentMove][0] - AAA; fromY = moveList[currentMove][1] - ONE; HistorySet(parseList, backwardMostMove, forwardMostMove, currentMove); /* [AS] */ + if(moveList[currentMove][4] == ';') { // multi-leg + ChessSquare piece = boards[currentMove][viaY][viaX]; + AnimateMove(boards[currentMove], fromX, fromY, viaX, viaY); + boards[currentMove][viaY][viaX] = boards[currentMove][fromY][fromX]; + AnimateMove(boards[currentMove], fromX=viaX, fromY=viaY, toX, toY); + boards[currentMove][viaY][viaX] = piece; + } else AnimateMove(boards[currentMove], fromX, fromY, toX, toY); if (appData.highlightLastMove) { @@ -15484,9 +15493,18 @@ ForwardInner (int target) SetHighlights(-1, -1, toX, toY); } } else { + int viaX = moveList[target - 1][5] - AAA; + int viaY = moveList[target - 1][6] - ONE; fromX = moveList[target - 1][0] - AAA; fromY = moveList[target - 1][1] - ONE; if (target == currentMove + 1) { + if(moveList[target - 1][4] == ';') { // multi-leg + ChessSquare piece = boards[currentMove][viaY][viaX]; + AnimateMove(boards[currentMove], fromX, fromY, viaX, viaY); + boards[currentMove][viaY][viaX] = boards[currentMove][fromY][fromX]; + AnimateMove(boards[currentMove], viaX, viaY, toX, toY); + boards[currentMove][viaY][viaX] = piece; + } else AnimateMove(boards[currentMove], fromX, fromY, toX, toY); } if (appData.highlightLastMove) { -- 1.7.0.4