]> git.itanic.dy.fi Git - sdl-planets/commitdiff
quadtree: quadtree_del: Fix tree integrity bug
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Mon, 12 Apr 2010 17:31:57 +0000 (20:31 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Tue, 13 Apr 2010 19:15:41 +0000 (22:15 +0300)
When a root node is deleted and new tree is built under the new root,
the new root node needs to have its parent set to null.

Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
quadtree.c

index 8efd8ad7a465b6a682ff5859350b345e653a02f7..a914f66324a8e0a6ba09d5ccfc50bd6d0c3c1128 100644 (file)
@@ -150,7 +150,7 @@ _quadtree_reposition_reqursively(struct quadtree *root,
 {
        int i;
 
-       validate_tree(node);
+       validate_tree(root);
 
        /* First remove all children, if any */
 
@@ -199,6 +199,7 @@ struct quadtree *quadtree_del(struct quadtree *node,
 
                        if (!parent) {
                                parent = node->child[i];
+                               parent->parent = 0;
                                continue;
                        }
                        _quadtree_reposition_reqursively(parent,