From f08fb7293382dbaf240860119d128486ada62221 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Sat, 21 Oct 2017 14:40:20 +0200 Subject: Improve short paths and do some refactoring. --- src/world.cpp | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'src/world.cpp') diff --git a/src/world.cpp b/src/world.cpp index 307374c..895eb0f 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -66,7 +66,6 @@ bool world_t::find_path(v2f_t src, v2f_t dst, rectf_t size, std::list *path) { path_finder_t finder; - bool rv; finder.setup_nodes(src, dst); @@ -79,24 +78,11 @@ bool world_t::find_path(v2f_t src, v2f_t dst, rectf_t size, node->accessible = (get_tile(index)->type >= 1); } - finder.find(); - rv = finder.export_path(path); + if (!finder.find()) + return false; - debug.clear(); - - for (size_t y = 0; y < finder.height; y++) - for (size_t x = 0; x < finder.width; x++) { - path_node_t *node = finder.nodes + y * finder.width + x; - std::stringstream ss; - - ss << "LT " << tile_index_t(x, y) << "\n"; - ss << " T " << finder.base + tile_index_t(x, y) << "\n"; - ss << " d " << node->dist; - - debug.push_back((debug_t){finder.base + tile_index_t(x, y), ss.str()}); - } - - return rv; + finder.export_path(path); + return true; } sector_t *world_t::get_sector(sector_index_t index) -- cgit