From bde4dd84f52fc51d0314439507f25e4a6d2a1e16 Mon Sep 17 00:00:00 2001 From: Steve Date: Mon, 22 Feb 2016 21:45:02 +0000 Subject: [PATCH] Removed redundant calls. --- src/battle/quadtree.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/battle/quadtree.c b/src/battle/quadtree.c index cbe66d9..7f34218 100644 --- a/src/battle/quadtree.c +++ b/src/battle/quadtree.c @@ -191,26 +191,20 @@ static int getIndex(Quadtree *root, int x, int y, int w, int h) void removeFromQuadtree(Entity *e, Quadtree *root) { - int index, i; + int index; - index = getIndex(root, e->x - (e->w / 2), e->y - (e->h / 2), e->w, e->h); - - removeEntity(e, root); - if (root->node[0]) { + index = getIndex(root, e->x - (e->w / 2), e->y - (e->h / 2), e->w, e->h); + if (index != -1) { removeFromQuadtree(e, root->node[index]); - } - else - { - for (i = 0; i < 4; i++) - { - removeFromQuadtree(e, root->node[i]); - } + return; } } + + removeEntity(e, root); } static void removeEntity(Entity *e, Quadtree *root)