Optimizations in Map::findPath

This commit is contained in:
sakagushi 2014-02-06 03:57:17 -02:00
parent ff617c3fab
commit f4f79f47bd
1 changed files with 2 additions and 4 deletions

View File

@ -798,13 +798,11 @@ std::tuple<std::vector<Otc::Direction>, Otc::PathFindResult> Map::findPath(const
std::sort(searchList.begin(), searchList.end(), [](Node *a, Node *b) { return a->totalCost < b->totalCost; });
auto end = std::unique(searchList.begin(), searchList.end());
searchList.resize(std::distance(searchList.begin(), end));
currentNode->evaluated = true;
currentNode = nullptr;
while(!searchList.empty() && !currentNode) {
Node *node = searchList.front();
searchList.pop_front();
for (auto begin = searchList.begin(); begin != end && !currentNode; ++begin) {
Node *node = *begin;
if(!node->evaluated)
currentNode = node;