summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/path-search.cpp1
-rw-r--r--test/path-search.cpp26
2 files changed, 15 insertions, 12 deletions
diff --git a/src/path-search.cpp b/src/path-search.cpp
index 3a678388..cf7d41d5 100644
--- a/src/path-search.cpp
+++ b/src/path-search.cpp
@@ -39,6 +39,7 @@ bool path_search::is_passable_1(chunk& c, Vector2 min, Vector2 max, object_id ow
if (x.data != own_id && x.pass != (uint64_t)pass_mode::pass)
{
is_passable = false;
+ //[[maybe_unused]] auto obj = c.world().find_object(x.data);
return false;
}
else
diff --git a/test/path-search.cpp b/test/path-search.cpp
index eb4ff4a5..3b1c4e93 100644
--- a/test/path-search.cpp
+++ b/test/path-search.cpp
@@ -11,15 +11,15 @@ namespace {
void test_bbox()
{
- constexpr auto is_passable_1 = [](chunk& c, path_search::bbox bb) {
+ static constexpr auto is_passable_1 = [](chunk& c, path_search::bbox bb) {
return path_search::is_passable_1(c, bb.min, bb.max, (object_id)-1);
};
- constexpr auto is_passable = [](world& w, chunk_coords_ ch, path_search::bbox bb) {
+ static constexpr auto is_passable = [](world& w, chunk_coords_ ch, path_search::bbox bb) {
return path_search::is_passable(w, ch, bb.min, bb.max, (object_id)-1);
};
- constexpr auto bbox = [](Vector2i coord, rotation r) {
+ static constexpr auto bbox = [](Vector2i coord, rotation r) {
return path_search::make_neighbor_tile_bbox(coord, {}, r);
};
@@ -81,15 +81,17 @@ void test_bbox()
auto w = world();
auto& c = test_app::make_test_chunk(w, ch);
- fm_assert( !is_passable_1(c, bbox({8, 8}, N)) );
- fm_assert( !is_passable_1(c, bbox({8, 8}, E)) );
- fm_assert( !is_passable_1(c, bbox({8, 8}, S)) );
- fm_assert( !is_passable_1(c, bbox({8, 8}, W)) );
-
- fm_assert( !is_passable_1(c, bbox({8, 9}, N)) );
- fm_assert( is_passable_1(c, bbox({8, 9}, E)) );
- fm_assert( is_passable_1(c, bbox({8, 9}, S)) );
- fm_assert( is_passable_1(c, bbox({8, 9}, W)) );
+ constexpr auto is_passable_NESW = [](chunk& c, Vector2i coord, std::array<bool, 4> dirs) {
+ fm_assert(is_passable_1(c, bbox(coord, N)) == dirs[0]);
+ fm_assert(is_passable_1(c, bbox(coord, E)) == dirs[1]);
+ fm_assert(is_passable_1(c, bbox(coord, S)) == dirs[2]);
+ fm_assert(is_passable_1(c, bbox(coord, W)) == dirs[3]);
+ };
+
+ is_passable_NESW(c, {8, 8}, { false, false, false, false });
+ is_passable_NESW(c, {8, 9}, { false, true, true, true });
+ is_passable_NESW(c, {2, 4}, { true, false, true, true });
+ is_passable_NESW(c, {4, 4}, { true, true, true, false });
}
}