From 57e246da3b68a43b4694ec5cd14957517b677afe Mon Sep 17 00:00:00 2001 From: Andy2 Date: Fri, 2 Jul 2010 22:44:50 -0700 Subject: [PATCH] handle blanks as well in redo of undone pending tiles --- xwords4/common/model.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/xwords4/common/model.c b/xwords4/common/model.c index 24b662ec9..9affd110a 100644 --- a/xwords4/common/model.c +++ b/xwords4/common/model.c @@ -1014,15 +1014,22 @@ model_redoPendingTiles( ModelCtxt* model, XP_S16 turn ) changed = nUndone > 0; if ( changed ) { PendingTile pendingTiles[nUndone]; - XP_U16 ii; + PendingTile* pt = pendingTiles; + XP_MEMCPY( pendingTiles, &player->pendingTiles[player->nPending], nUndone * sizeof(pendingTiles[0]) ); /* Now we have info about each tile, but don't know where in the tray they are. So find 'em. */ - for ( ii = 0; ii < nUndone; ++ii ) { - PendingTile* pt = &pendingTiles[ii]; - XP_S16 foundAt = model_trayContains( model, turn, pt->tile ); + for ( pt = pendingTiles; nUndone-- > 0; ++pt ) { + Tile tile = pt->tile; + XP_Bool isBlank = 0 != (tile & TILE_BLANK_BIT); + XP_S16 foundAt; + + if ( isBlank ) { + tile = dict_getBlankTile( model->vol.dict ); + } + foundAt = model_trayContains( model, turn, tile ); XP_ASSERT( foundAt >= 0 ); model_moveTrayToBoard( model, turn, pt->col, pt->row, foundAt, pt->tile & ~TILE_BLANK_BIT );