From 266cb250971712515fd6dc3e6701779a6036ce1f Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Sun, 22 Dec 2013 11:48:26 +0100 Subject: [PATCH] Clear memory of erased position on variant switch The Edit Position clear-board cycle would go from initial position to last-erased position (if this is different), but the latter could have been from another variant. In wich case we also want to clear. also print a message to alert people to the fact that they can click the clock again to restore the position. --- backend.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/backend.c b/backend.c index aea15b5..6dae63d 100644 --- a/backend.c +++ b/backend.c @@ -14593,7 +14593,8 @@ EditPositionMenuEvent (ChessSquare selection, int x, int y) { char buf[MSG_SIZ]; ChessSquare piece = boards[0][y][x]; - static Board erasedBoard, currentBoard, menuBoard; + static Board erasedBoard, currentBoard, menuBoard, nullBoard; + static int lastVariant; if (gameMode != EditPosition && gameMode != IcsExamining) return; @@ -14632,13 +14633,16 @@ EditPositionMenuEvent (ChessSquare selection, int x, int y) p = menuBoard[BOARD_HEIGHT-1][x]; for(y = x + 1; y < BOARD_RGHT; y++) if(menuBoard[BOARD_HEIGHT-1][y] == p) menuBoard[BOARD_HEIGHT-1][y] = EmptySquare; } + DisplayMessage("Clicking clock again restores position", ""); + if(gameInfo.variant != lastVariant) lastVariant = gameInfo.variant, CopyBoard(erasedBoard, boards[0]); if(!nonEmpty) { // asked to clear an empty board CopyBoard(boards[0], menuBoard); } else if(CompareBoards(currentBoard, menuBoard)) { // asked to clear an empty board CopyBoard(boards[0], initialPosition); } else - if(CompareBoards(currentBoard, initialPosition) && !CompareBoards(currentBoard, erasedBoard)) { + if(CompareBoards(currentBoard, initialPosition) && !CompareBoards(currentBoard, erasedBoard) + && !CompareBoards(nullBoard, erasedBoard)) { CopyBoard(boards[0], erasedBoard); } else CopyBoard(erasedBoard, currentBoard); -- 1.7.0.4