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:
Eric House 2022-01-20 22:07:58 -08:00
parent 4b55b0b873
commit 2d6ce6cfda
5 changed files with 20 additions and 16 deletions

View file

@ -1156,8 +1156,8 @@ board_commitTurn( BoardCtxt* board, XWEnv xwe, XP_Bool phoniesConfirmed,
}
if ( board->skipCommitConfirm || turnConfirmed ) {
XP_U16 nToPick = MAX_TRAY_TILES -
model_getNumTilesInTray( model, selPlayer );
XP_U16 nToPick = board->gi->traySize
- model_getNumTilesInTray( model, selPlayer );
if ( !server_askPickTiles( board->server, xwe, selPlayer, newTiles,
nToPick ) ) {
result = server_commitMove( board->server, xwe, selPlayer,

View file

@ -1419,7 +1419,7 @@ makeRobotMove( ServerCtxt* server, XWEnv xwe )
#ifdef XWFEATURE_SLOW_ROBOT
if ( 0 != server->nv.robotTradePct ) {
XP_ASSERT( ! inDuplicateMode( server ) );
if ( server_countTilesInPool( server ) >= MAX_TRAY_TILES ) {
if ( server_countTilesInPool( server ) >= gi->traySize ) {
XP_U16 pct = XP_RANDOM() % 100;
forceTrade = pct < server->nv.robotTradePct ;
}
@ -1459,7 +1459,7 @@ makeRobotMove( ServerCtxt* server, XWEnv xwe )
XP_Bool trade = forceTrade ||
((newMove.nTiles == 0) && !canMove &&
(server_countTilesInPool( server ) >= MAX_TRAY_TILES));
(server_countTilesInPool( server ) >= gi->traySize));
server->vol.showPrevMove = XP_TRUE;
if ( inDuplicateMode(server) || server->nv.showRobotScores ) {
@ -1640,7 +1640,8 @@ server_tilesPicked( ServerCtxt* server, XWEnv xwe, XP_U16 player,
TrayTileSet newTiles = *newTilesP;
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) );
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_U16 nSoFar = resultTiles->nTiles;
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
const DictionaryCtxt* dict = model_getDictionary( server->vol.model );
#endif
XP_ASSERT( !!pool );
#ifdef FEATURE_TRAY_EDIT
ask = server->vol.gi->allowPickTiles
&& !LP_IS_ROBOT(&server->vol.gi->players[playerNum]);
ask = gi->allowPickTiles
&& !LP_IS_ROBOT(&gi->players[playerNum]);
#else
ask = XP_FALSE;
#endif
@ -2609,7 +2611,7 @@ assignTilesToAll( ServerCtxt* server, XWEnv xwe )
if ( 0 == model_getNumTilesInTray( model, ii ) ) {
if ( pickingTiles && !LP_IS_ROBOT(&gi->players[ii])
&& informNeedPickTiles( server, xwe, XP_TRUE, ii,
MAX_TRAY_TILES ) ) {
gi->traySize ) ) {
allDone = XP_FALSE;
break;
}

View file

@ -1575,7 +1575,7 @@ ask_blank( gpointer data )
CommonGlobals* cGlobals = &globals->cGlobals;
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 );
for ( int ii = 0; ii < cGlobals->nTiles; ++ii ) {
@ -1591,6 +1591,7 @@ ask_blank( gpointer data )
return 0;
}
static void
gtk_util_notifyPickTileBlank( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
XP_U16 playerNum, XP_U16 col,
@ -1619,8 +1620,8 @@ ask_tiles( gpointer data )
XP_UCHAR* name = cGlobals->gi->players[cGlobals->selPlayer].name;
for ( XP_Bool done = XP_FALSE; !done; ) {
XP_S16 picked = gtkletterask( &newTiles, XP_TRUE, name,
cGlobals->nTiles, cGlobals->tiles,
cGlobals->tileCounts );
cGlobals->nToPick, cGlobals->nTiles,
cGlobals->tiles, cGlobals->tileCounts );
switch ( picked ) {
case PICKER_PICKALL:
done = XP_TRUE;

View file

@ -46,7 +46,8 @@ abort_button_event( GtkWidget* widget, gpointer XP_UNUSED(closure) )
XP_S16
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* label;
@ -102,8 +103,8 @@ gtkletterask( const TrayTileSet* curPick, XP_Bool forTray, const XP_UCHAR* name,
gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE );
if ( forTray ) {
char* fmt = "Choose a tile for %s.";
XP_SNPRINTF( buf, sizeof(buf), fmt, name );
char* fmt = "Choose %d tiles for %s.";
XP_SNPRINTF( buf, sizeof(buf), fmt, nToPick, name );
txt = buf;
} else {
txt = "Choose a letter for your blank.";

View file

@ -27,7 +27,7 @@
#include "gtkboard.h"
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,
const XP_U16* counts );