fix null ptr exception using null engine. Logic error was not exposed

earlier because except in multi-device game the UI would not allow you
to ask an engine-less robot player for a hint.
This commit is contained in:
ehouse 2009-09-25 10:17:35 +00:00
parent f3c27333ec
commit 881639c230

View file

@ -1441,28 +1441,30 @@ board_requestHint( BoardCtxt* board,
const TrayTileSet* tileSet; const TrayTileSet* tileSet;
ModelCtxt* model = board->model; ModelCtxt* model = board->model;
result = !!engine && preflight( board ); if ( !!engine && preflight( board ) ) {
/* undo any current move. otherwise we won't pass the full tray to /* undo any current move. otherwise we won't pass the full tray
the engine. Would it be better, though, to pass the whole tray to the engine. Would it be better, though, to pass the whole
regardless where its contents are? */ tray regardless where its contents are? */
if ( model_getCurrentMoveCount( model, selPlayer ) > 0 ) { if ( model_getCurrentMoveCount( model, selPlayer ) > 0 ) {
model_resetCurrentTurn( model, selPlayer ); model_resetCurrentTurn( model, selPlayer );
/* Draw's a no-op on Wince with a null hdc, but it'll draw again. /* Draw's a no-op on Wince with a null hdc, but it'll draw again.
Should probably define OS_INITS_DRAW on Wince...*/ Should probably define OS_INITS_DRAW on Wince...*/
#ifdef OS_INITS_DRAW #ifdef OS_INITS_DRAW
/* On symbian, it's illegal to draw except from inside the Draw /* On symbian, it's illegal to draw except from inside the
method. But the move search will probably be so fast that it's Draw method. But the move search will probably be so fast
ok to wait until we've found the move anyway. */ that it's ok to wait until we've found the move anyway. */
redraw = XP_TRUE; redraw = XP_TRUE;
#else #else
board_draw( board ); board_draw( board );
#endif #endif
}
tileSet = model_getPlayerTiles( model, selPlayer );
nTiles = tileSet->nTiles - pti->dividerLoc;
result = nTiles > 0;
} }
tileSet = model_getPlayerTiles( model, selPlayer );
nTiles = tileSet->nTiles - pti->dividerLoc;
result = nTiles > 0;
if ( result ) { if ( result ) {
#ifdef XWFEATURE_SEARCHLIMIT #ifdef XWFEATURE_SEARCHLIMIT
BdHintLimits limits; BdHintLimits limits;