Use lambdas in sort functions (for zone at least)

This commit is contained in:
Michael Cook (mackal)
2014-12-24 18:29:23 -05:00
parent 811872c17f
commit 8522542ae2
4 changed files with 15 additions and 22 deletions
+6 -6
View File
@@ -345,10 +345,10 @@ bool CheckLOSBetweenPoints(Map::Vertex start, Map::Vertex end) {
return true;
}
bool SortPathNodesByDistance(PathNodeSortStruct n1, PathNodeSortStruct n2)
auto path_compare = [](const PathNodeSortStruct& a, const PathNodeSortStruct& b)
{
return n1.Distance < n2.Distance;
}
return a.Distance < b.Distance;
};
std::deque<int> PathManager::FindRoute(Map::Vertex Start, Map::Vertex End)
{
@@ -382,7 +382,7 @@ std::deque<int> PathManager::FindRoute(Map::Vertex Start, Map::Vertex End)
}
}
std::sort(SortedByDistance.begin(), SortedByDistance.end(), SortPathNodesByDistance);
std::sort(SortedByDistance.begin(), SortedByDistance.end(), path_compare);
for(auto Iterator = SortedByDistance.begin(); Iterator != SortedByDistance.end(); ++Iterator)
{
@@ -420,7 +420,7 @@ std::deque<int> PathManager::FindRoute(Map::Vertex Start, Map::Vertex End)
}
}
std::sort(SortedByDistance.begin(), SortedByDistance.end(), SortPathNodesByDistance);
std::sort(SortedByDistance.begin(), SortedByDistance.end(), path_compare);
for(auto Iterator = SortedByDistance.begin(); Iterator != SortedByDistance.end(); ++Iterator)
{
@@ -1120,7 +1120,7 @@ int PathManager::FindNearestPathNode(Map::Vertex Position)
}
}
std::sort(SortedByDistance.begin(), SortedByDistance.end(), SortPathNodesByDistance);
std::sort(SortedByDistance.begin(), SortedByDistance.end(), path_compare);
for(auto Iterator = SortedByDistance.begin(); Iterator != SortedByDistance.end(); ++Iterator)
{