ramp/channel: don't dig into undiggable tiles

develop
myk002 2021-06-27 14:54:41 -07:00
parent d6c9f99c61
commit 1a19c3a944
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
1 changed files with 10 additions and 7 deletions

@ -334,20 +334,22 @@ static bool dig_tile(color_ostream &out, MapExtras::MapCache &map,
} }
break; break;
case df::tile_dig_designation::Channel: case df::tile_dig_designation::Channel:
if (can_dig_channel(tt)) { {
DFCoord pos_below(pos.x, pos.y, pos.z-1);
if (can_dig_channel(tt) && map.ensureBlockAt(pos_below)
&& is_diggable(map, pos_below, map.tiletypeAt(pos_below))) {
target_type = df::tiletype::OpenSpace; target_type = df::tiletype::OpenSpace;
DFCoord pos_above(pos.x, pos.y, pos.z+1); DFCoord pos_above(pos.x, pos.y, pos.z+1);
if (map.ensureBlockAt(pos_above)) if (map.ensureBlockAt(pos_above))
remove_ramp_top(map, pos_above); remove_ramp_top(map, pos_above);
DFCoord pos_below(pos.x, pos.y, pos.z-1); if (dig_tile(out, map, pos_below,
if (map.ensureBlockAt(pos_below) &&
dig_tile(out, map, pos_below,
df::tile_dig_designation::Ramp, dug_tiles)) { df::tile_dig_designation::Ramp, dug_tiles)) {
clean_ramps(map, pos_below); clean_ramps(map, pos_below);
// if we successfully dug out the ramp below, that took care // if we successfully dug out the ramp below, that took care
// of adding the ramp top here // of adding the ramp top here
return true; return true;
} }
}
break; break;
} }
case df::tile_dig_designation::UpStair: case df::tile_dig_designation::UpStair:
@ -374,7 +376,8 @@ static bool dig_tile(color_ostream &out, MapExtras::MapCache &map,
if (can_dig_ramp(tt)) { if (can_dig_ramp(tt)) {
target_type = findSimilarTileType(tt, df::tiletype_shape::RAMP); target_type = findSimilarTileType(tt, df::tiletype_shape::RAMP);
DFCoord pos_above(pos.x, pos.y, pos.z+1); DFCoord pos_above(pos.x, pos.y, pos.z+1);
if (target_type != tt && map.ensureBlockAt(pos_above)) { if (target_type != tt && map.ensureBlockAt(pos_above)
&& is_diggable(map, pos, map.tiletypeAt(pos_above))) {
// only capture the tile info of pos_above if we didn't get // only capture the tile info of pos_above if we didn't get
// here via the Channel case above // here via the Channel case above
if (dug_tiles.size() == 0) if (dug_tiles.size() == 0)