diff --git a/src/battle/quadtree.c b/src/battle/quadtree.c index 063d56d..96cc549 100644 --- a/src/battle/quadtree.c +++ b/src/battle/quadtree.c @@ -220,9 +220,25 @@ Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore) static void getAllEntsWithinNode(int x, int y, int w, int h, Entity *ignore, Quadtree *root) { - Quadtree *node; int index, i; + if (root->node[0]) + { + index = getIndex(root, x, y, w, h); + + if (index != -1) + { + getAllEntsWithinNode(x, y, w, h, ignore, root->node[index]); + } + else + { + for (i = 0 ; i < 4 ; i++) + { + getAllEntsWithinNode(x, y, w, h, ignore, root->node[i]); + } + } + } + for (i = 0 ; i < root->numEnts ; i++) { candidates[cIndex++] = root->ents[i]; @@ -232,27 +248,6 @@ static void getAllEntsWithinNode(int x, int y, int w, int h, Entity *ignore, Qua resizeCandidates(); } } - - index = getIndex(root, x, y, w, h); - - if (root->node[0]) - { - if (index != -1) - { - node = root->node[index]; - - getAllEntsWithinNode(node->x, node->y, node->w, node->h, ignore, node); - } - else - { - for (i = 0; i < 4; i++) - { - node = root->node[i]; - - getAllEntsWithinNode(node->x, node->y, node->w, node->h, ignore, node); - } - } - } } static void resizeCandidates(void)