From 5b33df4e25f4acff7eb1152ed79a662c9c1a5ec8 Mon Sep 17 00:00:00 2001 From: Andy2 Date: Fri, 29 Oct 2010 19:52:15 -0700 Subject: [PATCH] modify model_getTile to take NULL for out parms where the result is often ignored, then pass NULL instead of the address of variables called 'ignore'. Should be no behavior change. --- xwords4/common/board.c | 19 +++++++------------ xwords4/common/dragdrpp.c | 3 +-- xwords4/common/engine.c | 4 ++-- xwords4/common/model.c | 14 ++++++++++---- xwords4/common/mscore.c | 6 ++---- 5 files changed, 22 insertions(+), 24 deletions(-) diff --git a/xwords4/common/board.c b/xwords4/common/board.c index 3832b47c9..b0d3fb250 100644 --- a/xwords4/common/board.c +++ b/xwords4/common/board.c @@ -1215,10 +1215,8 @@ invalCellsWithTiles( BoardCtxt* board ) */ for ( row = model_numRows( model )-1; row >= 0; --row ) { for ( col = model_numCols( model )-1; col >= 0; --col ) { - Tile tile; - XP_Bool ignore; if ( model_getTile( model, col, row, includePending, - turn, &tile, &ignore, &ignore, &ignore ) ) { + turn, NULL, NULL, NULL, NULL ) ) { XP_U16 boardCol, boardRow; flipIf( board, col, row, &boardCol, &boardRow ); invalCell( board, boardCol, boardRow ); @@ -2327,13 +2325,12 @@ cellOccupied( const BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool inclPending ) { Tile tile; - XP_Bool ignr; XP_Bool result; flipIf( board, col, row, &col, &row ); result = model_getTile( board->model, col, row, inclPending, board->selPlayer, &tile, - &ignr, &ignr, &ignr ); + NULL, NULL, NULL ); return result; } /* cellOccupied */ @@ -2379,13 +2376,13 @@ XP_Bool holdsPendingTile( BoardCtxt* board, XP_U16 pencol, XP_U16 penrow ) { Tile tile; - XP_Bool ignore, isPending; + XP_Bool isPending; XP_U16 modcol, modrow; flipIf( board, pencol, penrow, &modcol, &modrow ); return model_getTile( board->model, modcol, modrow, XP_TRUE, - board->selPlayer, &tile, &ignore, &isPending, - (XP_Bool*)NULL ) + board->selPlayer, &tile, NULL, &isPending, + NULL ) && isPending; } /* holdsPendingTile */ @@ -3232,16 +3229,14 @@ boardCellChanged( void* p_board, XP_U16 turn, XP_U16 modelCol, XP_U16 modelRow, XP_Bool added ) { BoardCtxt* board = (BoardCtxt*)p_board; - XP_Bool pending, found, ignoreBlank; - Tile ignoreTile; + XP_Bool pending, found; XP_U16 col, row; flipIf( board, modelCol, modelRow, &col, &row ); /* for each player, check if the tile overwrites the cursor */ found = model_getTile( board->model, modelCol, modelRow, XP_TRUE, turn, - &ignoreTile, &ignoreBlank, &pending, - (XP_Bool*)NULL ); + NULL, NULL, &pending, NULL ); XP_ASSERT( !added || found ); /* if added is true so must found be */ diff --git a/xwords4/common/dragdrpp.c b/xwords4/common/dragdrpp.c index 92860bfc3..ec6d933d2 100644 --- a/xwords4/common/dragdrpp.c +++ b/xwords4/common/dragdrpp.c @@ -91,14 +91,13 @@ ddStartBoard( BoardCtxt* board, XP_U16 xx, XP_U16 yy ) trayVisible = board->trayVisState == TRAY_REVEALED; if ( trayVisible && holdsPendingTile( board, col, row ) ) { XP_U16 modelc, modelr; - XP_Bool ignore; ds->dtype = DT_TILE; flipIf( board, col, row, &modelc, &modelr ); found = model_getTile( board->model, modelc, modelr, XP_TRUE, board->selPlayer, &ds->tile, &ds->isBlank, - &ignore, &ignore ); + NULL, NULL ); XP_ASSERT( found ); } else { /* If we're not dragging a tile, we can either drag the board (scroll) diff --git a/xwords4/common/engine.c b/xwords4/common/engine.c index b9c6cf0ed..eb32eacad 100644 --- a/xwords4/common/engine.c +++ b/xwords4/common/engine.c @@ -732,7 +732,7 @@ localGetBoardTile( EngineCtxt* engine, XP_U16 col, XP_U16 row, XP_Bool substBlank ) { Tile result; - XP_Bool isBlank, ignore; + XP_Bool isBlank; if ( !engine->searchHorizontal ) { XP_U16 tmp = col; @@ -742,7 +742,7 @@ localGetBoardTile( EngineCtxt* engine, XP_U16 col, XP_U16 row, if ( model_getTile( engine->model, col, row, XP_FALSE, 0, /* don't get pending, so turn doesn't matter */ - &result, &isBlank, &ignore, (XP_Bool*)NULL ) ) { + &result, &isBlank, NULL, NULL ) ) { if ( isBlank && substBlank ) { result = engine->blankTile; } diff --git a/xwords4/common/model.c b/xwords4/common/model.c index 4b87f24fd..2f54db3c7 100644 --- a/xwords4/common/model.c +++ b/xwords4/common/model.c @@ -327,10 +327,16 @@ model_getTile( const ModelCtxt* model, XP_U16 col, XP_U16 row, if ( (cellTile & TILE_EMPTY_BIT) != 0 ) { return XP_FALSE; } - - *tileP = cellTile & TILE_VALUE_MASK; - *isBlank = IS_BLANK(cellTile); - *pendingP = pending; + + if ( NULL != tileP ) { + *tileP = cellTile & TILE_VALUE_MASK; + } + if ( NULL != isBlank ) { + *isBlank = IS_BLANK(cellTile); + } + if ( NULL != pendingP ) { + *pendingP = pending; + } if ( !!recentP ) { *recentP = (cellTile & PREV_MOVE_BIT) != 0; } diff --git a/xwords4/common/mscore.c b/xwords4/common/mscore.c index 917ff2631..e8b3279c4 100644 --- a/xwords4/common/mscore.c +++ b/xwords4/common/mscore.c @@ -317,11 +317,10 @@ static XP_Bool modelIsEmptyAt( const ModelCtxt* model, XP_U16 col, XP_U16 row ) { Tile tile; - XP_Bool ignore; XP_Bool found; found = model_getTile( model, col, row, XP_FALSE, -1, &tile, - &ignore, &ignore, (XP_Bool*)NULL ); + NULL, NULL, NULL ); return !found; } /* modelIsEmptyAt */ @@ -643,11 +642,10 @@ scoreWord( const ModelCtxt* model, MoveInfo* movei, /* new tiles */ ++tiles; --nTiles; } else { /* placed on the board before this move */ - XP_Bool ignore; tileMultiplier = 1; (void)model_getTile( model, col, row, XP_FALSE, -1, &tile, - &isBlank, &ignore, (XP_Bool*)NULL ); + &isBlank, NULL, NULL ); XP_ASSERT( (tile & TILE_VALUE_MASK) == tile ); }