optionally process only the cur z-level and below

develop
myk002 2022-10-05 14:01:09 -07:00
parent 73e291f40f
commit 33816b8bc2
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
3 changed files with 21 additions and 23 deletions

@ -40,6 +40,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Misc Improvements ## Misc Improvements
- `ls`: indent tag listings and wrap them in the right column for better readability - `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. - `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 ## Documentation

@ -25,7 +25,7 @@ dig
:summary: Designate circles. :summary: Designate circles.
.. dfhack-command:: digtype .. 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 .. dfhack-command:: digexp
:summary: Designate dig patterns for exploratory mining. :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 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 the circle that you want to dig. See the `digcircle`_ section below for
options. options.
``digtype [<designation>] [-p<number>]`` ``digtype [<designation>] [-p<number>] [-z]``
Designate all vein tiles of the selected type. See the `digtype`_ section Designate all vein tiles of the same type as the selected tile. See the
below for options. `digtype`_ section below for options.
``digexp [<pattern>] [<filter>] [-p<number>]`` ``digexp [<pattern>] [<filter>] [-p<number>]``
Designate dig patterns for exploratory mining. See the `digexp`_ section Designate dig patterns for exploratory mining. See the `digexp`_ section
below for options. below for options.
@ -143,6 +143,10 @@ Designation options:
``clear`` ``clear``
Clear any designations. 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 digexp
------ ------

@ -35,6 +35,7 @@ command_result digtype (color_ostream &out, vector <string> & parameters);
DFHACK_PLUGIN("dig"); DFHACK_PLUGIN("dig");
REQUIRE_GLOBAL(ui_sidebar_menus); REQUIRE_GLOBAL(ui_sidebar_menus);
REQUIRE_GLOBAL(world); REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(window_z);
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{ {
@ -1417,16 +1418,18 @@ command_result digtype (color_ostream &out, vector <string> & parameters)
//mostly copy-pasted from digv //mostly copy-pasted from digv
int32_t priority = parse_priority(out, parameters); int32_t priority = parse_priority(out, parameters);
CoreSuspender suspend; 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; return CR_FAILURE;
} }
int32_t targetDigType; uint32_t xMax,yMax,zMax;
if ( parameters.size() == 1 ) Maps::getSize(xMax,yMax,zMax);
{
string parameter = parameters[0]; int32_t targetDigType = -1;
for (string parameter : parameters) {
if ( parameter == "clear" ) if ( parameter == "clear" )
targetDigType = tile_dig_designation::No; targetDigType = tile_dig_designation::No;
else if ( parameter == "dig" ) else if ( parameter == "dig" )
@ -1441,26 +1444,16 @@ command_result digtype (color_ostream &out, vector <string> & parameters)
targetDigType = tile_dig_designation::DownStair; targetDigType = tile_dig_designation::DownStair;
else if ( parameter == "up" ) else if ( parameter == "up" )
targetDigType = tile_dig_designation::UpStair; targetDigType = tile_dig_designation::UpStair;
else if ( parameter == "-z" )
zMax = *window_z + 1;
else else
{ {
out.printerr("Invalid parameter.\n"); out.printerr("Invalid parameter: '%s'.\n", parameter.c_str());
return CR_FAILURE; return CR_FAILURE;
} }
} }
else
{
targetDigType = -1;
}
if (!Maps::IsValid())
{
out.printerr("Map is not available!\n");
return CR_FAILURE;
}
int32_t cx, cy, cz; int32_t cx, cy, cz;
uint32_t xMax,yMax,zMax;
Maps::getSize(xMax,yMax,zMax);
uint32_t tileXMax = xMax * 16; uint32_t tileXMax = xMax * 16;
uint32_t tileYMax = yMax * 16; uint32_t tileYMax = yMax * 16;
Gui::getCursorCoords(cx,cy,cz); Gui::getCursorCoords(cx,cy,cz);