@ -4,6 +4,7 @@
# include <stack>
# include <stack>
# include <string>
# include <string>
# include <cmath>
# include <cmath>
# include <memory>
# include "Core.h"
# include "Core.h"
# include "Console.h"
# include "Console.h"
@ -1072,14 +1073,13 @@ command_result digv (color_ostream &out, vector <string> & parameters)
con . printerr ( " I won't dig the borders. That would be cheating! \n " ) ;
con . printerr ( " I won't dig the borders. That would be cheating! \n " ) ;
return CR_FAILURE ;
return CR_FAILURE ;
}
}
MapExtras: : MapCache * MCache = new MapExtras : : MapCache ;
std: : unique_ptr < MapExtras : : MapCache > MCache = std : : make_unique < MapExtras : : MapCache > ( ) ;
df : : tile_designation des = MCache - > designationAt ( xy ) ;
df : : tile_designation des = MCache - > designationAt ( xy ) ;
df : : tiletype tt = MCache - > tiletypeAt ( xy ) ;
df : : tiletype tt = MCache - > tiletypeAt ( xy ) ;
int16_t veinmat = MCache - > veinMaterialAt ( xy ) ;
int16_t veinmat = MCache - > veinMaterialAt ( xy ) ;
if ( veinmat = = - 1 )
if ( veinmat = = - 1 )
{
{
con . printerr ( " This tile is not a vein. \n " ) ;
con . printerr ( " This tile is not a vein. \n " ) ;
delete MCache ;
return CR_FAILURE ;
return CR_FAILURE ;
}
}
con . print ( " %d/%d/%d tiletype: %d, veinmat: %d, designation: 0x%x ... DIGGING! \n " , cx , cy , cz , tt , veinmat , des . whole ) ;
con . print ( " %d/%d/%d tiletype: %d, veinmat: %d, designation: 0x%x ... DIGGING! \n " , cx , cy , cz , tt , veinmat , des . whole ) ;
@ -1192,7 +1192,6 @@ command_result digv (color_ostream &out, vector <string> & parameters)
}
}
}
}
MCache - > WriteAll ( ) ;
MCache - > WriteAll ( ) ;
delete MCache ;
return CR_OK ;
return CR_OK ;
}
}
@ -1259,7 +1258,7 @@ command_result digl (color_ostream &out, vector <string> & parameters)
con . printerr ( " I won't dig the borders. That would be cheating! \n " ) ;
con . printerr ( " I won't dig the borders. That would be cheating! \n " ) ;
return CR_FAILURE ;
return CR_FAILURE ;
}
}
MapExtras: : MapCache * MCache = new MapExtras : : MapCache ;
std: : unique_ptr < MapExtras : : MapCache > MCache = std : : make_unique < MapExtras : : MapCache > ( ) ;
df : : tile_designation des = MCache - > designationAt ( xy ) ;
df : : tile_designation des = MCache - > designationAt ( xy ) ;
df : : tiletype tt = MCache - > tiletypeAt ( xy ) ;
df : : tiletype tt = MCache - > tiletypeAt ( xy ) ;
int16_t veinmat = MCache - > veinMaterialAt ( xy ) ;
int16_t veinmat = MCache - > veinMaterialAt ( xy ) ;
@ -1267,7 +1266,6 @@ command_result digl (color_ostream &out, vector <string> & parameters)
if ( veinmat ! = - 1 )
if ( veinmat ! = - 1 )
{
{
con . printerr ( " This is a vein. Use digv instead! \n " ) ;
con . printerr ( " This is a vein. Use digv instead! \n " ) ;
delete MCache ;
return CR_FAILURE ;
return CR_FAILURE ;
}
}
con . print ( " %d/%d/%d tiletype: %d, basemat: %d, designation: 0x%x ... DIGGING! \n " , cx , cy , cz , tt , basemat , des . whole ) ;
con . print ( " %d/%d/%d tiletype: %d, basemat: %d, designation: 0x%x ... DIGGING! \n " , cx , cy , cz , tt , basemat , des . whole ) ;
@ -1408,7 +1406,6 @@ command_result digl (color_ostream &out, vector <string> & parameters)
}
}
}
}
MCache - > WriteAll ( ) ;
MCache - > WriteAll ( ) ;
delete MCache ;
return CR_OK ;
return CR_OK ;
}
}
@ -1424,9 +1421,13 @@ command_result digtype (color_ostream &out, vector <string> & parameters)
return CR_FAILURE ;
return CR_FAILURE ;
}
}
uint32_t zMin = 0 ;
uint32_t xMax , yMax , zMax ;
uint32_t xMax , yMax , zMax ;
Maps : : getSize ( xMax , yMax , zMax ) ;
Maps : : getSize ( xMax , yMax , zMax ) ;
bool hidden = false ;
bool automine = true ;
int32_t targetDigType = - 1 ;
int32_t targetDigType = - 1 ;
for ( string parameter : parameters ) {
for ( string parameter : parameters ) {
if ( parameter = = " clear " )
if ( parameter = = " clear " )
@ -1443,8 +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 " )
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 = = " --zup " | | parameter = = " -u " )
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 ( ) ) ;
@ -1462,14 +1471,21 @@ command_result digtype (color_ostream &out, vector <string> & parameters)
return CR_FAILURE ;
return CR_FAILURE ;
}
}
DFHack : : DFCoord xy ( ( uint32_t ) cx , ( uint32_t ) cy , cz ) ;
DFHack : : DFCoord xy ( ( uint32_t ) cx , ( uint32_t ) cy , cz ) ;
MapExtras: : MapCache * mCache = new 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 & & ! 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 ;
}
df : : tile_occupancy baseOcc = mCache - > occupancyAt ( xy ) ;
df : : tiletype tt = mCache - > tiletypeAt ( xy ) ;
df : : tiletype tt = mCache - > tiletypeAt ( xy ) ;
int16_t veinmat = mCache - > veinMaterialAt ( xy ) ;
int16_t veinmat = mCache - > veinMaterialAt ( xy ) ;
if ( veinmat = = - 1 )
if ( veinmat = = - 1 )
{
{
out . printerr ( " This tile is not a vein. \n " ) ;
out . printerr ( " This tile is not a vein. \n " ) ;
delete mCache ;
return CR_FAILURE ;
return CR_FAILURE ;
}
}
out . print ( " (%d,%d,%d) tiletype: %d, veinmat: %d, designation: 0x%x ... DIGGING! \n " , cx , cy , cz , tt , veinmat , baseDes . whole ) ;
out . print ( " (%d,%d,%d) tiletype: %d, veinmat: %d, designation: 0x%x ... DIGGING! \n " , cx , cy , cz , tt , veinmat , baseDes . whole ) ;
@ -1485,8 +1501,12 @@ command_result digtype (color_ostream &out, vector <string> & parameters)
baseDes . bits . dig = tile_dig_designation : : Default ;
baseDes . bits . dig = tile_dig_designation : : Default ;
}
}
}
}
// 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 & & automine ) baseOcc . bits . dig_auto = true ;
else baseOcc . bits . dig_auto = false ;
for ( uint32_t z = 0 ; z < zMax ; z + + )
for ( uint32_t z = zMin ; z < zMax ; z + + )
{
{
for ( uint32_t x = 1 ; x < tileXMax - 1 ; x + + )
for ( uint32_t x = 1 ; x < tileXMax - 1 ; x + + )
{
{
@ -1506,18 +1526,22 @@ command_result digtype (color_ostream &out, vector <string> & parameters)
if ( ! mCache - > testCoord ( current ) )
if ( ! mCache - > testCoord ( current ) )
{
{
out . printerr ( " testCoord failed at (%d,%d,%d) \n " , x , y , z ) ;
out . printerr ( " testCoord failed at (%d,%d,%d) \n " , x , y , z ) ;
delete mCache ;
return CR_FAILURE ;
return CR_FAILURE ;
}
}
df : : tile_designation designation = mCache - > designationAt ( current ) ;
df : : tile_designation designation = mCache - > designationAt ( current ) ;
if ( designation . bits . hidden & & ! hidden ) continue ;
df : : tile_occupancy occupancy = mCache - > occupancyAt ( current ) ;
designation . bits . dig = baseDes . bits . dig ;
designation . bits . dig = baseDes . bits . dig ;
occupancy . bits . dig_auto = baseOcc . bits . dig_auto ;
mCache - > setDesignationAt ( current , designation , priority ) ;
mCache - > setDesignationAt ( current , designation , priority ) ;
mCache - > setOccupancyAt ( current , occupancy ) ;
}
}
}
}
}
}
mCache - > WriteAll ( ) ;
mCache - > WriteAll ( ) ;
delete mCache ;
return CR_OK ;
return CR_OK ;
}
}