[gnome-chess] Accept CECP resign commands from engines



commit cf2383d138f59b7aad1a4a1e97e86671c4494dfe
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sun Aug 25 10:02:22 2013 -0500

    Accept CECP resign commands from engines
    
    https://bugzilla.gnome.org/show_bug.cgi?id=705012

 src/chess-engine-cecp.vala |    1 +
 src/gnome-chess.vala       |    8 ++++++++
 2 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/src/chess-engine-cecp.vala b/src/chess-engine-cecp.vala
index 3e75183..74ebf69 100644
--- a/src/chess-engine-cecp.vala
+++ b/src/chess-engine-cecp.vala
@@ -71,6 +71,7 @@ public class ChessEngineCECP : ChessEngine
             }
             else if (line == "resign" || line == "tellics resign")
             {
+                resigned ();
             }
             else if (line == "offer draw")
             {
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index 550185d..a8b7450 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -515,6 +515,7 @@ public class Application : Gtk.Application
             opponent_engine.stop ();
             opponent_engine.ready_changed.disconnect (engine_ready_cb);
             opponent_engine.moved.disconnect (engine_move_cb);
+            opponent_engine.resigned.disconnect (engine_resigned_cb);
             opponent_engine.stopped.disconnect (engine_stopped_cb);
             opponent_engine.error.disconnect (engine_error_cb);
             opponent_engine = null;
@@ -547,6 +548,7 @@ public class Application : Gtk.Application
         {
             opponent_engine.ready_changed.connect (engine_ready_cb);
             opponent_engine.moved.connect (engine_move_cb);
+            opponent_engine.resigned.connect (engine_resigned_cb);
             opponent_engine.stopped.connect (engine_stopped_cb);
             opponent_engine.error.connect (engine_error_cb);
             opponent_engine.start ();
@@ -662,8 +664,14 @@ public class Application : Gtk.Application
             game.stop (ChessResult.BUG, ChessRule.BUG);
     }
 
+    private void engine_resigned_cb (ChessEngine engine)
+    {
+        opponent.resign ();
+    }
+
     private void engine_stopped_cb (ChessEngine engine)
     {
+        // FIXME should print a different message than normal resign
         opponent.resign ();
     }
 


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