From 275cb79a1857fff08ce1b642bbfab6d7377bcaef Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 20 Oct 2023 12:33:00 +0200 Subject: aa --- src/object.cpp | 5 +++++ src/object.hpp | 1 + src/path-search-dijkstra.cpp | 10 +++++----- 3 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/object.cpp b/src/object.cpp index 001b9dc6..6284e3e9 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -103,6 +103,11 @@ bool object::is_virtual() const return false; } +point object::position() const +{ + return {coord, offset}; +} + bool object::can_rotate(global_coords coord, rotation new_r, rotation old_r, Vector2b offset, Vector2b bbox_offset, Vector2ub bbox_size) { diff --git a/src/object.hpp b/src/object.hpp index bd5066b9..c02e4d07 100644 --- a/src/object.hpp +++ b/src/object.hpp @@ -63,6 +63,7 @@ struct object struct chunk& chunk() const; size_t index() const; virtual bool is_virtual() const; + point position() const; explicit operator object_proto() const; diff --git a/src/path-search-dijkstra.cpp b/src/path-search-dijkstra.cpp index b5f5355a..5012cb54 100644 --- a/src/path-search-dijkstra.cpp +++ b/src/path-search-dijkstra.cpp @@ -204,18 +204,18 @@ path_search_result astar::Dijkstra(world& w, const point from_, const point to_, auto vec = Vector2(cur_pt.coord() - to_.coord()) * TILE_SIZE2 + Vector2(cur_pt.offset() - to_.offset()); auto bb1 = bbox{goal_bb.min + vec, goal_bb.max + vec}; auto bb = bbox_union(goal_bb, bb1); - bool fresh = true; if (goal_idx != (uint32_t)-1) - { if (dist >= nodes[goal_idx].dist) continue; - fresh = false; - } if (path_search::is_passable(w, to_.chunk3(), bb, own_id, p)) { - if (fresh) + if (goal_idx == (uint32_t)-1) + { + goal_idx = cache.lookup_index(goal_chunk_idx, goal_tile_idx); + } + if (goal_idx == (uint32_t)-1) { goal_idx = (uint32_t)nodes.size(); cache.add_index(goal_chunk_idx, goal_tile_idx, goal_idx); -- cgit v1.2.3