mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-29 10:26:36 +01:00
add isLocal param to server_getCurrentTurn
I want to store this information separately in summaries tables so e.g. games can be displayed sorted by whether it's the local player's turn.
This commit is contained in:
parent
926f069313
commit
4c923ead08
8 changed files with 27 additions and 20 deletions
|
@ -1661,8 +1661,10 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1summarize
|
|||
setInt( env, jsummary, "nMoves", nMoves );
|
||||
XP_Bool gameOver = server_getGameIsOver( state->game.server );
|
||||
setBool( env, jsummary, "gameOver", gameOver );
|
||||
XP_Bool isLocal;
|
||||
setInt( env, jsummary, "turn",
|
||||
server_getCurrentTurn( state->game.server ) );
|
||||
server_getCurrentTurn( state->game.server, &isLocal ) );
|
||||
// setBool( env, jsummary, "turnIsLocal", isLocal );
|
||||
setInt( env, jsummary, "lastMoveTime",
|
||||
server_getLastMoveTime(state->game.server) );
|
||||
|
||||
|
|
|
@ -792,7 +792,7 @@ board_canShuffle( const BoardCtxt* board )
|
|||
XP_Bool
|
||||
board_canHideRack( const BoardCtxt* board )
|
||||
{
|
||||
XP_Bool result = 0 <= server_getCurrentTurn( board->server )
|
||||
XP_Bool result = 0 <= server_getCurrentTurn( board->server, NULL )
|
||||
&& (board->boardObscuresTray || !board->gameOver);
|
||||
return result;
|
||||
}
|
||||
|
@ -988,7 +988,7 @@ warnBadWords( const XP_UCHAR* word, XP_Bool isLegal,
|
|||
if ( !isLegal ) {
|
||||
BadWordInfo bwi = {0};
|
||||
BoardCtxt* board = (BoardCtxt*)closure;
|
||||
XP_S16 turn = server_getCurrentTurn( board->server );
|
||||
XP_S16 turn = server_getCurrentTurn( board->server, NULL );
|
||||
|
||||
bwi.nWords = 1;
|
||||
bwi.words[0] = word;
|
||||
|
@ -1019,7 +1019,7 @@ XP_Bool
|
|||
board_commitTurn( BoardCtxt* board )
|
||||
{
|
||||
XP_Bool result = XP_FALSE;
|
||||
const XP_S16 turn = server_getCurrentTurn( board->server );
|
||||
const XP_S16 turn = server_getCurrentTurn( board->server, NULL );
|
||||
PerTurnInfo* pti = board->pti + turn;
|
||||
|
||||
if ( board->gameOver || turn < 0 ) {
|
||||
|
@ -1110,15 +1110,15 @@ static void
|
|||
selectPlayerImpl( BoardCtxt* board, XP_U16 newPlayer, XP_Bool reveal,
|
||||
XP_Bool canPeek )
|
||||
{
|
||||
XP_S16 curTurn = server_getCurrentTurn(board->server);
|
||||
XP_Bool isLocal;
|
||||
XP_S16 curTurn = server_getCurrentTurn( board->server, &isLocal );
|
||||
if ( !board->gameOver && curTurn < 0 ) {
|
||||
/* game not started yet; do nothing */
|
||||
} else if ( board->selPlayer == newPlayer ) {
|
||||
if ( reveal ) {
|
||||
checkRevealTray( board );
|
||||
}
|
||||
} else if ( canPeek || ((newPlayer == curTurn)
|
||||
&& LP_IS_LOCAL( &board->gi->players[newPlayer]))) {
|
||||
} else if ( canPeek || ((newPlayer == curTurn) && isLocal)) {
|
||||
PerTurnInfo* newInfo = &board->pti[newPlayer];
|
||||
XP_U16 oldPlayer = board->selPlayer;
|
||||
model_foreachPendingCell( board->model, newPlayer,
|
||||
|
@ -1318,7 +1318,7 @@ timerFiredForTimer( BoardCtxt* board )
|
|||
{
|
||||
board->timerPending = XP_FALSE;
|
||||
if ( !board->gameOver ) {
|
||||
XP_S16 turn = server_getCurrentTurn( board->server );
|
||||
XP_S16 turn = server_getCurrentTurn( board->server, NULL );
|
||||
|
||||
if ( turn >= 0 ) {
|
||||
++board->gi->players[turn].secondsUsed;
|
||||
|
@ -1365,7 +1365,8 @@ board_pushTimerSave( BoardCtxt* board )
|
|||
if ( board->timerSaveCount++ == 0 ) {
|
||||
board->timerStoppedTime = util_getCurSeconds( board->util );
|
||||
#ifdef DEBUG
|
||||
board->timerStoppedTurn = server_getCurrentTurn( board->server );
|
||||
board->timerStoppedTurn = server_getCurrentTurn( board->server,
|
||||
NULL );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -1380,7 +1381,7 @@ board_popTimerSave( BoardCtxt* board )
|
|||
between calls to board_pushTimerSave and this call, as can happen on
|
||||
franklin. So that's not an error. */
|
||||
if ( board->timerSaveCount > 0 ) {
|
||||
XP_S16 turn = server_getCurrentTurn( board->server );
|
||||
XP_S16 turn = server_getCurrentTurn( board->server, NULL );
|
||||
|
||||
XP_ASSERT( board->timerStoppedTurn == turn );
|
||||
|
||||
|
@ -1769,7 +1770,7 @@ chooseBestSelPlayer( BoardCtxt* board )
|
|||
return board->selPlayer;
|
||||
} else {
|
||||
|
||||
XP_S16 curTurn = server_getCurrentTurn( server );
|
||||
XP_S16 curTurn = server_getCurrentTurn( server, NULL );
|
||||
|
||||
if ( curTurn >= 0 ) {
|
||||
XP_U16 nPlayers = board->gi->nPlayers;
|
||||
|
@ -2001,7 +2002,7 @@ static XP_Bool
|
|||
preflight( BoardCtxt* board, XP_Bool reveal )
|
||||
{
|
||||
return !board->gameOver
|
||||
&& server_getCurrentTurn(board->server) >= 0
|
||||
&& server_getCurrentTurn(board->server, NULL) >= 0
|
||||
&& ( !reveal || checkRevealTray( board ) )
|
||||
&& !TRADE_IN_PROGRESS(board);
|
||||
} /* preflight */
|
||||
|
@ -2581,7 +2582,7 @@ askRevealTray( BoardCtxt* board )
|
|||
|
||||
if ( board->gameOver ) {
|
||||
revealed = XP_TRUE;
|
||||
} else if ( server_getCurrentTurn( board->server ) < 0 ) {
|
||||
} else if ( server_getCurrentTurn( board->server, NULL ) < 0 ) {
|
||||
revealed = XP_FALSE;
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
} else if ( !lp->isLocal ) {
|
||||
|
|
|
@ -240,7 +240,7 @@ struct BoardCtxt {
|
|||
# define valHintMiniWindowActive( board ) \
|
||||
((XP_Bool)((board)->miniWindowStuff[MINIWINDOW_VALHINT].text != NULL))
|
||||
#endif
|
||||
#define MY_TURN(b) ((b)->selPlayer == server_getCurrentTurn( (b)->server ))
|
||||
#define MY_TURN(b) ((b)->selPlayer == server_getCurrentTurn( (b)->server, NULL ))
|
||||
#define TRADE_IN_PROGRESS(b) ((b)->selInfo->tradeInProgress==XP_TRUE)
|
||||
|
||||
/* tray-related functions */
|
||||
|
|
|
@ -176,7 +176,7 @@ drawScoreBoard( BoardCtxt* board )
|
|||
XP_ASSERT( nPlayers <= MAX_NUM_PLAYERS );
|
||||
if ( nPlayers > 0 ) {
|
||||
ModelCtxt* model = board->model;
|
||||
XP_S16 curTurn = server_getCurrentTurn( board->server );
|
||||
XP_S16 curTurn = server_getCurrentTurn( board->server, NULL );
|
||||
XP_U16 selPlayer = board->selPlayer;
|
||||
XP_S16 nTilesInPool = server_countTilesInPool( board->server );
|
||||
XP_Rect scoreRect = board->scoreBdBounds;
|
||||
|
|
|
@ -2435,9 +2435,13 @@ server_commitTrade( ServerCtxt* server, const TrayTileSet* oldTiles )
|
|||
} /* server_commitTrade */
|
||||
|
||||
XP_S16
|
||||
server_getCurrentTurn( ServerCtxt* server )
|
||||
server_getCurrentTurn( ServerCtxt* server, XP_Bool* isLocal )
|
||||
{
|
||||
return server->nv.currentTurn;
|
||||
XP_S16 turn = server->nv.currentTurn;
|
||||
if ( NULL != isLocal && turn >= 0 ) {
|
||||
*isLocal = server->vol.gi->players[turn].isLocal;
|
||||
}
|
||||
return turn;
|
||||
} /* server_getCurrentTurn */
|
||||
|
||||
XP_Bool
|
||||
|
|
|
@ -94,7 +94,7 @@ XP_U16 server_secondsUsedBy( ServerCtxt* server, XP_U16 playerNum );
|
|||
XP_Bool server_handleUndo( ServerCtxt* server, XP_U16 limit );
|
||||
|
||||
/* signed because negative number means nobody's turn yet */
|
||||
XP_S16 server_getCurrentTurn( ServerCtxt* server );
|
||||
XP_S16 server_getCurrentTurn( ServerCtxt* server, XP_Bool* isLocal );
|
||||
XP_Bool server_getGameIsOver( ServerCtxt* server );
|
||||
/* return bitvector marking players still not arrived in networked game */
|
||||
XP_U16 server_getMissingPlayers( const ServerCtxt* server );
|
||||
|
|
|
@ -339,7 +339,7 @@ drawPendingScore( BoardCtxt* board, XP_S16 turnScore, XP_Bool hasCursor )
|
|||
/* Draw the pending score down in the last tray's rect */
|
||||
if ( countTilesToShow( board ) < MAX_TRAY_TILES ) {
|
||||
XP_U16 selPlayer = board->selPlayer;
|
||||
XP_S16 curTurn = server_getCurrentTurn( board->server );
|
||||
XP_S16 curTurn = server_getCurrentTurn( board->server, NULL );
|
||||
XP_Rect lastTileR;
|
||||
|
||||
figureTrayTileRect( board, MAX_TRAY_TILES-1, &lastTileR );
|
||||
|
|
|
@ -197,7 +197,7 @@ summarize( CommonGlobals* cGlobals )
|
|||
{
|
||||
XP_S16 nMoves = model_getNMoves( cGlobals->game.model );
|
||||
XP_Bool gameOver = server_getGameIsOver( cGlobals->game.server );
|
||||
XP_S16 turn = server_getCurrentTurn( cGlobals->game.server );
|
||||
XP_S16 turn = server_getCurrentTurn( cGlobals->game.server, NULL );
|
||||
XP_U32 lastMoveTime = server_getLastMoveTime( cGlobals->game.server );
|
||||
XP_U16 seed = 0;
|
||||
XP_S16 nMissing = 0;
|
||||
|
|
Loading…
Reference in a new issue