mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-04 20:46:28 +01:00
fix crash sorting tiles when there are fewer to sort than there is
space to the left of the divider, i.e. when the game's nearly over.
This commit is contained in:
parent
d00a89b8b0
commit
e52d5c4077
1 changed files with 9 additions and 10 deletions
|
@ -1864,19 +1864,18 @@ model_assignPlayerTiles( ModelCtxt* model, XP_S16 turn,
|
|||
void
|
||||
model_sortTiles( ModelCtxt* model, XP_S16 turn )
|
||||
{
|
||||
XP_S16 nTiles;
|
||||
|
||||
TrayTileSet sorted;
|
||||
const TrayTileSet* curTiles = model_getPlayerTiles( model, turn );
|
||||
XP_U16 dividerLoc = model_getDividerLoc( model, turn );
|
||||
sortTiles( &sorted, curTiles, dividerLoc );
|
||||
const TrayTileSet* curTiles = model_getPlayerTiles( model, turn );
|
||||
if ( curTiles->nTiles >= dividerLoc) { /* any to sort? */
|
||||
TrayTileSet sorted;
|
||||
sortTiles( &sorted, curTiles, dividerLoc );
|
||||
|
||||
nTiles = sorted.nTiles;
|
||||
while ( nTiles > 0 ) {
|
||||
removePlayerTile( model, turn, --nTiles );
|
||||
for ( XP_S16 nTiles = sorted.nTiles; nTiles > 0; ) {
|
||||
removePlayerTile( model, turn, --nTiles );
|
||||
}
|
||||
|
||||
assignPlayerTiles( model, turn, &sorted );
|
||||
}
|
||||
|
||||
assignPlayerTiles( model, turn, &sorted );
|
||||
} /* model_sortTiles */
|
||||
|
||||
XP_U16
|
||||
|
|
Loading…
Add table
Reference in a new issue