summaryrefslogtreecommitdiff
path: root/src/path_finder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/path_finder.cpp')
-rw-r--r--src/path_finder.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/path_finder.cpp b/src/path_finder.cpp
index ab300dc..8ca0ccc 100644
--- a/src/path_finder.cpp
+++ b/src/path_finder.cpp
@@ -78,10 +78,13 @@ void path_finder_t::find_r(tile_index_t index, float dist)
path.pop_back();
}
-void path_finder_t::find(void)
+bool path_finder_t::find(void)
{
tile_index_t start;
+ if ((src - dst).len() < 1.0f)
+ return true;
+
start = tile_index_at(src) - base;
nodes[start[1] * width + start[0]].accessible = false;
@@ -98,21 +101,18 @@ void path_finder_t::find(void)
find_r(next, v2f_t(offset).len());
}
+
+ return shortest_path.size() > 0;
}
-bool path_finder_t::export_path(std::list<v2f_t> *list)
+void path_finder_t::export_path(std::list<v2f_t> *list)
{
- if (!shortest_path.size())
- return false;
-
list->clear();
for (tile_index_t &index : shortest_path)
list->push_back(v2f_t(index + base) + tile_center);
list->push_back(dst);
-
- return true;
}
} // namespace world