mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-25 09:58:11 +01:00
Merge branch 'android_branch' into android_bt
This commit is contained in:
commit
3b3439371f
4 changed files with 34 additions and 32 deletions
|
@ -72,8 +72,6 @@ static void buildModelFromStack( ModelCtxt* model, StackCtxt* stack,
|
|||
MovePrintFuncPost mpfpo, void* closure );
|
||||
static void setPendingCounts( ModelCtxt* model, XP_S16 turn );
|
||||
static XP_S16 setContains( const TrayTileSet* tiles, Tile tile );
|
||||
static void sortTiles( TrayTileSet* dest, const TrayTileSet* src );
|
||||
static void removeTile( TrayTileSet* tiles, XP_U16 index );
|
||||
static void loadPlayerCtxt( const ModelCtxt* model, XWStreamCtxt* stream,
|
||||
XP_U16 version, PlayerCtxt* pc );
|
||||
static void writePlayerCtxt( const ModelCtxt* model, XWStreamCtxt* stream,
|
||||
|
@ -2413,16 +2411,6 @@ writePlayerCtxt( const ModelCtxt* model, XWStreamCtxt* stream,
|
|||
}
|
||||
} /* writePlayerCtxt */
|
||||
|
||||
static void
|
||||
removeTile( TrayTileSet* tiles, XP_U16 index )
|
||||
{
|
||||
XP_U16 ii;
|
||||
--tiles->nTiles;
|
||||
for ( ii = index; ii < tiles->nTiles; ++ii ) {
|
||||
tiles->tiles[ii] = tiles->tiles[ii+1];
|
||||
}
|
||||
}
|
||||
|
||||
static XP_S16
|
||||
setContains( const TrayTileSet* tiles, Tile tile )
|
||||
{
|
||||
|
@ -2439,23 +2427,6 @@ setContains( const TrayTileSet* tiles, Tile tile )
|
|||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
sortTiles( TrayTileSet* dest, const TrayTileSet* src )
|
||||
{
|
||||
TrayTileSet tmp = *src;
|
||||
dest->nTiles = 0;
|
||||
while ( 0 < tmp.nTiles ) {
|
||||
XP_U16 ii, smallest;
|
||||
for ( smallest = ii = 0; ii < tmp.nTiles; ++ii ) {
|
||||
if ( tmp.tiles[ii] < tmp.tiles[smallest] ) {
|
||||
smallest = ii;
|
||||
}
|
||||
}
|
||||
dest->tiles[dest->nTiles++] = tmp.tiles[smallest];
|
||||
removeTile( &tmp, smallest );
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CPLUS
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -104,9 +104,11 @@ static XP_U32
|
|||
augmentFor( XP_U32 hash, const StackEntry* entry )
|
||||
{
|
||||
switch( entry->moveType ) {
|
||||
case ASSIGN_TYPE:
|
||||
hash = augmentHash( hash, (XP_U8*)&entry->u.assign,
|
||||
sizeof(entry->u.assign) );
|
||||
case ASSIGN_TYPE: {
|
||||
TrayTileSet tiles;
|
||||
sortTiles( &tiles, &entry->u.assign.tiles );
|
||||
hash = augmentHash( hash, (XP_U8*)&tiles, sizeof(tiles) );
|
||||
}
|
||||
break;
|
||||
case MOVE_TYPE:
|
||||
hash = augmentHash( hash, (XP_U8*)&entry->u.move,
|
||||
|
|
|
@ -73,6 +73,33 @@ traySetFromStream( XWStreamCtxt* stream, TrayTileSet* ts )
|
|||
ts->nTiles = (XP_U8)nTiles;
|
||||
} /* traySetFromStream */
|
||||
|
||||
void
|
||||
removeTile( TrayTileSet* tiles, XP_U16 index )
|
||||
{
|
||||
XP_U16 ii;
|
||||
--tiles->nTiles;
|
||||
for ( ii = index; ii < tiles->nTiles; ++ii ) {
|
||||
tiles->tiles[ii] = tiles->tiles[ii+1];
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
sortTiles( TrayTileSet* dest, const TrayTileSet* src )
|
||||
{
|
||||
TrayTileSet tmp = *src;
|
||||
dest->nTiles = 0;
|
||||
while ( 0 < tmp.nTiles ) {
|
||||
XP_U16 ii, smallest;
|
||||
for ( smallest = ii = 0; ii < tmp.nTiles; ++ii ) {
|
||||
if ( tmp.tiles[ii] < tmp.tiles[smallest] ) {
|
||||
smallest = ii;
|
||||
}
|
||||
}
|
||||
dest->tiles[dest->nTiles++] = tmp.tiles[smallest];
|
||||
removeTile( &tmp, smallest );
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
signedToStream( XWStreamCtxt* stream, XP_U16 nBits, XP_S32 num )
|
||||
|
|
|
@ -34,6 +34,8 @@ 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 removeTile( TrayTileSet* tiles, XP_U16 index );
|
||||
|
||||
XP_S32 signedFromStream( XWStreamCtxt* stream, XP_U16 nBits );
|
||||
void signedToStream( XWStreamCtxt* stream, XP_U16 nBits, XP_S32 num );
|
||||
|
|
Loading…
Reference in a new issue