diff src/redraw_man.c @ 160:147c93163ef0

Fix bug of tank that bullet is not hidden when go out the map.
author Thinker K.F. Li <thinker@branda.to>
date Wed, 08 Oct 2008 03:57:56 +0800
parents b90abd31a281
children c7e5b8779bb5
line wrap: on
line diff
--- a/src/redraw_man.c	Sun Oct 05 23:32:58 2008 +0800
+++ b/src/redraw_man.c	Wed Oct 08 03:57:56 2008 +0800
@@ -428,7 +428,8 @@
 	if(geo->flags & GEF_FREE)
 	    return ERR;
 
-	geo->flags |= GEF_FREE | GEF_HIDDEN;
+	geo->flags |= GEF_FREE;
+	sh_hide(shape);
 	if(!(geo->flags & GEF_DIRTY)) {
 	    r = add_dirty_geo(rdman, geo);
 	    if(r != OK)
@@ -575,7 +576,8 @@
 	    if(!(member->flags & GEF_FREE))
 		return ERR;
 	}
-	coord->flags |= COF_FREE | COF_HIDDEN;
+	coord->flags |= COF_FREE;
+	coord_hide(coord);
 	if(!(coord->flags & COF_DIRTY)) {
 	    r = add_dirty_coord(rdman, coord);
 	    if(r != OK)
@@ -635,7 +637,9 @@
 /*! \brief Mark a coord is changed.
  *
  * A changed coord_t object is marked as dirty and put
- * into dirty_coords list.
+ * into dirty_coords list.  rdman_coord_changed() should be called
+ * for a coord after it been changed to notify redraw manager to
+ * redraw shapes grouped by it.
  */
 int rdman_coord_changed(redraw_man_t *rdman, coord_t *coord) {
     coord_t *child;
@@ -645,6 +649,9 @@
 
     add_dirty_coord(rdman, coord);
 
+    if(coord->flags & COF_HIDDEN)
+	return OK;
+
     /* Make child coords dirty. */
     for(child = preorder_coord_subtree(coord, coord);
 	child != NULL;
@@ -728,9 +735,9 @@
     shape->geo->flags &= ~GEF_DIRTY;
 
     if(is_coord_subtree_hidden(shape->coord))
-	shape->geo->flags |= GEF_HIDDEN;
+	sh_hide(shape);
     else
-	shape->geo->flags &= ~GEF_HIDDEN;
+	sh_show(shape);
 }
 
 /*! \brief Setup canvas for the coord.
@@ -1029,6 +1036,9 @@
     cairo_t *canvas;
     int mem_idx;
 
+    if(coord->flags & COF_HIDDEN)
+	return OK;
+
     canvas = coord->canvas;
     member = FIRST_MEMBER(coord);
     mem_idx = 0;
@@ -1045,6 +1055,7 @@
 		draw_shape(rdman, canvas, member->shape);
 		dirty = 1;
 	    }
+
 	    member = NEXT_MEMBER(member);
 	    mem_idx++;
 	}
@@ -1119,7 +1130,6 @@
 	draw_shapes_in_areas(rdman, n_dirty_areas, dirty_areas);
 	copy_cr_2_backend(rdman, rdman->dirty_areas.num,
 			  rdman->dirty_areas.ds);
-	rdman->dirty_areas.num = 0;
 	reset_clip(rdman);
     }
     rdman->dirty_areas.num = 0;