From 8dccfae9bc98c61db24c2c0c11b45a2e9d68e3a4 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Tue, 14 Nov 2023 10:33:35 -0800 Subject: [PATCH 1/2] don't extend too far beyond ramps and don't expand across mushroom tops -- they're not pathable --- plugins/burrow.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/plugins/burrow.cpp b/plugins/burrow.cpp index 2a2cac362..a9ac8fc22 100644 --- a/plugins/burrow.cpp +++ b/plugins/burrow.cpp @@ -520,8 +520,7 @@ static uint16_t get_walk_group(const df::coord & pos) { } static bool is_tree(const df::tiletype *tt) { - return tileMaterial(*tt) == tiletype_material::TREE || - tileMaterial(*tt) == tiletype_material::MUSHROOM; + return tileMaterial(*tt) == tiletype_material::TREE; } // if the outside tile flag is set @@ -599,14 +598,16 @@ static void flood_fill(lua_State *L, bool enable) { if (start_walk && start_walk != walk && tt && !is_tree(tt)) continue; - flood.emplace(pos.x-1, pos.y-1, pos.z); - flood.emplace(pos.x, pos.y-1, pos.z); - flood.emplace(pos.x+1, pos.y-1, pos.z); - flood.emplace(pos.x-1, pos.y, pos.z); - flood.emplace(pos.x+1, pos.y, pos.z); - flood.emplace(pos.x-1, pos.y+1, pos.z); - flood.emplace(pos.x, pos.y+1, pos.z); - flood.emplace(pos.x+1, pos.y+1, pos.z); + if (tt && tileShape(*tt) != df::tiletype_shape::RAMP_TOP) { + flood.emplace(pos.x-1, pos.y-1, pos.z); + flood.emplace(pos.x, pos.y-1, pos.z); + flood.emplace(pos.x+1, pos.y-1, pos.z); + flood.emplace(pos.x-1, pos.y, pos.z); + flood.emplace(pos.x+1, pos.y, pos.z); + flood.emplace(pos.x-1, pos.y+1, pos.z); + flood.emplace(pos.x, pos.y+1, pos.z); + flood.emplace(pos.x+1, pos.y+1, pos.z); + } if (!zlevel) { df::coord pos_above = pos + df::coord(0, 0, 1); From 3116287f08ced51efb42af33f9069076e657ba27 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Tue, 14 Nov 2023 10:42:05 -0800 Subject: [PATCH 2/2] don't expand through tree branches unless they're pathable --- plugins/burrow.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/burrow.cpp b/plugins/burrow.cpp index a9ac8fc22..7f357f254 100644 --- a/plugins/burrow.cpp +++ b/plugins/burrow.cpp @@ -523,6 +523,10 @@ static bool is_tree(const df::tiletype *tt) { return tileMaterial(*tt) == tiletype_material::TREE; } +static bool is_tree_trunk(const df::tiletype *tt) { + return is_tree(tt) && tileShape(*tt)== tiletype_shape::WALL; +} + // if the outside tile flag is set // or it's light and it's a tree // or there are just outside or light tree tiles above it @@ -595,7 +599,7 @@ static void flood_fill(lua_State *L, bool enable) { // only go one tile outside of a walkability group (trees don't count) df::tiletype *tt = Maps::getTileType(pos); - if (start_walk && start_walk != walk && tt && !is_tree(tt)) + if (start_walk && start_walk != walk && tt && !is_tree_trunk(tt)) continue; if (tt && tileShape(*tt) != df::tiletype_shape::RAMP_TOP) {