Merge pull request #4021 from myk002/myk_burrow_flood_final

[burrow] final tweaking of flood fill logic
develop
Myk 2023-11-14 10:52:20 -08:00 committed by GitHub
commit 5c78bf29ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 11 deletions

@ -520,8 +520,11 @@ static uint16_t get_walk_group(const df::coord & pos) {
} }
static bool is_tree(const df::tiletype *tt) { static bool is_tree(const df::tiletype *tt) {
return tileMaterial(*tt) == tiletype_material::TREE || return tileMaterial(*tt) == tiletype_material::TREE;
tileMaterial(*tt) == tiletype_material::MUSHROOM; }
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 // if the outside tile flag is set
@ -596,17 +599,19 @@ static void flood_fill(lua_State *L, bool enable) {
// only go one tile outside of a walkability group (trees don't count) // only go one tile outside of a walkability group (trees don't count)
df::tiletype *tt = Maps::getTileType(pos); 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; continue;
flood.emplace(pos.x-1, pos.y-1, pos.z); if (tt && tileShape(*tt) != df::tiletype_shape::RAMP_TOP) {
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-1, pos.z); flood.emplace(pos.x, pos.y-1, 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+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+1, pos.y, 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+1, pos.z); flood.emplace(pos.x, pos.y+1, pos.z);
flood.emplace(pos.x+1, pos.y+1, pos.z);
}
if (!zlevel) { if (!zlevel) {
df::coord pos_above = pos + df::coord(0, 0, 1); df::coord pos_above = pos + df::coord(0, 0, 1);