diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/path-search-dijkstra.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/path-search-dijkstra.cpp b/src/path-search-dijkstra.cpp index 1db63ac7..bcf34cb5 100644 --- a/src/path-search-dijkstra.cpp +++ b/src/path-search-dijkstra.cpp @@ -158,8 +158,6 @@ path_search_result astar::Dijkstra(world& w, Vector2ub own_size, const object_id while (!Q.empty()) { - fm_assert(nodes.size() < 500); - std::pop_heap(Q.begin(), Q.end(), heap_comparator); const auto id = Q.back(); Q.pop_back(); @@ -168,7 +166,7 @@ path_search_result astar::Dijkstra(world& w, Vector2ub own_size, const object_id auto& node = nodes[id]; fm_debug_assert(node.dist != (uint32_t)-1); - Debug{} << "node" << id << "|" << node.coord.to_signed3() << node.offset << "|" << node.dist; + //Debug{} << "node" << id << "|" << node.coord.to_signed3() << node.offset << "|" << node.dist; const auto bb0 = bbox_from_pos(Vector2(node.coord.local()), node.offset, own_size); @@ -180,7 +178,7 @@ path_search_result astar::Dijkstra(world& w, Vector2ub own_size, const object_id continue; const auto sz = nodes.size(); - auto [it, created] = indexes.try_emplace({.coord = new_coord, .offset = new_offset}, sz); + auto [it, fresh] = indexes.try_emplace({.coord = new_coord, .offset = new_offset}, sz); const auto new_idx = it.value(); if (new_idx == sz) @@ -194,12 +192,12 @@ path_search_result astar::Dijkstra(world& w, Vector2ub own_size, const object_id auto& node = nodes[new_idx]; - if (!created && dist >= node.dist) + if (!fresh && dist >= node.dist) continue; node.dist = dist; auto e = make_edge({node.coord, node.offset}, {new_coord, new_offset}); - if (auto [it, created] = edges.try_emplace(e, edge_status::unknown); created) + if (auto [it, fresh] = edges.try_emplace(e, edge_status::unknown); fresh) { auto& status = it.value(); auto vec_ = Vector2(vec); @@ -215,7 +213,7 @@ path_search_result astar::Dijkstra(world& w, Vector2ub own_size, const object_id } } - Debug{} << (created ? " new" : " old") << new_idx << "|" << node.coord.to_signed3() << node.offset << "|" << node.dist; + //Debug{} << (fresh ? " new" : " old") << new_idx << "|" << node.coord.to_signed3() << node.offset << "|" << node.dist; Q.push_back(new_idx); std::push_heap(Q.begin(), Q.end(), heap_comparator); |