{
struct quadtree *parent;
+ if (node == it->head)
+ return;
+
parent = quadtree_del(node, &planet_ops);
quadtree_add(parent, node, &planet_ops);
}
return tree_to_planet(tree_parent);
}
- /*
- * Now, search the subtree for any crossed children and move
- * them into correct place within the tree.
- */
- it.qt_iterator.head = &p->tree;
- it.limit[0] = p->pos;
- it.limit[1] = new_pos;
- it.qt_iterator.direction = planet_search_when_moving;
- it.qt_iterator.callback = planet_move_iterator;
- walk_quadtree(&it.qt_iterator);
-
+ if(p->tree.children) {
+ /*
+ * Now, search the subtree for any crossed children and move
+ * them into correct place within the tree.
+ */
+ it.qt_iterator.head = &p->tree;
+ it.limit[0] = p->pos;
+ it.limit[1] = new_pos;
+ it.qt_iterator.direction = planet_search_when_moving;
+ it.qt_iterator.callback = planet_move_iterator;
+ walk_quadtree(&it.qt_iterator);
+ }
p->pos = new_pos;
return tree_to_planet(quadtree_find_parent(&p->tree));