From ae9edbb08d8940001c03386e6501bce8c5cabb96 Mon Sep 17 00:00:00 2001 From: ehouse Date: Sun, 29 Feb 2004 06:59:37 +0000 Subject: [PATCH] After an undo, set the prev_move bits on the move now on top of the stack so the tiles will get highlighted. --- xwords4/common/model.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/xwords4/common/model.c b/xwords4/common/model.c index 629135ba4..becd8a64c 100644 --- a/xwords4/common/model.c +++ b/xwords4/common/model.c @@ -581,6 +581,41 @@ model_undoLatestMoves( ModelCtxt* model, PoolContext* pool, } } + /* If there's still a move on top of the stack, highlight its tiles since + they're now the most recent move. */ + for ( ; ; ) { + StackEntry entry; + XP_U16 movesLeft = stack_getNEntries( stack ); + if ( movesLeft == 0 || + !stack_getNthEntry( stack, movesLeft - 1, &entry ) ) { + break; + } + if ( entry.moveType == MOVE_TYPE ) { + XP_U16 nTiles = entry.u.move.moveInfo.nTiles; + XP_U16 col, row; + XP_U16* varies; + + if ( entry.u.move.moveInfo.isHorizontal ) { + row = entry.u.move.moveInfo.commonCoord; + varies = &col; + } else { + col = entry.u.move.moveInfo.commonCoord; + varies = &row; + } + + while ( nTiles-- ) { + CellTile tile; + + *varies = entry.u.move.moveInfo.tiles[nTiles].varCoord; + tile = getModelTileRaw( model, col, row ); + setModelTileRaw( model, col, row, (CellTile)(tile | PREV_MOVE_BIT) ); + + notifyBoardListeners( model, entry.playerNum, col, row, XP_FALSE ); + } + break; + } + } + if ( nMovesUndone != nMovesSought ) { success = XP_FALSE; }