gnome-games r9008 - trunk/iagno



Author: thomashpa
Date: Wed Apr  8 00:56:23 2009
New Revision: 9008
URL: http://svn.gnome.org/viewvc/gnome-games?rev=9008&view=rev

Log:
use g_timeout_add_seconds when possible in iagno. Fixes last bit of bug #564202

Modified:
   trunk/iagno/gnothello.c
   trunk/iagno/gnothello.h

Modified: trunk/iagno/gnothello.c
==============================================================================
--- trunk/iagno/gnothello.c	(original)
+++ trunk/iagno/gnothello.c	Wed Apr  8 00:56:23 2009
@@ -682,17 +682,17 @@
     switch (black_computer_level) {
     case 1:
       black_computer_id =
-	g_timeout_add (computer_speed, (GSourceFunc) computer_move_1,
+	add_timeout (computer_speed, (GSourceFunc) computer_move_1,
 		       (gpointer) BLACK_TURN);
       break;
     case 2:
       black_computer_id =
-	g_timeout_add (computer_speed, (GSourceFunc) computer_move_2,
+	add_timeout (computer_speed, (GSourceFunc) computer_move_2,
 		       (gpointer) BLACK_TURN);
       break;
     case 3:
       black_computer_id =
-	g_timeout_add (computer_speed, (GSourceFunc) computer_move_3,
+	add_timeout (computer_speed, (GSourceFunc) computer_move_3,
 		       (gpointer) BLACK_TURN);
       break;
     }
@@ -701,17 +701,17 @@
     switch (white_computer_level) {
     case 1:
       white_computer_id =
-	g_timeout_add (computer_speed, (GSourceFunc) computer_move_1,
+	add_timeout (computer_speed, (GSourceFunc) computer_move_1,
 		       (gpointer) WHITE_TURN);
       break;
     case 2:
       white_computer_id =
-	g_timeout_add (computer_speed, (GSourceFunc) computer_move_2,
+	add_timeout (computer_speed, (GSourceFunc) computer_move_2,
 		       (gpointer) WHITE_TURN);
       break;
     case 3:
       white_computer_id =
-	g_timeout_add (computer_speed, (GSourceFunc) computer_move_3,
+	add_timeout (computer_speed, (GSourceFunc) computer_move_3,
 		       (gpointer) WHITE_TURN);
       break;
     }
@@ -719,6 +719,17 @@
   return TRUE;
 }
 
+guint
+add_timeout (guint time, GSourceFunc func, gpointer turn)
+{
+  if (time % 1000) {
+    return g_timeout_add (time, func, turn);
+  } else {
+    time = time / 1000;
+    return g_timeout_add_seconds (time, func, turn);
+  }
+}
+
 void
 set_bg_color (void)
 {

Modified: trunk/iagno/gnothello.h
==============================================================================
--- trunk/iagno/gnothello.h	(original)
+++ trunk/iagno/gnothello.h	Wed Apr  8 00:56:23 2009
@@ -82,6 +82,7 @@
 void gui_status (void);
 void gui_message (gchar * message);
 guint check_computer_players (void);
+guint add_timeout (guint time, GSourceFunc func, gpointer turn);
 void load_pixmaps (void);
 void properties_cb (GtkWidget * widget, gpointer data);
 void set_bg_color (void);



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