[gnome-games] Removed useless call to floorf and roundf and simplified code with MAX call



commit 0ce939eee7593929bbe82f869be4344c05b342bb
Author: Guillaume Beland <guillaume beland gmail com>
Date:   Tue Aug 4 13:08:11 2009 -0400

    Removed useless call to floorf and roundf and simplified code with MAX call

 gnibbles/main.c         |    4 ++--
 gnibbles/worm-clutter.c |   16 ++++++++--------
 2 files changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/gnibbles/main.c b/gnibbles/main.c
index 0bf5a42..681b050 100644
--- a/gnibbles/main.c
+++ b/gnibbles/main.c
@@ -929,12 +929,12 @@ main (int argc, char **argv)
   GOptionContext *context;
   gboolean retval;
   GError *error = NULL;
+  
+  gtk_clutter_init (&argc, &argv);
 
   if (!games_runtime_init ("gnibbles"))
     return 1;
 
-  gtk_clutter_init (&argc, &argv);
-
 #ifdef ENABLE_SETGID
   setgid_io_init ();
 #endif
diff --git a/gnibbles/worm-clutter.c b/gnibbles/worm-clutter.c
index 82a4276..48a4272 100644
--- a/gnibbles/worm-clutter.c
+++ b/gnibbles/worm-clutter.c
@@ -308,7 +308,7 @@ gnibbles_worm_get_actor_length (ClutterActor *actor) {
 
   clutter_actor_get_size (CLUTTER_ACTOR (actor), &w, &h);
   size = MAX (w,h);
-  size = roundf (size / properties->tilesize);
+  size = size / properties->tilesize;
 
   return size;
 }
@@ -701,8 +701,8 @@ gnibbles_worm_resize (GnibblesWorm *worm, gint newtile)
     direction = g_value_get_boolean (&val);
 
     clutter_actor_get_size (CLUTTER_ACTOR (tmp), &w, &h);
-    size = w < h ? roundf(h) : roundf(w);
-    size = roundf (size / properties->tilesize);
+    size = MAX (w,h);
+    size = size / properties->tilesize;
 
     if (direction)
       clutter_actor_set_size (tmp, newtile * size, newtile);
@@ -877,8 +877,8 @@ gnibbles_worm_move_head (GnibblesWorm *worm)
 
   clutter_actor_get_size (CLUTTER_ACTOR (head), &w, &h);
   clutter_actor_get_position (CLUTTER_ACTOR (head), &x, &y);
-  size = w < h ? floorf (h) : floorf (w);
-  size = floorf (size + properties->tilesize);
+  size = MAX (w, h);
+  size = size + properties->tilesize;
 
   switch (worm->direction) {
     case WORMRIGHT:
@@ -929,7 +929,7 @@ gnibbles_worm_move_tail (GnibblesWorm *worm)
   clutter_actor_get_size (CLUTTER_ACTOR (tail), &w, &h);
   clutter_actor_get_position (CLUTTER_ACTOR (tail), &x, &y);
   size = MAX (w, h);
-  size = floorf (size - properties->tilesize);
+  size = size - properties->tilesize;
   
   if (worm->change <= 0) {
     if (size <= 0) {
@@ -1075,8 +1075,8 @@ gnibbles_worm_get_length (GnibblesWorm *worm)
   for (i = 0; i < nbr_actor; i++) {
     tmp = clutter_group_get_nth_child (CLUTTER_GROUP (worm->actors), i);
     clutter_actor_get_size (CLUTTER_ACTOR (tmp), &w, &h);
-    tmp_size = w > h ? roundf(w) : roundf(h);
-    size += roundf (tmp_size / properties->tilesize);
+    tmp_size = MAX (w, h);
+    size += tmp_size / properties->tilesize;
   }
   return size;
 }



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