fix adjacent smooth walls when we dig one out

develop
myk002 2021-06-27 21:58:16 -07:00
parent 7f0c3cc7e4
commit 0b703d9818
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
1 changed files with 13 additions and 1 deletions

@ -414,6 +414,8 @@ static bool dig_tile(color_ostream &out, MapExtras::MapCache &map,
} }
static bool is_smooth_wall(MapExtras::MapCache &map, const DFCoord &pos) { static bool is_smooth_wall(MapExtras::MapCache &map, const DFCoord &pos) {
if (!map.ensureBlockAt(pos))
return false;
df::tiletype tt = map.tiletypeAt(pos); df::tiletype tt = map.tiletypeAt(pos);
return tileSpecial(tt) == df::tiletype_special::SMOOTH return tileSpecial(tt) == df::tiletype_special::SMOOTH
&& tileShape(tt) == df::tiletype_shape::WALL; && tileShape(tt) == df::tiletype_shape::WALL;
@ -447,9 +449,10 @@ static TileDirection ensure_valid_tdir(TileDirection tdir) {
} }
// connects adjacent smooth walls to our new smooth wall // connects adjacent smooth walls to our new smooth wall
static TileDirection BLANK_TILE_DIRECTION;
static bool adjust_smooth_wall_dir(MapExtras::MapCache &map, static bool adjust_smooth_wall_dir(MapExtras::MapCache &map,
const DFCoord &pos, const DFCoord &pos,
TileDirection tdir) { TileDirection tdir = BLANK_TILE_DIRECTION) {
if (!is_smooth_wall(map, pos)) if (!is_smooth_wall(map, pos))
return false; return false;
@ -465,6 +468,14 @@ static bool adjust_smooth_wall_dir(MapExtras::MapCache &map,
return true; return true;
} }
static void refresh_adjacent_smooth_walls(MapExtras::MapCache &map,
const DFCoord &pos) {
adjust_smooth_wall_dir(map, DFCoord(pos.x, pos.y-1, pos.z));
adjust_smooth_wall_dir(map, DFCoord(pos.x, pos.y+1, pos.z));
adjust_smooth_wall_dir(map, DFCoord(pos.x-1, pos.y, pos.z));
adjust_smooth_wall_dir(map, DFCoord(pos.x+1, pos.y, pos.z));
}
// assumes that if the game let you designate a tile for smoothing, it must be // assumes that if the game let you designate a tile for smoothing, it must be
// valid to do so. // valid to do so.
static bool smooth_tile(color_ostream &out, MapExtras::MapCache &map, static bool smooth_tile(color_ostream &out, MapExtras::MapCache &map,
@ -578,6 +589,7 @@ static void do_dig(color_ostream &out, std::vector<DFCoord> &dug_coords,
map.setDesignationAt(pos, td); map.setDesignationAt(pos, td);
for (auto info : dug_tiles) { for (auto info : dug_tiles) {
dug_coords.push_back(info.pos); dug_coords.push_back(info.pos);
refresh_adjacent_smooth_walls(map, info.pos);
if (info.imat < 0) if (info.imat < 0)
continue; continue;
if (produces_item(options.boulder_percents, if (produces_item(options.boulder_percents,