Merge pull request #2318 from myk002/myk_digtype_z

[digtype] optionally process only the cur z-level and below
develop
Myk 2022-10-05 14:07:54 -07:00 committed by GitHub
commit f4502d5a1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
- `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

@ -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 [<designation>] [-p<number>]``
Designate all vein tiles of the selected type. See the `digtype`_ section
below for options.
``digtype [<designation>] [-p<number>] [-z]``
Designate all vein tiles of the same type as the selected tile. See the
`digtype`_ section below for options.
``digexp [<pattern>] [<filter>] [-p<number>]``
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
------

@ -35,6 +35,7 @@ command_result digtype (color_ostream &out, vector <string> & 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 <PluginCommand> &commands)
{
@ -1417,16 +1418,18 @@ command_result digtype (color_ostream &out, vector <string> & 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 <string> & 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);