Travel: Fixed crash when trying to travel in maps with no nodes (#1171)

This commit is contained in:
EricksOliveira
2025-04-27 07:52:48 -03:00
committed by GitHub
parent 6d24db6999
commit fc9555b7d4

View File

@@ -1348,6 +1348,9 @@ TravelNodeRoute TravelNodeMap::getRoute(WorldPosition startPos, WorldPosition en
std::vector<WorldPosition> newStartPath; std::vector<WorldPosition> newStartPath;
std::vector<TravelNode*> startNodes = m_nodes, endNodes = m_nodes; std::vector<TravelNode*> startNodes = m_nodes, endNodes = m_nodes;
if(!startNodes.size() || !endNodes.size())
return TravelNodeRoute();
// Partial sort to get the closest 5 nodes at the begin of the array. // Partial sort to get the closest 5 nodes at the begin of the array.
std::partial_sort(startNodes.begin(), startNodes.begin() + 5, startNodes.end(), std::partial_sort(startNodes.begin(), startNodes.begin() + 5, startNodes.end(),
[startPos](TravelNode* i, TravelNode* j) { return i->fDist(startPos) < j->fDist(startPos); }); [startPos](TravelNode* i, TravelNode* j) { return i->fDist(startPos) < j->fDist(startPos); });