diff --git a/common/board.c b/common/board.c index 6021ccd3c..151f59039 100644 --- a/common/board.c +++ b/common/board.c @@ -624,13 +624,15 @@ board_commitTurn( BoardCtxt* board ) * cursor and tray traySelBits. Others, such as the miniwindow stuff, are * singletons that may have to be hidden or shown. */ -void -board_selectPlayer( BoardCtxt* board, XP_U16 newPlayer ) +static void +selectPlayerImpl( BoardCtxt* board, XP_U16 newPlayer, XP_Bool reveal ) { if ( !board->gameOver && server_getCurrentTurn(board->server) < 0 ) { /* game not started yet; do nothing */ } else if ( board->selPlayer == newPlayer ) { - checkRevealTray( board ); + if ( reveal ) { + checkRevealTray( board ); + } } else { XP_U16 oldPlayer = board->selPlayer; model_foreachPendingCell( board->model, newPlayer, @@ -677,6 +679,12 @@ board_selectPlayer( BoardCtxt* board, XP_U16 newPlayer ) } board->scoreBoardInvalid = XP_TRUE; /* if only one player, number of tiles remaining may have changed*/ +} /* selectPlayerImpl */ + +void +board_selectPlayer( BoardCtxt* board, XP_U16 newPlayer ) +{ + selectPlayerImpl( board, newPlayer, XP_TRUE ); } /* board_selectPlayer */ void @@ -3349,7 +3357,8 @@ boardTurnChanged( void* p_board ) nextPlayer = chooseBestSelPlayer( board ); if ( nextPlayer >= 0 ) { - board_selectPlayer( board, nextPlayer ); + XP_U16 nHumans = gi_countLocalHumans( board->gi ); + selectPlayerImpl( board, nextPlayer, nHumans <= 1 ); } setTimerIf( board ); diff --git a/common/game.c b/common/game.c index e30a9139c..080ef0ae0 100644 --- a/common/game.c +++ b/common/game.c @@ -346,17 +346,19 @@ gi_copy( MPFORMAL CurGameInfo* destGI, CurGameInfo* srcGI ) } /* gi_copy */ XP_U16 -gi_countHumans( const CurGameInfo* gi ) +gi_countLocalHumans( const CurGameInfo* gi ) { XP_U16 count = 0; XP_U16 nPlayers = gi->nPlayers; + const LocalPlayer* lp = gi->players; while ( nPlayers-- ) { - if ( !gi->players[nPlayers].isRobot ) { + if ( lp->isLocal && !lp->isRobot ) { ++count; } + ++lp; } return count; -} /* gi_countHumans */ +} /* gi_countLocalHumans */ void gi_readFromStream( MPFORMAL XWStreamCtxt* stream, CurGameInfo* gi ) diff --git a/common/game.h b/common/game.h index 6c348197f..913f2d907 100644 --- a/common/game.h +++ b/common/game.h @@ -101,7 +101,7 @@ void gi_disposePlayerInfo( MPFORMAL CurGameInfo* gi ); void gi_writeToStream( XWStreamCtxt* stream, const CurGameInfo* gi ); void gi_readFromStream( MPFORMAL XWStreamCtxt* stream, CurGameInfo* gi ); void gi_copy( MPFORMAL CurGameInfo* destGI, CurGameInfo* srcGi ); -XP_U16 gi_countHumans( const CurGameInfo* gi ); +XP_U16 gi_countLocalHumans( const CurGameInfo* gi ); XP_Bool player_hasPasswd( LocalPlayer* player ); XP_Bool player_passwordMatches( LocalPlayer* player, XP_U8* buf, XP_U16 len ); diff --git a/palm/palmmain.c b/palm/palmmain.c index a1010fb7a..e7ff351d3 100644 --- a/palm/palmmain.c +++ b/palm/palmmain.c @@ -1246,7 +1246,7 @@ saveOpenGame( PalmAppGlobals* globals ) const XP_UCHAR* dictName; char namebuf[MAX_GAMENAME_LENGTH]; - if ( gi_countHumans( &globals->gameInfo ) > 1 ) { + if ( gi_countLocalHumans( &globals->gameInfo ) > 1 ) { board_hideTray( globals->game.board ); /* so won't be visible when next opened */ } @@ -1456,7 +1456,7 @@ eventLoop( PalmAppGlobals* globals ) && !!globals->game.board ) { if ( !globals->menuIsDown /* hi Marcus :-) */ && closeNonMainForms(globals) - && gi_countHumans( &globals->gameInfo ) > 1 + && gi_countLocalHumans( &globals->gameInfo ) > 1 && board_hideTray( globals->game.board ) ) { board_draw( globals->game.board ); }