The planet needs to be remove from all linked lists before they are
being merged together. If merging takes place while both nodes are in
the same quad tree, the tree logic might collapse due to two nodes
sharing the same identical coordinates.
Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
struct planet *merge_planets(struct planet *a, struct planet *b)
{
struct quadtree *p;
- _merge_planets(a, b);
list_del(&b->list);
p = quadtree_del(&b->tree, &planet_ops);
+ _merge_planets(a, b);
free(b);
return tree_to_planet(p);
}