mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
fix problems with tile picking introduced by 9-tiles
Not sure if these would show up if you're not picking face-up, but if so they justify a release.
This commit is contained in:
parent
4b55b0b873
commit
2d6ce6cfda
5 changed files with 20 additions and 16 deletions
|
@ -1156,8 +1156,8 @@ board_commitTurn( BoardCtxt* board, XWEnv xwe, XP_Bool phoniesConfirmed,
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( board->skipCommitConfirm || turnConfirmed ) {
|
if ( board->skipCommitConfirm || turnConfirmed ) {
|
||||||
XP_U16 nToPick = MAX_TRAY_TILES -
|
XP_U16 nToPick = board->gi->traySize
|
||||||
model_getNumTilesInTray( model, selPlayer );
|
- model_getNumTilesInTray( model, selPlayer );
|
||||||
if ( !server_askPickTiles( board->server, xwe, selPlayer, newTiles,
|
if ( !server_askPickTiles( board->server, xwe, selPlayer, newTiles,
|
||||||
nToPick ) ) {
|
nToPick ) ) {
|
||||||
result = server_commitMove( board->server, xwe, selPlayer,
|
result = server_commitMove( board->server, xwe, selPlayer,
|
||||||
|
|
|
@ -1419,7 +1419,7 @@ makeRobotMove( ServerCtxt* server, XWEnv xwe )
|
||||||
#ifdef XWFEATURE_SLOW_ROBOT
|
#ifdef XWFEATURE_SLOW_ROBOT
|
||||||
if ( 0 != server->nv.robotTradePct ) {
|
if ( 0 != server->nv.robotTradePct ) {
|
||||||
XP_ASSERT( ! inDuplicateMode( server ) );
|
XP_ASSERT( ! inDuplicateMode( server ) );
|
||||||
if ( server_countTilesInPool( server ) >= MAX_TRAY_TILES ) {
|
if ( server_countTilesInPool( server ) >= gi->traySize ) {
|
||||||
XP_U16 pct = XP_RANDOM() % 100;
|
XP_U16 pct = XP_RANDOM() % 100;
|
||||||
forceTrade = pct < server->nv.robotTradePct ;
|
forceTrade = pct < server->nv.robotTradePct ;
|
||||||
}
|
}
|
||||||
|
@ -1459,7 +1459,7 @@ makeRobotMove( ServerCtxt* server, XWEnv xwe )
|
||||||
|
|
||||||
XP_Bool trade = forceTrade ||
|
XP_Bool trade = forceTrade ||
|
||||||
((newMove.nTiles == 0) && !canMove &&
|
((newMove.nTiles == 0) && !canMove &&
|
||||||
(server_countTilesInPool( server ) >= MAX_TRAY_TILES));
|
(server_countTilesInPool( server ) >= gi->traySize));
|
||||||
|
|
||||||
server->vol.showPrevMove = XP_TRUE;
|
server->vol.showPrevMove = XP_TRUE;
|
||||||
if ( inDuplicateMode(server) || server->nv.showRobotScores ) {
|
if ( inDuplicateMode(server) || server->nv.showRobotScores ) {
|
||||||
|
@ -1640,7 +1640,8 @@ server_tilesPicked( ServerCtxt* server, XWEnv xwe, XP_U16 player,
|
||||||
TrayTileSet newTiles = *newTilesP;
|
TrayTileSet newTiles = *newTilesP;
|
||||||
pool_removeTiles( server->pool, &newTiles );
|
pool_removeTiles( server->pool, &newTiles );
|
||||||
|
|
||||||
fetchTiles( server, xwe, player, MAX_TRAY_TILES, NULL, &newTiles, XP_FALSE );
|
fetchTiles( server, xwe, player, server->vol.gi->traySize,
|
||||||
|
NULL, &newTiles, XP_FALSE );
|
||||||
XP_ASSERT( !inDuplicateMode(server) );
|
XP_ASSERT( !inDuplicateMode(server) );
|
||||||
model_assignPlayerTiles( server->vol.model, player, &newTiles );
|
model_assignPlayerTiles( server->vol.model, player, &newTiles );
|
||||||
|
|
||||||
|
@ -2476,15 +2477,16 @@ fetchTiles( ServerCtxt* server, XWEnv xwe, XP_U16 playerNum, XP_U16 nToFetch,
|
||||||
XP_Bool ask;
|
XP_Bool ask;
|
||||||
XP_U16 nSoFar = resultTiles->nTiles;
|
XP_U16 nSoFar = resultTiles->nTiles;
|
||||||
PoolContext* pool = server->pool;
|
PoolContext* pool = server->pool;
|
||||||
const XP_UCHAR* curTray[MAX_TRAY_TILES];
|
const CurGameInfo* gi = server->vol.gi;
|
||||||
|
const XP_UCHAR* curTray[gi->traySize];
|
||||||
#ifdef FEATURE_TRAY_EDIT
|
#ifdef FEATURE_TRAY_EDIT
|
||||||
const DictionaryCtxt* dict = model_getDictionary( server->vol.model );
|
const DictionaryCtxt* dict = model_getDictionary( server->vol.model );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
XP_ASSERT( !!pool );
|
XP_ASSERT( !!pool );
|
||||||
#ifdef FEATURE_TRAY_EDIT
|
#ifdef FEATURE_TRAY_EDIT
|
||||||
ask = server->vol.gi->allowPickTiles
|
ask = gi->allowPickTiles
|
||||||
&& !LP_IS_ROBOT(&server->vol.gi->players[playerNum]);
|
&& !LP_IS_ROBOT(&gi->players[playerNum]);
|
||||||
#else
|
#else
|
||||||
ask = XP_FALSE;
|
ask = XP_FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
@ -2609,7 +2611,7 @@ assignTilesToAll( ServerCtxt* server, XWEnv xwe )
|
||||||
if ( 0 == model_getNumTilesInTray( model, ii ) ) {
|
if ( 0 == model_getNumTilesInTray( model, ii ) ) {
|
||||||
if ( pickingTiles && !LP_IS_ROBOT(&gi->players[ii])
|
if ( pickingTiles && !LP_IS_ROBOT(&gi->players[ii])
|
||||||
&& informNeedPickTiles( server, xwe, XP_TRUE, ii,
|
&& informNeedPickTiles( server, xwe, XP_TRUE, ii,
|
||||||
MAX_TRAY_TILES ) ) {
|
gi->traySize ) ) {
|
||||||
allDone = XP_FALSE;
|
allDone = XP_FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1575,7 +1575,7 @@ ask_blank( gpointer data )
|
||||||
CommonGlobals* cGlobals = &globals->cGlobals;
|
CommonGlobals* cGlobals = &globals->cGlobals;
|
||||||
|
|
||||||
XP_UCHAR* name = globals->cGlobals.gi->players[cGlobals->selPlayer].name;
|
XP_UCHAR* name = globals->cGlobals.gi->players[cGlobals->selPlayer].name;
|
||||||
XP_S16 result = gtkletterask( NULL, XP_FALSE, name,
|
XP_S16 result = gtkletterask( NULL, XP_FALSE, name, 1,
|
||||||
cGlobals->nTiles, cGlobals->tiles, NULL );
|
cGlobals->nTiles, cGlobals->tiles, NULL );
|
||||||
|
|
||||||
for ( int ii = 0; ii < cGlobals->nTiles; ++ii ) {
|
for ( int ii = 0; ii < cGlobals->nTiles; ++ii ) {
|
||||||
|
@ -1591,6 +1591,7 @@ ask_blank( gpointer data )
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_util_notifyPickTileBlank( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
|
gtk_util_notifyPickTileBlank( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
|
||||||
XP_U16 playerNum, XP_U16 col,
|
XP_U16 playerNum, XP_U16 col,
|
||||||
|
@ -1619,8 +1620,8 @@ ask_tiles( gpointer data )
|
||||||
XP_UCHAR* name = cGlobals->gi->players[cGlobals->selPlayer].name;
|
XP_UCHAR* name = cGlobals->gi->players[cGlobals->selPlayer].name;
|
||||||
for ( XP_Bool done = XP_FALSE; !done; ) {
|
for ( XP_Bool done = XP_FALSE; !done; ) {
|
||||||
XP_S16 picked = gtkletterask( &newTiles, XP_TRUE, name,
|
XP_S16 picked = gtkletterask( &newTiles, XP_TRUE, name,
|
||||||
cGlobals->nTiles, cGlobals->tiles,
|
cGlobals->nToPick, cGlobals->nTiles,
|
||||||
cGlobals->tileCounts );
|
cGlobals->tiles, cGlobals->tileCounts );
|
||||||
switch ( picked ) {
|
switch ( picked ) {
|
||||||
case PICKER_PICKALL:
|
case PICKER_PICKALL:
|
||||||
done = XP_TRUE;
|
done = XP_TRUE;
|
||||||
|
|
|
@ -46,7 +46,8 @@ abort_button_event( GtkWidget* widget, gpointer XP_UNUSED(closure) )
|
||||||
|
|
||||||
XP_S16
|
XP_S16
|
||||||
gtkletterask( const TrayTileSet* curPick, XP_Bool forTray, const XP_UCHAR* name,
|
gtkletterask( const TrayTileSet* curPick, XP_Bool forTray, const XP_UCHAR* name,
|
||||||
XP_U16 nTiles, const XP_UCHAR** texts, const XP_U16* counts )
|
XP_U16 nToPick, XP_U16 nTiles, const XP_UCHAR** texts,
|
||||||
|
const XP_U16* counts )
|
||||||
{
|
{
|
||||||
GtkWidget* dialog;
|
GtkWidget* dialog;
|
||||||
GtkWidget* label;
|
GtkWidget* label;
|
||||||
|
@ -102,8 +103,8 @@ gtkletterask( const TrayTileSet* curPick, XP_Bool forTray, const XP_UCHAR* name,
|
||||||
gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE );
|
gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE );
|
||||||
|
|
||||||
if ( forTray ) {
|
if ( forTray ) {
|
||||||
char* fmt = "Choose a tile for %s.";
|
char* fmt = "Choose %d tiles for %s.";
|
||||||
XP_SNPRINTF( buf, sizeof(buf), fmt, name );
|
XP_SNPRINTF( buf, sizeof(buf), fmt, nToPick, name );
|
||||||
txt = buf;
|
txt = buf;
|
||||||
} else {
|
} else {
|
||||||
txt = "Choose a letter for your blank.";
|
txt = "Choose a letter for your blank.";
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "gtkboard.h"
|
#include "gtkboard.h"
|
||||||
|
|
||||||
XP_S16 gtkletterask( const TrayTileSet* curPick, XP_Bool forTray,
|
XP_S16 gtkletterask( const TrayTileSet* curPick, XP_Bool forTray,
|
||||||
const XP_UCHAR* name,
|
const XP_UCHAR* name, XP_U16 nToPick,
|
||||||
XP_U16 nTiles, const XP_UCHAR** texts,
|
XP_U16 nTiles, const XP_UCHAR** texts,
|
||||||
const XP_U16* counts );
|
const XP_U16* counts );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue