[gnome-chess] Load completed saved games properly



commit 4a3ccef9b32de00885027f4b54016206e3564377
Author: Sahil Sareen <sahil sareen hotmail com>
Date:   Sun Dec 28 21:24:47 2014 +0530

    Load completed saved games properly
    
    Update game.result from the pgn-result when loading
    a completed game. Stop the game and timer accordingly
    and display the winner.
    https://bugzilla.gnome.org/show_bug.cgi?id=705002

 src/gnome-chess.vala |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index 7b7fb82..5cadd3a 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -572,6 +572,15 @@ public class ChessApplication : Gtk.Application
         }
 
         game.start ();
+
+        // If loading a completed saved game
+        if (pgn_game.result == PGNGame.RESULT_WHITE)
+            game.result = ChessResult.WHITE_WON;
+        else if (pgn_game.result == PGNGame.RESULT_BLACK)
+            game.result = ChessResult.BLACK_WON;
+        else if (pgn_game.result == PGNGame.RESULT_DRAW)
+            game.result = ChessResult.DRAW;
+
         if (opponent_engine != null)
             opponent_engine.start_game ();
 
@@ -585,9 +594,6 @@ public class ChessApplication : Gtk.Application
             disable_window_action (PAUSE_RESUME_ACTION_NAME);
         }
 
-        if (game.result != ChessResult.IN_PROGRESS)
-            game_end_cb (game);
-
         update_history_panel ();
         update_action_status ();
         update_pause_resume_button ();
@@ -604,6 +610,10 @@ public class ChessApplication : Gtk.Application
             assert (opponent_engine != null);
             opponent_engine.move ();
         }
+
+        // If loading a completed saved game
+        if (game.result != ChessResult.IN_PROGRESS)
+            game.stop (game.result, game.rule);
     }
 
     private ChessEngine? get_engine (string name, string difficulty)


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