diff src/coord.c @ 151:d11aa8fc06c7

Fix bug of tanks do not show at right places. Since we avoid to dirty a subtree if root of a subtree have been dirty or hidden, it make children that was added into coord tree after a coord be dirty do not be marked with COF_DIRTY flag. To fix it, when a new coord is created, the parent is checked and mark new coord with COF_DIRTY flag if the parent is dirty. It forces new coords to be cleaned and transformed to right places.
author Thinker K.F. Li <thinker@branda.to>
date Fri, 26 Sep 2008 17:42:16 +0800
parents 0de8fd11271e
children c7e5b8779bb5
line wrap: on
line diff
--- a/src/coord.c	Thu Sep 25 23:44:38 2008 +0800
+++ b/src/coord.c	Fri Sep 26 17:42:16 2008 +0800
@@ -120,22 +120,33 @@
     return sqrt(x * x + y * y);
 }
 
+/*!
+ * \note Coords, marked with COF_SKIP_TRIVAL (for temporary), and
+ * descendants of them will not be trivaled and the flag with be removed
+ * after skipping them.
+ */
 coord_t *preorder_coord_subtree(coord_t *root, coord_t *last) {
-    coord_t *next;
+    coord_t *next = NULL;
 
     ASSERT(last != NULL);
     
-    if(STAILQ_HEAD(last->children))
+    if((!(last->flags & COF_SKIP_TRIVAL)) &&
+       STAILQ_HEAD(last->children)) {
 	next = STAILQ_HEAD(last->children);
-    else {
+	if(!(next->flags & COF_SKIP_TRIVAL))
+	    return next;
+    } else {
 	next = last;
+    }
+
+    do {
+	next->flags &= ~COF_SKIP_TRIVAL;
 	while(next != root && STAILQ_NEXT(coord_t, sibling, next) == NULL)
 	    next = next->parent;
 	if(next == root)
-	    next = NULL;
-	if(next)
-	    next = STAILQ_NEXT(coord_t, sibling, next);
-    }
+	    return NULL;
+	next = STAILQ_NEXT(coord_t, sibling, next);
+    } while(next->flags & COF_SKIP_TRIVAL);
 
     return next;
 }