diff --git a/xwords4/common/board.c b/xwords4/common/board.c index 9ce4a2989..798e23954 100644 --- a/xwords4/common/board.c +++ b/xwords4/common/board.c @@ -1689,10 +1689,10 @@ board_toggle_showValues( BoardCtxt* board ) } /* board_toggle_showValues */ XP_Bool -board_replaceTiles( BoardCtxt* board ) +board_replaceNTiles( BoardCtxt* board, XP_U16 nTiles ) { XP_Bool result = XP_FALSE; - while ( replaceLastTile( board ) ) { + while ( 0 < nTiles-- && replaceLastTile( board ) ) { result = XP_TRUE; } @@ -1701,6 +1701,12 @@ board_replaceTiles( BoardCtxt* board ) } return result; +} + +XP_Bool +board_replaceTiles( BoardCtxt* board ) +{ + return board_replaceNTiles( board, MAX_TRAY_TILES ); } /* board_replaceTiles */ XP_Bool diff --git a/xwords4/common/boardp.h b/xwords4/common/boardp.h index 7124ef651..2f6133960 100644 --- a/xwords4/common/boardp.h +++ b/xwords4/common/boardp.h @@ -268,6 +268,7 @@ XP_Bool holdsPendingTile( BoardCtxt* board, XP_U16 pencol, XP_U16 penrow ); XP_Bool moveTileToBoard( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_U16 tileIndex, Tile blankFace ); +XP_Bool board_replaceNTiles( BoardCtxt* board, XP_U16 nTiles ); void invalTilesUnderRect( BoardCtxt* board, const XP_Rect* rect ); void invalCellRegion( BoardCtxt* board, XP_U16 colA, XP_U16 rowA, XP_U16 colB, diff --git a/xwords4/common/tray.c b/xwords4/common/tray.c index 4e712edd7..bb2beb359 100644 --- a/xwords4/common/tray.c +++ b/xwords4/common/tray.c @@ -442,11 +442,16 @@ handleActionInTray( BoardCtxt* board, XP_S16 index, XP_Bool onDivider ) #endif } else if ( index == -(MAX_TRAY_TILES) ) { /* pending score tile */ result = board_commitTurn( board ); -#ifndef DISABLE_EMPTYTRAY_UNDO +#if defined XWFEATURE_TRAYUNDO_ALL } else if ( index < 0 ) { /* other empty area */ /* it better be true */ (void)board_replaceTiles( board ); result = XP_TRUE; +#elif defined XWFEATURE_TRAYUNDO_ONE + } else if ( index < 0 ) { /* other empty area */ + /* it better be true */ + (void)board_replaceNTiles( board, 1 ); + result = XP_TRUE; #endif } return result;