diff --git a/src/MultilevelAStarEx.cpp b/src/MultilevelAStarEx.cpp index 61a267a..85632e0 100644 --- a/src/MultilevelAStarEx.cpp +++ b/src/MultilevelAStarEx.cpp @@ -268,13 +268,11 @@ Variant MultilevelAStarEx::find_path(const Vector2i &from, const Vector2i &to, b node->open(_pass, current, current->distanceFromStart + distance, to2); open.push_back(node); } - else if (node->state(_pass) == Node::OPEN) + // TODO: check if this should only be performed on open nodes or all nodes + else if (current->distanceFromStart + distance < node->distanceFromStart) { - if (current->distanceFromStart < node->parent->distanceFromStart) - { - node->parent = current; - node->distanceFromStart = current->distanceFromStart + distance; - } + node->parent = current; + node->distanceFromStart = current->distanceFromStart + distance; } // find the closest cell