From 0e9ecb5c33e35a9adceea97de637db133ffa9dbf Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 9 Oct 2023 05:25:16 +0200 Subject: a --- src/path-search-dijkstra.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/path-search-dijkstra.cpp') diff --git a/src/path-search-dijkstra.cpp b/src/path-search-dijkstra.cpp index 417b1b55..cec44225 100644 --- a/src/path-search-dijkstra.cpp +++ b/src/path-search-dijkstra.cpp @@ -264,17 +264,23 @@ path_search_result astar::Dijkstra(world& w, point from_, point to_, object_id o if (dist >= max_dist) continue; - #ifdef FM_ASTAR_NO_EDGE_CACHE + const auto new_pt = point{.coord = new_coord, .offset = new_offset}; + + if (auto it = indexes.find(new_pt); it != indexes.end()) + if (nodes[it->second].dist >= dist) + continue; + +#ifdef FM_ASTAR_NO_EDGE_CACHE { auto vec_ = Vector2(vec); auto bb1 = bbox{ bb0.min + vec_, bb0.max + vec_ }; auto bb = bbox_union(bb1, bb0); if (!path_search::is_passable(w, chunk_coords_(new_coord), bb, own_id, p)) continue; } - #endif +#endif const auto sz = nodes.size(); - auto [it, fresh] = indexes.try_emplace({.coord = new_coord, .offset = new_offset}, sz); + auto [it, fresh] = indexes.try_emplace(new_pt, sz); const auto new_idx = it.value(); if (new_idx == sz) -- cgit v1.2.3