mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-30 10:26:58 +01:00
fix crash using undo/redo after a turn has overwritten pending tiles:
when redoing need to check that cell is still empty.
This commit is contained in:
parent
5b33df4e25
commit
8c7043d42c
1 changed files with 10 additions and 6 deletions
|
@ -1013,12 +1013,11 @@ model_moveTrayToBoard( ModelCtxt* model, XP_S16 turn, XP_U16 col, XP_U16 row,
|
||||||
XP_Bool
|
XP_Bool
|
||||||
model_redoPendingTiles( ModelCtxt* model, XP_S16 turn )
|
model_redoPendingTiles( ModelCtxt* model, XP_S16 turn )
|
||||||
{
|
{
|
||||||
XP_Bool changed = XP_FALSE;
|
XP_U16 actualCnt = 0;
|
||||||
|
|
||||||
PlayerCtxt* player = &model->players[turn];
|
PlayerCtxt* player = &model->players[turn];
|
||||||
XP_U16 nUndone = player->nUndone;
|
XP_U16 nUndone = player->nUndone;
|
||||||
changed = nUndone > 0;
|
if ( nUndone > 0 ) {
|
||||||
if ( changed ) {
|
|
||||||
PendingTile pendingTiles[nUndone];
|
PendingTile pendingTiles[nUndone];
|
||||||
PendingTile* pt = pendingTiles;
|
PendingTile* pt = pendingTiles;
|
||||||
|
|
||||||
|
@ -1037,11 +1036,16 @@ model_redoPendingTiles( ModelCtxt* model, XP_S16 turn )
|
||||||
}
|
}
|
||||||
foundAt = model_trayContains( model, turn, tile );
|
foundAt = model_trayContains( model, turn, tile );
|
||||||
XP_ASSERT( foundAt >= 0 );
|
XP_ASSERT( foundAt >= 0 );
|
||||||
|
|
||||||
|
if ( !model_getTile( model, pt->col, pt->row, XP_FALSE, turn,
|
||||||
|
NULL, NULL, NULL, NULL ) ) {
|
||||||
model_moveTrayToBoard( model, turn, pt->col, pt->row,
|
model_moveTrayToBoard( model, turn, pt->col, pt->row,
|
||||||
foundAt, pt->tile & ~TILE_BLANK_BIT );
|
foundAt, pt->tile & ~TILE_BLANK_BIT );
|
||||||
|
++actualCnt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
}
|
||||||
|
return actualCnt > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue