From b22ca57f50d6c3446af6e3cea5375305a3ea9065 Mon Sep 17 00:00:00 2001 From: Najeeb Al-Shabibi Date: Sun, 24 Sep 2023 12:15:46 +0100 Subject: [PATCH] added previous 'hidden' and 'no-auto' functionality as options, and adjusted how z-level options are specified --- docs/plugins/dig.rst | 25 +++++++++++++++++-------- plugins/dig.cpp | 21 +++++++++++++++------ 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/docs/plugins/dig.rst b/docs/plugins/dig.rst index d6b6451a6..9cb3cc505 100644 --- a/docs/plugins/dig.rst +++ b/docs/plugins/dig.rst @@ -50,7 +50,7 @@ Usage Designate circles. The diameter is the number of tiles across the center of the circle that you want to dig. See the `digcircle`_ section below for options. -``digtype [] [-p] [-z]`` +``digtype [] [-p] [--zup|-u] [--zdown|-zu] [--cur-zlevel|-z] [--hidden|-h] [--no-auto|-a]`` Designate all vein tiles of the same type as the selected tile. See the `digtype`_ section below for options. ``digexp [] [] [-p]`` @@ -119,9 +119,11 @@ the last selected parameters. digtype ------- -For every tile on the map of the same vein type as the selected tile, this -command designates it to have the same designation as the selected tile. If the -selected tile has no designation, they will be dig designated. +For every tile on the map of the same vein type as the selected tile, this command +designates it to have the same designation as the selected tile. If the selected +tile has no designation, they will be dig designated. By default, only designates +visible tiles, and in the case of dig designation, applies automatic mining to them +(designates uncovered neighbouring tiles of the same type to be dug). If an argument is given, the designation of the selected tile is ignored, and all appropriate tiles are set to the specified designation. @@ -143,10 +145,17 @@ Designation options: ``clear`` Clear any designations. -You can also pass a ``-z`` and/or a ``+z``` option, which restricts designations to the -current z-level and down/up. This is useful when you don't want to designate tiles on the -same z-levels as your carefully dug fort above/below. To dig only at the current z-level, -pass in both. +Other options: +``--zdown`` or ``-d`` + Only designates tiles on the cursor's z-level and below +``--zup`` or ``-u`` + Only designates tiles on the cursor's z-level and above +``--cur-zlevel`` or ``-z`` + Only designates tiles on the same z-level as the cursor +``--hidden`` or ``-h`` + Allows designation of hidden tiles, and using a hidden tile as the "palette" +``--no-auto`` or ``-a`` + No automatic mining mode designation - useful if you want to avoid dwarves digging where you don't want them digexp ------ diff --git a/plugins/dig.cpp b/plugins/dig.cpp index 1379bc3db..836f48e9d 100644 --- a/plugins/dig.cpp +++ b/plugins/dig.cpp @@ -1425,6 +1425,9 @@ command_result digtype (color_ostream &out, vector & parameters) Maps::getSize(xMax,yMax,zMax); uint32_t zMin = 0; + + bool hidden = false; + bool automine = true; int32_t targetDigType = -1; for (string parameter : parameters) { @@ -1442,10 +1445,16 @@ command_result digtype (color_ostream &out, vector & parameters) targetDigType = tile_dig_designation::DownStair; else if ( parameter == "up" ) targetDigType = tile_dig_designation::UpStair; - else if ( parameter == "-z" ) + else if ( parameter == "-z" || parameter == "--cur-zlevel" ) + {zMax = *window_z + 1; zMin = *window_z;} + else if ( parameter == "--zdown" || parameter == "-d") zMax = *window_z + 1; - else if ( parameter == "+z") + else if ( parameter == "--zup" || parameter == "-u") zMin = *window_z; + else if ( parameter == "--hidden" || parameter == "-h") + hidden = true; + else if ( parameter == "--no-auto" || parameter == "-a" ) + automine = false; else { out.printerr("Invalid parameter: '%s'.\n", parameter.c_str()); @@ -1466,8 +1475,8 @@ command_result digtype (color_ostream &out, vector & parameters) std::unique_ptr mCache = std::make_unique(); df::tile_designation baseDes = mCache->designationAt(xy); - if (baseDes.bits.hidden) { - out.printerr("Cursor is pointing at a hidden tile. Point the cursor at a visible tile"); + if (baseDes.bits.hidden && !hidden) { + out.printerr("Cursor is pointing at a hidden tile. Point the cursor at a visible tile when using the --hidden option.\n"); return CR_FAILURE; } @@ -1495,7 +1504,7 @@ command_result digtype (color_ostream &out, vector & parameters) } // Auto dig only works on default dig designation. Setting dig_auto for any other designation // prevents dwarves from digging that tile at all. - if (baseDes.bits.dig == tile_dig_designation::Default) baseOcc.bits.dig_auto = true; + if (baseDes.bits.dig == tile_dig_designation::Default && automine) baseOcc.bits.dig_auto = true; else baseOcc.bits.dig_auto = false; for( uint32_t z = zMin; z < zMax; z++ ) @@ -1523,7 +1532,7 @@ command_result digtype (color_ostream &out, vector & parameters) df::tile_designation designation = mCache->designationAt(current); - if (designation.bits.hidden) continue; + if (designation.bits.hidden && !hidden) continue; df::tile_occupancy occupancy = mCache->occupancyAt(current); designation.bits.dig = baseDes.bits.dig;