From: Timo Kokkonen Date: Wed, 20 Jul 2011 12:47:55 +0000 (+0300) Subject: merge_planets: Remove planet from linked lists before merging X-Git-Url: http://git.itanic.dy.fi/?p=sdl-planets;a=commitdiff_plain;h=0f13064cd991ca571194e35f40218e33f5cfa4fd merge_planets: Remove planet from linked lists before merging 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 --- diff --git a/planet.c b/planet.c index 2c7d143..c6d8aee 100644 --- a/planet.c +++ b/planet.c @@ -266,11 +266,11 @@ static struct planet *_merge_planets(struct planet *a, struct planet *b) 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); }