[gbrainy] Allow to continue in the case of an exception when init a game



commit cdba63479090a9638a76b531505878b9e0cfb6da
Author: Jordi Mas <jmas softcatala org>
Date:   Mon Jan 10 20:53:15 2011 +0100

    Allow to continue in the case of an exception when init a game

 src/Core/Main/GameSession.cs |   29 ++++++++++++++++++-----------
 1 files changed, 18 insertions(+), 11 deletions(-)
---
diff --git a/src/Core/Main/GameSession.cs b/src/Core/Main/GameSession.cs
index 2ecc2c8..835bbba 100644
--- a/src/Core/Main/GameSession.cs
+++ b/src/Core/Main/GameSession.cs
@@ -246,20 +246,27 @@ namespace gbrainy.Core.Main
 		}
 
 		public void NextGame ()
-		{	
-			if (CurrentGame != null)
-				CurrentGame.Finish ();
+		{
+			try
+			{
+				if (CurrentGame != null)
+					CurrentGame.Finish ();
 
-			history.GamesPlayed++;
-			CurrentGame = game_manager.GetPuzzle ();
-			CurrentGame.SynchronizingObject = SynchronizingObject;
-			CurrentGame.DrawRequest += GameDrawRequest;
-			CurrentGame.UpdateUIElement += GameUpdateUIElement;
+				history.GamesPlayed++;
+				CurrentGame = game_manager.GetPuzzle ();
+				CurrentGame.SynchronizingObject = SynchronizingObject;
+				CurrentGame.DrawRequest += GameDrawRequest;
+				CurrentGame.UpdateUIElement += GameUpdateUIElement;
 
-			CurrentGame.Begin ();
+				CurrentGame.Begin ();
 
-			CurrentGame.GameTime = TimeSpan.Zero;
-			Status = SessionStatus.Playing;
+				CurrentGame.GameTime = TimeSpan.Zero;
+				Status = SessionStatus.Playing;
+			}
+			catch (Exception e)
+			{
+				Console.WriteLine ("GameSession.NextGame {0}", e);
+			}
 		}
 
 		public void Pause ()



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