diff --git a/xwords4/common/comtypes.h b/xwords4/common/comtypes.h index 8322cbc28..245ba01df 100644 --- a/xwords4/common/comtypes.h +++ b/xwords4/common/comtypes.h @@ -130,6 +130,7 @@ typedef struct CommonPrefs { XP_Bool showRobotScores; /* applies to all games */ XP_Bool hideTileValues; XP_Bool skipCommitConfirm; /* applies to all games */ + XP_Bool sortNewTiles; /* applies to all games */ #ifdef XWFEATURE_SLOW_ROBOT XP_U16 robotThinkMin, robotThinkMax; #endif diff --git a/xwords4/common/server.c b/xwords4/common/server.c index 2f8b8fa80..0119d1e3f 100644 --- a/xwords4/common/server.c +++ b/xwords4/common/server.c @@ -91,6 +91,7 @@ typedef struct ServerNonvolatiles { XP_S8 currentTurn; /* invalid when game is over */ XP_U8 pendingRegistrations; XP_Bool showRobotScores; + XP_Bool sortNewTiles; #ifdef XWFEATURE_SLOW_ROBOT XP_U16 robotThinkMin, robotThinkMax; /* not saved (yet) */ @@ -438,6 +439,7 @@ void server_prefsChanged( ServerCtxt* server, CommonPrefs* cp ) { server->nv.showRobotScores = cp->showRobotScores; + server->nv.sortNewTiles = cp->sortNewTiles; #ifdef XWFEATURE_SLOW_ROBOT server->nv.robotThinkMin = cp->robotThinkMin; server->nv.robotThinkMax = cp->robotThinkMax; @@ -1019,6 +1021,15 @@ clearLocalRobots( ServerCtxt* server ) } /* clearLocalRobots */ #endif +static void +sortTilesIf( ServerCtxt* server, XP_S16 turn ) +{ + ModelCtxt* model = server->vol.model; + if ( server->nv.sortNewTiles ) { + model_sortTiles( model, turn ); + } +} + /* Called in response to message from server listing all the names of * players in the game (in server-assigned order) and their initial * tray contents. @@ -1117,7 +1128,7 @@ client_readInitialMessage( ServerCtxt* server, XWStreamCtxt* stream ) later. */ pool_removeTiles( pool, &tiles ); - model_sortTiles( model, i ); + sortTilesIf( server, i ); } SETSTATE( server, XWSTATE_INTURN ); @@ -1582,7 +1593,7 @@ assignTilesToAll( ServerCtxt* server ) TrayTileSet newTiles; fetchTiles( server, i, numAssigned, NULL, &newTiles ); model_assignPlayerTiles( model, i, &newTiles ); - model_sortTiles( model, i ); + sortTilesIf( server, i ); } } /* assignTilesToAll */ @@ -2031,7 +2042,7 @@ server_commitMove( ServerCtxt* server ) #endif model_commitTurn( model, turn, &newTiles ); - model_sortTiles( model, turn ); + sortTilesIf( server, turn ); if ( !isLegalMove && !isClient ) { badWordMoveUndoAndTellUser( server, &server->illegalWordInfo ); diff --git a/xwords4/linux/gtkmain.c b/xwords4/linux/gtkmain.c index 5f5177903..e21566d0d 100644 --- a/xwords4/linux/gtkmain.c +++ b/xwords4/linux/gtkmain.c @@ -2053,6 +2053,7 @@ gtkmain( LaunchParams* params, int argc, char *argv[] ) globals.cp.showBoardArrow = XP_TRUE; globals.cp.hideTileValues = params->hideValues; globals.cp.skipCommitConfirm = params->skipCommitConfirm; + globals.cp.sortNewTiles = params->sortNewTiles; globals.cp.showColors = params->showColors; globals.cp.showRobotScores = params->showRobotScores; #ifdef XWFEATURE_SLOW_ROBOT diff --git a/xwords4/linux/linuxmain.c b/xwords4/linux/linuxmain.c index 01189d0e5..6885644e4 100644 --- a/xwords4/linux/linuxmain.c +++ b/xwords4/linux/linuxmain.c @@ -209,6 +209,7 @@ usage( char* appName, char* msg ) "\t [-S] # slow robot down \n" "\t [-i] # print game history when game over\n" "\t [-U] # call 'Undo' after game ends\n" + "\t [-O] # sort the tray each time tiles are added\n" #ifdef XWFEATURE_RELAY "\t [-H] # Don't send heartbeats to relay\n" #endif @@ -809,7 +810,7 @@ main( int argc, char** argv ) #if defined PLATFORM_GTK "h:I" #endif - "0b:cod:e:Ff:iKkLlmNn:Pr:Ssq:t:Uw:v" + "0b:cod:e:Ff:iKkLlmNn:OPr:Ssq:t:Uw:v" #ifdef XWFEATURE_SLOW_ROBOT "z:" #endif @@ -923,6 +924,9 @@ main( int argc, char** argv ) mainParams.gi.players[index].name = copyString( mainParams.util->mpool, (XP_UCHAR*)optarg); break; + case 'O': + mainParams.sortNewTiles = XP_TRUE; + break; case 's': isServer = XP_TRUE; break; diff --git a/xwords4/linux/main.h b/xwords4/linux/main.h index 417c61150..e344dde94 100644 --- a/xwords4/linux/main.h +++ b/xwords4/linux/main.h @@ -59,6 +59,7 @@ typedef struct LaunchParams { XP_Bool verticalScore; XP_Bool hideValues; XP_Bool showColors; + XP_Bool sortNewTiles; XP_Bool skipCommitConfirm; XP_Bool needsNewGame; // XP_Bool mainParams;