From ff617c3fabbf6cf385d4e505fcbc204c28ecf57e Mon Sep 17 00:00:00 2001 From: sakagushi Date: Thu, 6 Feb 2014 03:36:19 -0200 Subject: [PATCH] More fixes in Map::findPath Fixed the styling, std::unique and removed the priority_queue comment --- src/client/map.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/client/map.cpp b/src/client/map.cpp index d04a5fb0..b410344b 100644 --- a/src/client/map.cpp +++ b/src/client/map.cpp @@ -697,8 +697,7 @@ std::tuple, Otc::PathFindResult> Map::findPath(const } std::unordered_map nodes; - //std::priority_queue, LessNode> searchList; - std::deque searchList; + std::deque searchList; Node *currentNode = new Node(startPos); currentNode->pos = startPos; @@ -797,12 +796,13 @@ std::tuple, Otc::PathFindResult> Map::findPath(const } } - std::sort(searchList.begin(), searchList.end(), [](Node *a, Node *b) { return a->totalCost < b->totalCost; }); - std::unique(searchList.begin(), searchList.end()); + 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.size() > 0 && !currentNode) { + while(!searchList.empty() && !currentNode) { Node *node = searchList.front(); searchList.pop_front();