diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2017-10-21 14:40:20 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2017-10-21 14:40:20 +0200 |
commit | f08fb7293382dbaf240860119d128486ada62221 (patch) | |
tree | ce9a85f47b3dacc98f75a9f73f1378d4c00ec915 /src/world.cpp | |
parent | 42fece714e30b899208a90183a571452eb35811e (diff) |
Improve short paths and do some refactoring.
Diffstat (limited to 'src/world.cpp')
-rw-r--r-- | src/world.cpp | 22 |
1 files changed, 4 insertions, 18 deletions
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<v2f_t> *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) |