mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-16 15:41:16 +01:00
as proof of concept, skip the first 3 tiles when sorting newly
assigned. Later '3' will be replaced by the location of the tray divider, but that has to be moved from board to model first.
This commit is contained in:
parent
93526d38d7
commit
1346aa6ee5
4 changed files with 14 additions and 8 deletions
|
@ -1838,7 +1838,7 @@ model_assignPlayerTiles( ModelCtxt* model, XP_S16 turn,
|
|||
{
|
||||
XP_ASSERT( turn >= 0 );
|
||||
TrayTileSet sorted;
|
||||
sortTiles( &sorted, tiles );
|
||||
sortTiles( &sorted, tiles, 0 );
|
||||
stack_addAssign( model->vol.stack, turn, &sorted );
|
||||
|
||||
assignPlayerTiles( model, turn, tiles );
|
||||
|
@ -1850,7 +1850,8 @@ model_sortTiles( ModelCtxt* model, XP_S16 turn )
|
|||
XP_S16 nTiles;
|
||||
|
||||
TrayTileSet sorted;
|
||||
sortTiles( &sorted, model_getPlayerTiles( model, turn ) );
|
||||
const TrayTileSet* curTiles = model_getPlayerTiles( model, turn );
|
||||
sortTiles( &sorted, curTiles, XP_MIN( 3, curTiles->nTiles) );
|
||||
|
||||
nTiles = sorted.nTiles;
|
||||
while ( nTiles > 0 ) {
|
||||
|
|
|
@ -97,7 +97,7 @@ augmentFor( XP_U32 hash, const StackEntry* entry )
|
|||
switch( entry->moveType ) {
|
||||
case ASSIGN_TYPE: {
|
||||
TrayTileSet tiles;
|
||||
sortTiles( &tiles, &entry->u.assign.tiles );
|
||||
sortTiles( &tiles, &entry->u.assign.tiles, 0 );
|
||||
hash = augmentHash( hash, (XP_U8*)&tiles, sizeof(tiles) );
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -84,13 +84,18 @@ removeTile( TrayTileSet* tiles, XP_U16 index )
|
|||
}
|
||||
|
||||
void
|
||||
sortTiles( TrayTileSet* dest, const TrayTileSet* src )
|
||||
sortTiles( TrayTileSet* dest, const TrayTileSet* src, XP_U16 skip )
|
||||
{
|
||||
XP_ASSERT( src->nTiles >= skip );
|
||||
TrayTileSet tmp = *src;
|
||||
dest->nTiles = 0;
|
||||
while ( 0 < tmp.nTiles ) {
|
||||
|
||||
/* Copy in the ones we're not sorting */
|
||||
dest->nTiles = skip;
|
||||
XP_MEMCPY( &dest->tiles, &tmp.tiles, skip * sizeof(tmp.tiles[0]) );
|
||||
|
||||
while ( skip < tmp.nTiles ) {
|
||||
XP_U16 ii, smallest;
|
||||
for ( smallest = ii = 0; ii < tmp.nTiles; ++ii ) {
|
||||
for ( smallest = ii = skip; ii < tmp.nTiles; ++ii ) {
|
||||
if ( tmp.tiles[ii] < tmp.tiles[smallest] ) {
|
||||
smallest = ii;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ XP_U16 bitsForMax( XP_U32 n );
|
|||
|
||||
void traySetToStream( XWStreamCtxt* stream, const TrayTileSet* ts );
|
||||
void traySetFromStream( XWStreamCtxt* stream, TrayTileSet* ts );
|
||||
void sortTiles( TrayTileSet* dest, const TrayTileSet* src );
|
||||
void sortTiles( TrayTileSet* dest, const TrayTileSet* src, XP_U16 skip );
|
||||
void removeTile( TrayTileSet* tiles, XP_U16 index );
|
||||
|
||||
XP_S32 signedFromStream( XWStreamCtxt* stream, XP_U16 nBits );
|
||||
|
|
Loading…
Reference in a new issue