Fix claim draw dialog appearing for moves through history
Using the history viewer should not trigger the claim draw dialog. I noticed this because there's a big warning comment in game_turn_cb() saying to not use it for anything related to the game itself, yet here it was. Note I add one additional check here, to mave sure the game has not ended before telling the engine to move. Note also that this makes every move 0.1s slower than before... that seems fine.
This commit is contained in:
parent
384ebe0120
commit
be944e49cc
1 changed files with 16 additions and 12 deletions
|
@ -874,12 +874,6 @@ Copyright © 2015–2016 Sahil Sareen""";
|
||||||
|
|
||||||
if (game.clock != null)
|
if (game.clock != null)
|
||||||
enable_window_action (PAUSE_RESUME_ACTION_NAME);
|
enable_window_action (PAUSE_RESUME_ACTION_NAME);
|
||||||
|
|
||||||
/* FIXME: This looks like the wrong place for this, as per the
|
|
||||||
* warning comment just above.
|
|
||||||
*/
|
|
||||||
if (game.can_claim_draw ())
|
|
||||||
present_claim_draw_dialog ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void set_move_text (Gtk.TreeIter iter, ChessMove move)
|
private void set_move_text (Gtk.TreeIter iter, ChessMove move)
|
||||||
|
@ -1127,13 +1121,23 @@ Copyright © 2015–2016 Sahil Sareen""";
|
||||||
|
|
||||||
view.queue_draw ();
|
view.queue_draw ();
|
||||||
|
|
||||||
if (opponent_engine != null)
|
/* Remaining work goes in a timeout to give the game widget a chance to
|
||||||
{
|
* redraw first, so the pieces are shown to move before displaying the
|
||||||
opponent_engine.report_move (move);
|
* claim draw dialog. */
|
||||||
|
Timeout.add(100, () => {
|
||||||
|
if (game.can_claim_draw ())
|
||||||
|
present_claim_draw_dialog ();
|
||||||
|
|
||||||
if (move.piece.color != opponent.color && !starting)
|
if (opponent_engine != null)
|
||||||
opponent_engine.move ();
|
{
|
||||||
}
|
opponent_engine.report_move (move);
|
||||||
|
|
||||||
|
if (move.piece.color != opponent.color && !starting && game.is_started)
|
||||||
|
opponent_engine.move ();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Source.REMOVE;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void game_undo_cb (ChessGame game)
|
private void game_undo_cb (ChessGame game)
|
||||||
|
|
Loading…
Reference in a new issue