From 86e1a8d59c22afb84be44726835ff67a4484d080 Mon Sep 17 00:00:00 2001 From: myk002 Date: Wed, 7 Sep 2022 10:10:44 -0700 Subject: [PATCH] When smoothing walls, connect to doors and fgates --- docs/changelog.txt | 1 + plugins/dig-now.cpp | 26 +++++++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index f5f3c8b1b..8560cd4c5 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -43,6 +43,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - `tags`: new built-in command to list the tool category tags and their definitions. tags associated with each tool are visible in the tool help and in the output of `ls`. ## Fixes +- `dig-now`: Fix direction of smoothed walls when adjacent to a door or floodgate - ``job.removeJob()``: ensure jobs are removed from the world list when they are canceled - `quickfort`: `Dreamfort ` blueprint set: declare the hospital zone before building the coffer; otherwise DF fails to stock the hospital with materials diff --git a/plugins/dig-now.cpp b/plugins/dig-now.cpp index bbcabde65..365be3313 100644 --- a/plugins/dig-now.cpp +++ b/plugins/dig-now.cpp @@ -424,26 +424,30 @@ static bool is_smooth_wall(MapExtras::MapCache &map, const DFCoord &pos) { && tileShape(tt) == df::tiletype_shape::WALL; } -static bool is_smooth_wall_or_door(MapExtras::MapCache &map, - const DFCoord &pos) { - if (is_smooth_wall(map, pos)) - return true; - +static bool is_connector(MapExtras::MapCache &map, const DFCoord &pos) { df::building *bld = Buildings::findAtTile(pos); - return bld && bld->getType() == df::building_type::Door; + + return bld && + (bld->getType() == df::building_type::Door || + bld->getType() == df::building_type::Floodgate); +} + +static bool is_smooth_wall_or_connector(MapExtras::MapCache &map, + const DFCoord &pos) { + return is_smooth_wall(map, pos) || is_connector(map, pos); } // adds adjacent smooth walls and doors to the given tdir static TileDirection get_adjacent_smooth_walls(MapExtras::MapCache &map, const DFCoord &pos, TileDirection tdir) { - if (is_smooth_wall_or_door(map, DFCoord(pos.x, pos.y-1, pos.z))) + if (is_smooth_wall_or_connector(map, DFCoord(pos.x, pos.y-1, pos.z))) tdir.north = 1; - if (is_smooth_wall_or_door(map, DFCoord(pos.x, pos.y+1, pos.z))) + if (is_smooth_wall_or_connector(map, DFCoord(pos.x, pos.y+1, pos.z))) tdir.south = 1; - if (is_smooth_wall_or_door(map, DFCoord(pos.x-1, pos.y, pos.z))) + if (is_smooth_wall_or_connector(map, DFCoord(pos.x-1, pos.y, pos.z))) tdir.west = 1; - if (is_smooth_wall_or_door(map, DFCoord(pos.x+1, pos.y, pos.z))) + if (is_smooth_wall_or_connector(map, DFCoord(pos.x+1, pos.y, pos.z))) tdir.east = 1; return tdir; } @@ -469,7 +473,7 @@ static bool adjust_smooth_wall_dir(MapExtras::MapCache &map, const DFCoord &pos, TileDirection tdir = BLANK_TILE_DIRECTION) { if (!is_smooth_wall(map, pos)) - return false; + return is_connector(map, pos); tdir = ensure_valid_tdir(get_adjacent_smooth_walls(map, pos, tdir));