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



commit 99f5afb96c432b12e4a2b339eb286c8a54617b94
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 f0cf3fb..bb91f32 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -764,6 +764,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]