fix infinite loop looking for last not-undone move to highlight.

This commit is contained in:
ehouse 2004-05-15 16:06:35 +00:00
parent d0e11a6080
commit 676f049479

View file

@ -540,7 +540,6 @@ model_undoLatestMoves( ModelCtxt* model, PoolContext* pool,
if ( nStackEntries < nMovesSought ) { if ( nStackEntries < nMovesSought ) {
return XP_FALSE; return XP_FALSE;
} else if ( nStackEntries <= model->nPlayers ) { } else if ( nStackEntries <= model->nPlayers ) {
util_userError( model->vol.util, ERR_CANT_UNDO_TILEASSIGN );
return XP_FALSE; return XP_FALSE;
} }
@ -590,13 +589,13 @@ model_undoLatestMoves( ModelCtxt* model, PoolContext* pool,
} }
} }
/* If there's still a move on top of the stack, highlight its tiles since /* Find the first MOVE still on the stack and highlight its tiles since
they're now the most recent move. */ they're now the most recent move. Trades and lost turns ignored. */
nStackEntries = stack_getNEntries( stack );
for ( ; ; ) { for ( ; ; ) {
StackEntry entry; StackEntry entry;
XP_U16 movesLeft = stack_getNEntries( stack ); if ( nStackEntries == 0 ||
if ( movesLeft == 0 || !stack_getNthEntry( stack, nStackEntries - 1, &entry ) ) {
!stack_getNthEntry( stack, movesLeft - 1, &entry ) ) {
break; break;
} }
if ( entry.moveType == MOVE_TYPE ) { if ( entry.moveType == MOVE_TYPE ) {
@ -617,13 +616,16 @@ model_undoLatestMoves( ModelCtxt* model, PoolContext* pool,
*varies = entry.u.move.moveInfo.tiles[nTiles].varCoord; *varies = entry.u.move.moveInfo.tiles[nTiles].varCoord;
tile = getModelTileRaw( model, col, row ); tile = getModelTileRaw( model, col, row );
setModelTileRaw( model, col, row, (CellTile)(tile | PREV_MOVE_BIT) ); setModelTileRaw( model, col, row,
(CellTile)(tile | PREV_MOVE_BIT) );
notifyBoardListeners( model, entry.playerNum, col, row, XP_FALSE ); notifyBoardListeners( model, entry.playerNum, col, row,
XP_FALSE );
} }
break; break;
} else if ( entry.moveType == ASSIGN_TYPE ) { } else if ( entry.moveType == ASSIGN_TYPE ) {
break; break;
} else {
--nStackEntries; /* look at the next one */
} }
} }