From 33816b8bc215dcf7b11c9c6ea1cc98f9e80ce0e0 Mon Sep 17 00:00:00 2001 From: myk002 Date: Wed, 5 Oct 2022 14:01:09 -0700 Subject: [PATCH] optionally process only the cur z-level and below --- docs/changelog.txt | 1 + docs/plugins/dig.rst | 12 ++++++++---- plugins/dig.cpp | 31 ++++++++++++------------------- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index fb11def8e..eba15cfb4 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -40,6 +40,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Misc Improvements - `ls`: indent tag listings and wrap them in the right column for better readability - `ls`: new ``--exclude`` option for hiding matched scripts from the output. this can be especially useful for modders who don't want their mod scripts to be included in ``ls`` output. +- `digtype`: new ``-z`` option for digtype to restrict designations to the current z-level and down ## Documentation diff --git a/docs/plugins/dig.rst b/docs/plugins/dig.rst index 4384ade65..a10db97df 100644 --- a/docs/plugins/dig.rst +++ b/docs/plugins/dig.rst @@ -25,7 +25,7 @@ dig :summary: Designate circles. .. dfhack-command:: digtype - :summary: Designate all vein tiles of the selected type. + :summary: Designate all vein tiles of the same type as the selected tile. .. dfhack-command:: digexp :summary: Designate dig patterns for exploratory mining. @@ -50,9 +50,9 @@ 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]`` - Designate all vein tiles of the selected type. See the `digtype`_ section - below for options. +``digtype [] [-p] [-z]`` + Designate all vein tiles of the same type as the selected tile. See the + `digtype`_ section below for options. ``digexp [] [] [-p]`` Designate dig patterns for exploratory mining. See the `digexp`_ section below for options. @@ -143,6 +143,10 @@ Designation options: ``clear`` Clear any designations. +You can also pass a ``-z`` option, which restricts designations to the current +z-level and down. This is useful when you don't want to designate tiles on the +same z-levels as your carefully dug fort above. + digexp ------ diff --git a/plugins/dig.cpp b/plugins/dig.cpp index ddc2cd97e..945bf3613 100644 --- a/plugins/dig.cpp +++ b/plugins/dig.cpp @@ -35,6 +35,7 @@ command_result digtype (color_ostream &out, vector & parameters); DFHACK_PLUGIN("dig"); REQUIRE_GLOBAL(ui_sidebar_menus); REQUIRE_GLOBAL(world); +REQUIRE_GLOBAL(window_z); DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) { @@ -1417,16 +1418,18 @@ command_result digtype (color_ostream &out, vector & parameters) //mostly copy-pasted from digv int32_t priority = parse_priority(out, parameters); CoreSuspender suspend; - if ( parameters.size() > 1 ) + + if (!Maps::IsValid()) { - out.printerr("Too many parameters.\n"); + out.printerr("Map is not available!\n"); return CR_FAILURE; } - int32_t targetDigType; - if ( parameters.size() == 1 ) - { - string parameter = parameters[0]; + uint32_t xMax,yMax,zMax; + Maps::getSize(xMax,yMax,zMax); + + int32_t targetDigType = -1; + for (string parameter : parameters) { if ( parameter == "clear" ) targetDigType = tile_dig_designation::No; else if ( parameter == "dig" ) @@ -1441,26 +1444,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" ) + zMax = *window_z + 1; else { - out.printerr("Invalid parameter.\n"); + out.printerr("Invalid parameter: '%s'.\n", parameter.c_str()); return CR_FAILURE; } } - else - { - targetDigType = -1; - } - - if (!Maps::IsValid()) - { - out.printerr("Map is not available!\n"); - return CR_FAILURE; - } int32_t cx, cy, cz; - uint32_t xMax,yMax,zMax; - Maps::getSize(xMax,yMax,zMax); uint32_t tileXMax = xMax * 16; uint32_t tileYMax = yMax * 16; Gui::getCursorCoords(cx,cy,cz);