added previous 'hidden' and 'no-auto' functionality as options, and adjusted how z-level options are specified

develop
Najeeb Al-Shabibi 2023-09-24 12:15:46 +01:00
parent 6fe0fb5bf9
commit b22ca57f50
2 changed files with 32 additions and 14 deletions

@ -50,7 +50,7 @@ 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>] [-z]`` ``digtype [<designation>] [-p<number>] [--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 Designate all vein tiles of the same type as the selected tile. See the
`digtype`_ section below for options. `digtype`_ section below for options.
``digexp [<pattern>] [<filter>] [-p<number>]`` ``digexp [<pattern>] [<filter>] [-p<number>]``
@ -119,9 +119,11 @@ the last selected parameters.
digtype digtype
------- -------
For every tile on the map of the same vein type as the selected tile, this For every tile on the map of the same vein type as the selected tile, this command
command designates it to have the same designation as the selected tile. If the designates it to have the same designation as the selected tile. If the selected
selected tile has no designation, they will be dig designated. 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 If an argument is given, the designation of the selected tile is ignored, and
all appropriate tiles are set to the specified designation. all appropriate tiles are set to the specified designation.
@ -143,10 +145,17 @@ Designation options:
``clear`` ``clear``
Clear any designations. Clear any designations.
You can also pass a ``-z`` and/or a ``+z``` option, which restricts designations to the Other options:
current z-level and down/up. This is useful when you don't want to designate tiles on the ``--zdown`` or ``-d``
same z-levels as your carefully dug fort above/below. To dig only at the current z-level, Only designates tiles on the cursor's z-level and below
pass in both. ``--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 digexp
------ ------

@ -1425,6 +1425,9 @@ command_result digtype (color_ostream &out, vector <string> & parameters)
Maps::getSize(xMax,yMax,zMax); Maps::getSize(xMax,yMax,zMax);
uint32_t zMin = 0; uint32_t zMin = 0;
bool hidden = false;
bool automine = true;
int32_t targetDigType = -1; int32_t targetDigType = -1;
for (string parameter : parameters) { for (string parameter : parameters) {
@ -1442,10 +1445,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" ) else if ( parameter == "-z" || parameter == "--cur-zlevel" )
{zMax = *window_z + 1; zMin = *window_z;}
else if ( parameter == "--zdown" || parameter == "-d")
zMax = *window_z + 1; zMax = *window_z + 1;
else if ( parameter == "+z") else if ( parameter == "--zup" || parameter == "-u")
zMin = *window_z; zMin = *window_z;
else if ( parameter == "--hidden" || parameter == "-h")
hidden = true;
else if ( parameter == "--no-auto" || parameter == "-a" )
automine = false;
else else
{ {
out.printerr("Invalid parameter: '%s'.\n", parameter.c_str()); out.printerr("Invalid parameter: '%s'.\n", parameter.c_str());
@ -1466,8 +1475,8 @@ command_result digtype (color_ostream &out, vector <string> & parameters)
std::unique_ptr<MapExtras::MapCache> mCache = std::make_unique<MapExtras::MapCache>(); std::unique_ptr<MapExtras::MapCache> mCache = std::make_unique<MapExtras::MapCache>();
df::tile_designation baseDes = mCache->designationAt(xy); df::tile_designation baseDes = mCache->designationAt(xy);
if (baseDes.bits.hidden) { if (baseDes.bits.hidden && !hidden) {
out.printerr("Cursor is pointing at a hidden tile. Point the cursor at a visible tile"); 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; return CR_FAILURE;
} }
@ -1495,7 +1504,7 @@ command_result digtype (color_ostream &out, vector <string> & parameters)
} }
// Auto dig only works on default dig designation. Setting dig_auto for any other designation // Auto dig only works on default dig designation. Setting dig_auto for any other designation
// prevents dwarves from digging that tile at all. // 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; else baseOcc.bits.dig_auto = false;
for( uint32_t z = zMin; z < zMax; z++ ) for( uint32_t z = zMin; z < zMax; z++ )
@ -1523,7 +1532,7 @@ command_result digtype (color_ostream &out, vector <string> & parameters)
df::tile_designation designation = mCache->designationAt(current); 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); df::tile_occupancy occupancy = mCache->occupancyAt(current);
designation.bits.dig = baseDes.bits.dig; designation.bits.dig = baseDes.bits.dig;