[gnome-chess/gnome-3-36] Fix "engine error" after user resigns before engine moves



commit 69a0e3168e8c53c2c4ef733bbbf01b78643a5179
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Fri Dec 4 18:45:53 2020 -0600

    Fix "engine error" after user resigns before engine moves
    
    If the user has resigned, the engine doesn't know the game is over,
    because we don't tell it. So if the user resigns immediately after
    moving, and the engine has not moved yet, we need to ignore it when it
    does.
    
    Fixes #49

 src/gnome-chess.vala | 7 +++++++
 1 file changed, 7 insertions(+)
---
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index a91e25d..da0cc2f 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -767,6 +767,13 @@ Copyright © 2015–2016 Sahil Sareen""";
         var original_game = game;
         var original_state = game.current_state;
 
+        /* We don't inform the engine that the game has ended when the user
+         * resigns. So if the game is over, and the next game has not yet
+         * begun, we need to ignore it.
+         */
+        if (!game.is_started)
+            return;
+
         if (!game.is_paused)
         {
             do_engine_move (move);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]