2018-01-21 17:27:16 -07:00
|
|
|
#include <vector>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <stack>
|
|
|
|
#include <string>
|
|
|
|
#include <cmath>
|
|
|
|
|
2011-12-31 04:48:42 -07:00
|
|
|
#include "Core.h"
|
2012-01-15 13:54:14 -07:00
|
|
|
#include "Console.h"
|
|
|
|
#include "Export.h"
|
|
|
|
#include "PluginManager.h"
|
2018-01-21 17:27:16 -07:00
|
|
|
|
2012-01-15 13:54:14 -07:00
|
|
|
#include "modules/Gui.h"
|
|
|
|
#include "modules/MapCache.h"
|
2018-01-21 17:27:16 -07:00
|
|
|
#include "modules/Maps.h"
|
2012-03-31 07:41:55 -06:00
|
|
|
#include "modules/Materials.h"
|
2018-01-21 17:27:16 -07:00
|
|
|
|
2023-01-05 18:11:01 -07:00
|
|
|
#include "df/gamest.h"
|
2018-01-21 17:27:16 -07:00
|
|
|
|
2011-07-10 13:07:14 -06:00
|
|
|
using std::vector;
|
|
|
|
using std::string;
|
2011-07-11 14:23:13 -06:00
|
|
|
using std::stack;
|
2011-07-10 13:07:14 -06:00
|
|
|
using namespace DFHack;
|
2012-01-21 17:31:15 -07:00
|
|
|
using namespace df::enums;
|
2011-07-10 13:07:14 -06:00
|
|
|
|
2012-03-31 07:41:55 -06:00
|
|
|
command_result digv (color_ostream &out, vector <string> & parameters);
|
|
|
|
command_result digvx (color_ostream &out, vector <string> & parameters);
|
|
|
|
command_result digl (color_ostream &out, vector <string> & parameters);
|
|
|
|
command_result diglx (color_ostream &out, vector <string> & parameters);
|
|
|
|
command_result digexp (color_ostream &out, vector <string> & parameters);
|
2012-03-10 04:55:42 -07:00
|
|
|
command_result digcircle (color_ostream &out, vector <string> & parameters);
|
2012-08-19 20:45:47 -06:00
|
|
|
command_result digtype (color_ostream &out, vector <string> & parameters);
|
2011-07-10 13:07:14 -06:00
|
|
|
|
2012-03-31 07:41:55 -06:00
|
|
|
DFHACK_PLUGIN("dig");
|
2023-01-05 18:11:01 -07:00
|
|
|
REQUIRE_GLOBAL(game);
|
2014-12-02 19:44:20 -07:00
|
|
|
REQUIRE_GLOBAL(world);
|
2022-10-05 15:01:09 -06:00
|
|
|
REQUIRE_GLOBAL(window_z);
|
2011-07-10 13:07:14 -06:00
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
|
2011-07-10 13:07:14 -06:00
|
|
|
{
|
2011-12-31 02:25:46 -07:00
|
|
|
commands.push_back(PluginCommand(
|
2022-07-24 17:08:35 -06:00
|
|
|
"digv",
|
|
|
|
"Dig a whole vein.",
|
|
|
|
digv,
|
|
|
|
Gui::cursor_hotkey));
|
2011-12-31 02:25:46 -07:00
|
|
|
commands.push_back(PluginCommand(
|
2022-07-24 17:08:35 -06:00
|
|
|
"digvx",
|
|
|
|
"Dig a whole vein, following through z-levels.",
|
|
|
|
digvx,
|
|
|
|
Gui::cursor_hotkey));
|
2012-03-31 07:41:55 -06:00
|
|
|
commands.push_back(PluginCommand(
|
2022-07-24 17:08:35 -06:00
|
|
|
"digl",
|
|
|
|
"Dig layerstone.",
|
|
|
|
digl,
|
|
|
|
Gui::cursor_hotkey));
|
2012-03-31 07:41:55 -06:00
|
|
|
commands.push_back(PluginCommand(
|
2022-07-24 17:08:35 -06:00
|
|
|
"diglx",
|
|
|
|
"Dig layerstone, following through z-levels.",
|
|
|
|
diglx,
|
|
|
|
Gui::cursor_hotkey));
|
|
|
|
commands.push_back(PluginCommand(
|
|
|
|
"digexp",
|
|
|
|
"Select or designate an exploratory pattern.",
|
|
|
|
digexp));
|
|
|
|
commands.push_back(PluginCommand(
|
|
|
|
"digcircle",
|
|
|
|
"Dig designate a circle (filled or hollow)",
|
|
|
|
digcircle));
|
|
|
|
commands.push_back(PluginCommand(
|
|
|
|
"digtype",
|
|
|
|
"Dig all veins of a given type.",
|
|
|
|
digtype,Gui::cursor_hotkey));
|
2011-07-10 13:07:14 -06:00
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
DFhackCExport command_result plugin_shutdown ( color_ostream &out )
|
2011-07-10 13:07:14 -06:00
|
|
|
{
|
|
|
|
return CR_OK;
|
|
|
|
}
|
2011-08-22 07:18:35 -06:00
|
|
|
|
|
|
|
template <class T>
|
2012-01-21 17:31:15 -07:00
|
|
|
bool from_string(T& t,
|
|
|
|
const std::string& s,
|
|
|
|
std::ios_base& (*f)(std::ios_base&))
|
2011-08-22 07:18:35 -06:00
|
|
|
{
|
|
|
|
std::istringstream iss(s);
|
|
|
|
return !(iss >> f >> t).fail();
|
|
|
|
}
|
|
|
|
|
|
|
|
enum circle_what
|
|
|
|
{
|
|
|
|
circle_set,
|
|
|
|
circle_unset,
|
2011-08-27 07:12:03 -06:00
|
|
|
circle_invert,
|
2011-08-22 07:18:35 -06:00
|
|
|
};
|
|
|
|
|
2011-11-15 13:58:38 -07:00
|
|
|
bool dig (MapExtras::MapCache & MCache,
|
2012-01-21 17:31:15 -07:00
|
|
|
circle_what what,
|
|
|
|
df::tile_dig_designation type,
|
2018-01-21 17:27:16 -07:00
|
|
|
int32_t priority,
|
2012-01-21 17:31:15 -07:00
|
|
|
int32_t x, int32_t y, int32_t z,
|
|
|
|
int x_max, int y_max
|
|
|
|
)
|
2011-11-15 13:58:38 -07:00
|
|
|
{
|
|
|
|
DFCoord at (x,y,z);
|
|
|
|
auto b = MCache.BlockAt(at/16);
|
2012-04-10 08:21:19 -06:00
|
|
|
if(!b || !b->is_valid())
|
2011-11-15 13:58:38 -07:00
|
|
|
return false;
|
|
|
|
if(x == 0 || x == x_max * 16 - 1)
|
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
//out.print("not digging map border\n");
|
2011-11-15 13:58:38 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(y == 0 || y == y_max * 16 - 1)
|
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
//out.print("not digging map border\n");
|
2011-11-15 13:58:38 -07:00
|
|
|
return false;
|
|
|
|
}
|
2012-02-13 15:56:33 -07:00
|
|
|
df::tiletype tt = MCache.tiletypeAt(at);
|
2012-01-19 13:11:52 -07:00
|
|
|
df::tile_designation des = MCache.designationAt(at);
|
2011-11-15 13:58:38 -07:00
|
|
|
// could be potentially used to locate hidden constructions?
|
2012-03-13 12:15:12 -06:00
|
|
|
if(tileMaterial(tt) == tiletype_material::CONSTRUCTION && !des.bits.hidden)
|
2011-11-15 13:58:38 -07:00
|
|
|
return false;
|
2012-02-13 15:56:33 -07:00
|
|
|
df::tiletype_shape ts = tileShape(tt);
|
2013-04-12 07:14:35 -06:00
|
|
|
if (ts == tiletype_shape::EMPTY && !des.bits.hidden)
|
2011-11-15 13:58:38 -07:00
|
|
|
return false;
|
|
|
|
if(!des.bits.hidden)
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2012-02-13 18:17:38 -07:00
|
|
|
df::tiletype_shape_basic tsb = ENUM_ATTR(tiletype_shape, basic_shape, ts);
|
2012-02-13 15:56:33 -07:00
|
|
|
if(tsb == tiletype_shape_basic::Wall)
|
2011-11-15 13:58:38 -07:00
|
|
|
{
|
2012-02-13 15:56:33 -07:00
|
|
|
std::cerr << "allowing tt" << (int)tt << ", is wall\n";
|
2011-11-15 13:58:38 -07:00
|
|
|
break;
|
|
|
|
}
|
2012-02-13 15:56:33 -07:00
|
|
|
if (tsb == tiletype_shape_basic::Floor
|
2012-01-21 17:31:15 -07:00
|
|
|
&& (type == tile_dig_designation::DownStair || type == tile_dig_designation::Channel)
|
2014-07-25 19:49:46 -06:00
|
|
|
&& ts != tiletype_shape::BRANCH
|
|
|
|
&& ts != tiletype_shape::TRUNK_BRANCH
|
|
|
|
&& ts != tiletype_shape::TWIG
|
2012-01-21 17:31:15 -07:00
|
|
|
)
|
2011-11-15 13:58:38 -07:00
|
|
|
{
|
2012-02-13 15:56:33 -07:00
|
|
|
std::cerr << "allowing tt" << (int)tt << ", is floor\n";
|
2011-11-15 13:58:38 -07:00
|
|
|
break;
|
|
|
|
}
|
2012-02-13 15:56:33 -07:00
|
|
|
if (tsb == tiletype_shape_basic::Stair && type == tile_dig_designation::Channel )
|
2011-11-15 13:58:38 -07:00
|
|
|
break;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
while(0);
|
|
|
|
}
|
|
|
|
switch(what)
|
|
|
|
{
|
2012-01-21 17:31:15 -07:00
|
|
|
case circle_set:
|
|
|
|
if(des.bits.dig == tile_dig_designation::No)
|
|
|
|
{
|
|
|
|
des.bits.dig = type;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case circle_unset:
|
|
|
|
if (des.bits.dig != tile_dig_designation::No)
|
|
|
|
{
|
|
|
|
des.bits.dig = tile_dig_designation::No;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case circle_invert:
|
|
|
|
if(des.bits.dig == tile_dig_designation::No)
|
|
|
|
{
|
|
|
|
des.bits.dig = type;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
des.bits.dig = tile_dig_designation::No;
|
|
|
|
}
|
|
|
|
break;
|
2011-11-15 13:58:38 -07:00
|
|
|
}
|
2012-02-13 15:56:33 -07:00
|
|
|
std::cerr << "allowing tt" << (int)tt << "\n";
|
2018-01-21 17:27:16 -07:00
|
|
|
MCache.setDesignationAt(at,des,priority);
|
2011-11-15 13:58:38 -07:00
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool lineX (MapExtras::MapCache & MCache,
|
2012-01-21 17:31:15 -07:00
|
|
|
circle_what what,
|
|
|
|
df::tile_dig_designation type,
|
2018-01-21 17:27:16 -07:00
|
|
|
int32_t priority,
|
2012-01-21 17:31:15 -07:00
|
|
|
int32_t y1, int32_t y2, int32_t x, int32_t z,
|
|
|
|
int x_max, int y_max
|
|
|
|
)
|
2011-11-15 13:58:38 -07:00
|
|
|
{
|
|
|
|
for(int32_t y = y1; y <= y2; y++)
|
|
|
|
{
|
2018-01-21 17:27:16 -07:00
|
|
|
dig(MCache, what, type, priority, x,y,z, x_max, y_max);
|
2011-11-15 13:58:38 -07:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool lineY (MapExtras::MapCache & MCache,
|
2012-01-21 17:31:15 -07:00
|
|
|
circle_what what,
|
|
|
|
df::tile_dig_designation type,
|
2018-01-21 17:27:16 -07:00
|
|
|
int32_t priority,
|
2012-01-21 17:31:15 -07:00
|
|
|
int32_t x1, int32_t x2, int32_t y, int32_t z,
|
|
|
|
int x_max, int y_max
|
|
|
|
)
|
2011-11-15 13:58:38 -07:00
|
|
|
{
|
|
|
|
for(int32_t x = x1; x <= x2; x++)
|
|
|
|
{
|
2018-01-21 17:27:16 -07:00
|
|
|
dig(MCache, what, type, priority, x,y,z, x_max, y_max);
|
2011-11-15 13:58:38 -07:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
2018-01-21 17:27:16 -07:00
|
|
|
int32_t parse_priority(color_ostream &out, vector<string> ¶meters)
|
|
|
|
{
|
2023-01-28 08:06:48 -07:00
|
|
|
int32_t default_priority = game->main_interface.designation.priority;
|
2018-01-21 17:27:16 -07:00
|
|
|
|
|
|
|
for (auto it = parameters.begin(); it != parameters.end(); ++it)
|
|
|
|
{
|
|
|
|
const string &s = *it;
|
|
|
|
if (s.substr(0, 2) == "p=" || s.substr(0, 2) == "-p")
|
|
|
|
{
|
|
|
|
if (s.size() >= 3)
|
|
|
|
{
|
|
|
|
auto priority = int32_t(1000 * atof(s.c_str() + 2));
|
|
|
|
parameters.erase(it);
|
|
|
|
return priority;
|
|
|
|
}
|
|
|
|
else if (it + 1 != parameters.end())
|
|
|
|
{
|
|
|
|
auto priority = int32_t(1000 * atof((*(it + 1)).c_str()));
|
2018-01-28 00:16:57 -07:00
|
|
|
parameters.erase(it, it + 2);
|
2018-01-21 17:27:16 -07:00
|
|
|
return priority;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
out.printerr("invalid priority specified; reverting to %i\n", default_priority);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return default_priority;
|
|
|
|
}
|
|
|
|
|
2018-01-28 00:16:57 -07:00
|
|
|
string forward_priority(color_ostream &out, vector<string> ¶meters)
|
|
|
|
{
|
|
|
|
return string("-p") + int_to_string(parse_priority(out, parameters) / 1000);
|
|
|
|
}
|
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
command_result digcircle (color_ostream &out, vector <string> & parameters)
|
2011-08-22 07:18:35 -06:00
|
|
|
{
|
|
|
|
static bool filled = false;
|
|
|
|
static circle_what what = circle_set;
|
2012-01-21 17:31:15 -07:00
|
|
|
static df::tile_dig_designation type = tile_dig_designation::Default;
|
2011-08-26 21:50:14 -06:00
|
|
|
static int diameter = 0;
|
|
|
|
auto saved_d = diameter;
|
2011-08-22 07:18:35 -06:00
|
|
|
bool force_help = false;
|
2018-01-21 17:27:16 -07:00
|
|
|
int32_t priority = parse_priority(out, parameters);
|
|
|
|
|
2012-01-31 09:55:38 -07:00
|
|
|
for(size_t i = 0; i < parameters.size();i++)
|
2011-08-22 07:18:35 -06:00
|
|
|
{
|
|
|
|
if(parameters[i] == "help" || parameters[i] == "?")
|
|
|
|
{
|
|
|
|
force_help = true;
|
|
|
|
}
|
|
|
|
else if(parameters[i] == "hollow")
|
|
|
|
{
|
|
|
|
filled = false;
|
|
|
|
}
|
|
|
|
else if(parameters[i] == "filled")
|
|
|
|
{
|
|
|
|
filled = true;
|
|
|
|
}
|
|
|
|
else if(parameters[i] == "set")
|
|
|
|
{
|
|
|
|
what = circle_set;
|
|
|
|
}
|
|
|
|
else if(parameters[i] == "unset")
|
|
|
|
{
|
|
|
|
what = circle_unset;
|
|
|
|
}
|
2011-08-27 07:12:03 -06:00
|
|
|
else if(parameters[i] == "invert")
|
|
|
|
{
|
|
|
|
what = circle_invert;
|
|
|
|
}
|
2011-08-23 04:51:11 -06:00
|
|
|
else if(parameters[i] == "dig")
|
|
|
|
{
|
2012-01-21 17:31:15 -07:00
|
|
|
type = tile_dig_designation::Default;
|
2011-08-23 04:51:11 -06:00
|
|
|
}
|
|
|
|
else if(parameters[i] == "ramp")
|
|
|
|
{
|
2012-01-21 17:31:15 -07:00
|
|
|
type = tile_dig_designation::Ramp;
|
2011-08-23 04:51:11 -06:00
|
|
|
}
|
|
|
|
else if(parameters[i] == "dstair")
|
|
|
|
{
|
2012-01-21 17:31:15 -07:00
|
|
|
type = tile_dig_designation::DownStair;
|
2011-08-23 04:51:11 -06:00
|
|
|
}
|
|
|
|
else if(parameters[i] == "ustair")
|
|
|
|
{
|
2012-01-21 17:31:15 -07:00
|
|
|
type = tile_dig_designation::UpStair;
|
2011-08-23 04:51:11 -06:00
|
|
|
}
|
|
|
|
else if(parameters[i] == "xstair")
|
|
|
|
{
|
2012-01-21 17:31:15 -07:00
|
|
|
type = tile_dig_designation::UpDownStair;
|
2011-08-23 04:51:11 -06:00
|
|
|
}
|
|
|
|
else if(parameters[i] == "chan")
|
|
|
|
{
|
2012-01-21 17:31:15 -07:00
|
|
|
type = tile_dig_designation::Channel;
|
2011-08-23 04:51:11 -06:00
|
|
|
}
|
2011-08-26 21:50:14 -06:00
|
|
|
else if (!from_string(diameter,parameters[i], std::dec))
|
2011-08-22 07:18:35 -06:00
|
|
|
{
|
2011-08-26 21:50:14 -06:00
|
|
|
diameter = saved_d;
|
2011-08-22 07:18:35 -06:00
|
|
|
}
|
|
|
|
}
|
2011-08-26 21:50:14 -06:00
|
|
|
if(diameter < 0)
|
|
|
|
diameter = -diameter;
|
|
|
|
if(force_help || diameter == 0)
|
2011-08-22 07:18:35 -06:00
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print(
|
2012-01-21 17:31:15 -07:00
|
|
|
"A command for easy designation of filled and hollow circles.\n"
|
|
|
|
"\n"
|
|
|
|
"Options:\n"
|
|
|
|
" hollow = Set the circle to hollow (default)\n"
|
|
|
|
" filled = Set the circle to filled\n"
|
|
|
|
"\n"
|
|
|
|
" set = set designation\n"
|
|
|
|
" unset = unset current designation\n"
|
|
|
|
" invert = invert current designation\n"
|
|
|
|
"\n"
|
|
|
|
" dig = normal digging\n"
|
|
|
|
" ramp = ramp digging\n"
|
|
|
|
" ustair = staircase up\n"
|
|
|
|
" dstair = staircase down\n"
|
|
|
|
" xstair = staircase up/down\n"
|
|
|
|
" chan = dig channel\n"
|
|
|
|
"\n"
|
|
|
|
" # = diameter in tiles (default = 0)\n"
|
2018-01-28 00:16:57 -07:00
|
|
|
" -p # = designation priority (default = 4)\n"
|
2012-01-21 17:31:15 -07:00
|
|
|
"\n"
|
|
|
|
"After you have set the options, the command called with no options\n"
|
|
|
|
"repeats with the last selected parameters:\n"
|
2013-04-03 14:16:36 -06:00
|
|
|
"'digcircle filled 3' = Dig a filled circle with diameter = 3.\n"
|
2012-01-21 17:31:15 -07:00
|
|
|
"'digcircle' = Do it again.\n"
|
|
|
|
);
|
2011-08-22 07:18:35 -06:00
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
int32_t cx, cy, cz;
|
2012-03-10 04:55:42 -07:00
|
|
|
CoreSuspender suspend;
|
2012-01-19 20:44:17 -07:00
|
|
|
if (!Maps::IsValid())
|
2011-08-22 07:18:35 -06:00
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("Map is not available!\n");
|
2011-08-22 07:18:35 -06:00
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t x_max, y_max, z_max;
|
2012-01-19 20:44:17 -07:00
|
|
|
Maps::getSize(x_max,y_max,z_max);
|
2011-08-22 07:18:35 -06:00
|
|
|
|
2012-01-19 20:44:17 -07:00
|
|
|
MapExtras::MapCache MCache;
|
2012-03-03 06:38:24 -07:00
|
|
|
if(!Gui::getCursorCoords(cx,cy,cz) || cx == -30000)
|
2011-08-22 07:18:35 -06:00
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("Can't get the cursor coords...\n");
|
2011-08-22 07:18:35 -06:00
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
2011-08-26 21:50:14 -06:00
|
|
|
int r = diameter / 2;
|
|
|
|
int iter;
|
|
|
|
bool adjust;
|
|
|
|
if(diameter % 2)
|
2011-08-22 07:18:35 -06:00
|
|
|
{
|
2011-08-26 21:50:14 -06:00
|
|
|
// paint center
|
|
|
|
if(filled)
|
|
|
|
{
|
2018-01-21 17:27:16 -07:00
|
|
|
lineY(MCache, what, type, priority, cx - r, cx + r, cy, cz, x_max, y_max);
|
2011-08-26 21:50:14 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-01-21 17:27:16 -07:00
|
|
|
dig(MCache, what, type, priority, cx - r, cy, cz, x_max, y_max);
|
|
|
|
dig(MCache, what, type, priority, cx + r, cy, cz, x_max, y_max);
|
2011-08-26 21:50:14 -06:00
|
|
|
}
|
|
|
|
adjust = false;
|
|
|
|
iter = 2;
|
2011-08-22 07:18:35 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-08-26 21:50:14 -06:00
|
|
|
adjust = true;
|
|
|
|
iter = 1;
|
2011-08-22 07:18:35 -06:00
|
|
|
}
|
2011-08-26 21:50:14 -06:00
|
|
|
int lastwhole = r;
|
|
|
|
for(; iter <= diameter - 1; iter +=2)
|
2011-08-22 07:18:35 -06:00
|
|
|
{
|
2011-08-26 21:50:14 -06:00
|
|
|
// top, bottom coords
|
|
|
|
int top = cy - ((iter + 1) / 2) + adjust;
|
|
|
|
int bottom = cy + ((iter + 1) / 2);
|
|
|
|
// see where the current 'line' intersects the circle
|
2011-08-28 14:28:23 -06:00
|
|
|
double val = std::sqrt(double(diameter*diameter - iter*iter));
|
2011-08-26 21:50:14 -06:00
|
|
|
// adjust for circles with odd diameter
|
|
|
|
if(!adjust)
|
|
|
|
val -= 1;
|
|
|
|
// map the found value to the DF grid
|
|
|
|
double whole;
|
|
|
|
double fraction = std::modf(val / 2.0, & whole);
|
|
|
|
if (fraction > 0.5)
|
|
|
|
whole += 1.0;
|
|
|
|
int right = cx + whole;
|
|
|
|
int left = cx - whole + adjust;
|
|
|
|
int diff = lastwhole - whole;
|
|
|
|
// paint
|
|
|
|
if(filled || iter == diameter - 1)
|
2011-08-22 07:18:35 -06:00
|
|
|
{
|
2018-01-21 17:27:16 -07:00
|
|
|
lineY(MCache, what, type, priority, left, right, top, cz, x_max, y_max);
|
|
|
|
lineY(MCache, what, type, priority, left, right, bottom, cz, x_max, y_max);
|
2011-08-22 07:18:35 -06:00
|
|
|
}
|
2011-08-26 21:50:14 -06:00
|
|
|
else
|
2011-08-22 07:18:35 -06:00
|
|
|
{
|
2018-01-21 17:27:16 -07:00
|
|
|
dig(MCache, what, type, priority, left, top, cz, x_max, y_max);
|
|
|
|
dig(MCache, what, type, priority, left, bottom, cz, x_max, y_max);
|
|
|
|
dig(MCache, what, type, priority, right, top, cz, x_max, y_max);
|
|
|
|
dig(MCache, what, type, priority, right, bottom, cz, x_max, y_max);
|
2011-08-22 07:18:35 -06:00
|
|
|
}
|
2011-08-26 21:50:14 -06:00
|
|
|
if(!filled && diff > 1)
|
2011-08-22 07:18:35 -06:00
|
|
|
{
|
2011-08-26 21:50:14 -06:00
|
|
|
int lright = cx + lastwhole;
|
|
|
|
int lleft = cx - lastwhole + adjust;
|
2018-01-21 17:27:16 -07:00
|
|
|
lineY(MCache, what, type, priority, lleft + 1, left - 1, top + 1 , cz, x_max, y_max);
|
|
|
|
lineY(MCache, what, type, priority, right + 1, lright - 1, top + 1 , cz, x_max, y_max);
|
|
|
|
lineY(MCache, what, type, priority, lleft + 1, left - 1, bottom - 1 , cz, x_max, y_max);
|
|
|
|
lineY(MCache, what, type, priority, right + 1, lright - 1, bottom - 1 , cz, x_max, y_max);
|
2011-08-22 07:18:35 -06:00
|
|
|
}
|
2011-08-26 21:50:14 -06:00
|
|
|
lastwhole = whole;
|
2011-08-22 07:18:35 -06:00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|
|
};
|
2011-08-17 06:27:24 -06:00
|
|
|
|
|
|
|
static digmask cross =
|
|
|
|
{
|
|
|
|
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
|
|
|
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
|
|
|
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
|
|
|
{0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0},
|
|
|
|
{0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0},
|
|
|
|
{0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0},
|
|
|
|
{0,0,0,1,0,0,0,1,1,0,0,0,1,0,0,0},
|
|
|
|
{0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0},
|
|
|
|
{0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0},
|
|
|
|
{0,0,0,1,0,0,0,1,1,0,0,0,1,0,0,0},
|
|
|
|
{0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0},
|
|
|
|
{0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0},
|
|
|
|
{0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0},
|
|
|
|
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
|
|
|
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
|
|
|
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
|
|
|
};
|
2011-08-17 05:26:03 -06:00
|
|
|
enum explo_how
|
|
|
|
{
|
|
|
|
EXPLO_NOTHING,
|
|
|
|
EXPLO_DIAG5,
|
2012-01-05 18:27:27 -07:00
|
|
|
EXPLO_DIAG5R,
|
2011-08-17 05:26:03 -06:00
|
|
|
EXPLO_LADDER,
|
2012-01-05 18:27:27 -07:00
|
|
|
EXPLO_LADDERR,
|
2011-08-17 05:26:03 -06:00
|
|
|
EXPLO_CLEAR,
|
2011-08-17 06:27:24 -06:00
|
|
|
EXPLO_CROSS,
|
2011-08-17 05:26:03 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
enum explo_what
|
|
|
|
{
|
|
|
|
EXPLO_ALL,
|
|
|
|
EXPLO_HIDDEN,
|
|
|
|
EXPLO_DESIGNATED,
|
|
|
|
};
|
|
|
|
|
2012-01-19 20:44:17 -07:00
|
|
|
bool stamp_pattern (uint32_t bx, uint32_t by, int z_level,
|
2012-01-21 17:31:15 -07:00
|
|
|
digmask & dm, explo_how how, explo_what what,
|
|
|
|
int x_max, int y_max
|
|
|
|
)
|
2011-11-15 13:58:38 -07:00
|
|
|
{
|
2012-01-19 20:44:17 -07:00
|
|
|
df::map_block * bl = Maps::getBlock(bx,by,z_level);
|
2011-11-15 13:58:38 -07:00
|
|
|
if(!bl)
|
|
|
|
return false;
|
|
|
|
int x = 0,mx = 16;
|
|
|
|
if(bx == 0)
|
|
|
|
x = 1;
|
2018-04-06 00:18:15 -06:00
|
|
|
if(int(bx) == x_max - 1)
|
2011-11-15 13:58:38 -07:00
|
|
|
mx = 15;
|
|
|
|
for(; x < mx; x++)
|
|
|
|
{
|
|
|
|
int y = 0,my = 16;
|
|
|
|
if(by == 0)
|
|
|
|
y = 1;
|
2018-04-06 00:18:15 -06:00
|
|
|
if(int(by) == y_max - 1)
|
2011-11-15 13:58:38 -07:00
|
|
|
my = 15;
|
|
|
|
for(; y < my; y++)
|
|
|
|
{
|
2012-01-19 13:11:52 -07:00
|
|
|
df::tile_designation & des = bl->designation[x][y];
|
2012-02-13 15:56:33 -07:00
|
|
|
df::tiletype tt = bl->tiletype[x][y];
|
2011-11-15 13:58:38 -07:00
|
|
|
// could be potentially used to locate hidden constructions?
|
2012-02-13 15:56:33 -07:00
|
|
|
if(tileMaterial(tt) == tiletype_material::CONSTRUCTION && !des.bits.hidden)
|
2011-11-15 13:58:38 -07:00
|
|
|
continue;
|
2012-01-19 13:11:52 -07:00
|
|
|
if(!isWallTerrain(tt) && !des.bits.hidden)
|
2011-11-15 13:58:38 -07:00
|
|
|
continue;
|
|
|
|
if(how == EXPLO_CLEAR)
|
|
|
|
{
|
2012-01-21 17:31:15 -07:00
|
|
|
des.bits.dig = tile_dig_designation::No;
|
2011-11-15 13:58:38 -07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(dm[y][x])
|
|
|
|
{
|
|
|
|
if(what == EXPLO_ALL
|
2018-04-06 00:18:15 -06:00
|
|
|
|| (des.bits.dig == tile_dig_designation::Default && what == EXPLO_DESIGNATED)
|
|
|
|
|| (des.bits.hidden && what == EXPLO_HIDDEN))
|
2011-11-15 13:58:38 -07:00
|
|
|
{
|
2012-01-21 17:31:15 -07:00
|
|
|
des.bits.dig = tile_dig_designation::Default;
|
2011-11-15 13:58:38 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(what == EXPLO_DESIGNATED)
|
|
|
|
{
|
2012-01-21 17:31:15 -07:00
|
|
|
des.bits.dig = tile_dig_designation::No;
|
2011-11-15 13:58:38 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-02-15 13:35:44 -07:00
|
|
|
bl->flags.bits.designated = true;
|
2011-11-15 13:58:38 -07:00
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
2012-03-31 07:41:55 -06:00
|
|
|
command_result digexp (color_ostream &out, vector <string> & parameters)
|
2011-08-17 05:26:03 -06:00
|
|
|
{
|
|
|
|
bool force_help = false;
|
|
|
|
static explo_how how = EXPLO_NOTHING;
|
|
|
|
static explo_what what = EXPLO_HIDDEN;
|
2018-01-21 17:27:16 -07:00
|
|
|
int32_t priority = parse_priority(out, parameters);
|
|
|
|
|
2012-01-31 09:55:38 -07:00
|
|
|
for(size_t i = 0; i < parameters.size();i++)
|
2011-08-17 05:26:03 -06:00
|
|
|
{
|
|
|
|
if(parameters[i] == "help" || parameters[i] == "?")
|
|
|
|
{
|
|
|
|
force_help = true;
|
|
|
|
}
|
|
|
|
else if(parameters[i] == "all")
|
|
|
|
{
|
|
|
|
what = EXPLO_ALL;
|
|
|
|
}
|
|
|
|
else if(parameters[i] == "hidden")
|
|
|
|
{
|
|
|
|
what = EXPLO_HIDDEN;
|
|
|
|
}
|
|
|
|
else if(parameters[i] == "designated")
|
|
|
|
{
|
|
|
|
what = EXPLO_DESIGNATED;
|
|
|
|
}
|
|
|
|
else if(parameters[i] == "diag5")
|
|
|
|
{
|
|
|
|
how = EXPLO_DIAG5;
|
|
|
|
}
|
2012-01-05 18:27:27 -07:00
|
|
|
else if(parameters[i] == "diag5r")
|
|
|
|
{
|
|
|
|
how = EXPLO_DIAG5R;
|
|
|
|
}
|
2011-08-17 05:26:03 -06:00
|
|
|
else if(parameters[i] == "clear")
|
|
|
|
{
|
|
|
|
how = EXPLO_CLEAR;
|
|
|
|
}
|
|
|
|
else if(parameters[i] == "ladder")
|
|
|
|
{
|
|
|
|
how = EXPLO_LADDER;
|
|
|
|
}
|
2012-01-05 18:27:27 -07:00
|
|
|
else if(parameters[i] == "ladderr")
|
|
|
|
{
|
|
|
|
how = EXPLO_LADDERR;
|
|
|
|
}
|
2011-08-17 06:27:24 -06:00
|
|
|
else if(parameters[i] == "cross")
|
|
|
|
{
|
|
|
|
how = EXPLO_CROSS;
|
|
|
|
}
|
2011-08-17 05:26:03 -06:00
|
|
|
}
|
|
|
|
if(force_help || how == EXPLO_NOTHING)
|
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print(
|
2012-01-21 17:31:15 -07:00
|
|
|
"This command can be used for exploratory mining.\n"
|
2012-02-20 04:04:15 -07:00
|
|
|
"http://dwarffortresswiki.org/Exploratory_mining\n"
|
2012-01-21 17:31:15 -07:00
|
|
|
"\n"
|
|
|
|
"There are two variables that can be set: pattern and filter.\n"
|
|
|
|
"Patterns:\n"
|
|
|
|
" diag5 = diagonals separated by 5 tiles\n"
|
|
|
|
" diag5r = diag5 rotated 90 degrees\n"
|
|
|
|
" ladder = A 'ladder' pattern\n"
|
|
|
|
"ladderr = ladder rotated 90 degrees\n"
|
|
|
|
" clear = Just remove all dig designations\n"
|
|
|
|
" cross = A cross, exactly in the middle of the map.\n"
|
|
|
|
"Filters:\n"
|
|
|
|
" all = designate whole z-level\n"
|
|
|
|
" hidden = designate only hidden tiles of z-level (default)\n"
|
|
|
|
" designated = Take current designation and apply pattern to it.\n"
|
|
|
|
"\n"
|
|
|
|
"After you have a pattern set, you can use 'expdig' to apply it:\n"
|
2012-03-31 07:41:55 -06:00
|
|
|
"'digexp diag5 hidden' = set filter to hidden, pattern to diag5.\n"
|
|
|
|
"'digexp' = apply the pattern with filter.\n"
|
2012-01-21 17:31:15 -07:00
|
|
|
);
|
2011-08-17 05:26:03 -06:00
|
|
|
return CR_OK;
|
|
|
|
}
|
2012-03-10 04:55:42 -07:00
|
|
|
CoreSuspender suspend;
|
2011-08-17 05:26:03 -06:00
|
|
|
uint32_t x_max, y_max, z_max;
|
2012-01-19 20:44:17 -07:00
|
|
|
if (!Maps::IsValid())
|
2011-08-17 05:26:03 -06:00
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("Map is not available!\n");
|
2011-08-17 05:26:03 -06:00
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
2012-01-19 20:44:17 -07:00
|
|
|
Maps::getSize(x_max,y_max,z_max);
|
2011-08-17 05:26:03 -06:00
|
|
|
int32_t xzzz,yzzz,z_level;
|
2012-03-03 06:38:24 -07:00
|
|
|
if(!Gui::getViewCoords(xzzz,yzzz,z_level))
|
2011-08-17 05:26:03 -06:00
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("Can't get view coords...\n");
|
2011-08-17 05:26:03 -06:00
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
if(how == EXPLO_DIAG5)
|
|
|
|
{
|
|
|
|
int which;
|
|
|
|
for(uint32_t x = 0; x < x_max; x++)
|
|
|
|
{
|
2018-04-06 00:18:15 -06:00
|
|
|
for(uint32_t y = 0 ; y < y_max; y++)
|
2011-08-17 05:26:03 -06:00
|
|
|
{
|
|
|
|
which = (4*x + y) % 5;
|
2012-01-19 20:44:17 -07:00
|
|
|
stamp_pattern(x,y_max - 1 - y, z_level, diag5[which],
|
2012-01-21 17:31:15 -07:00
|
|
|
how, what, x_max, y_max);
|
2011-08-17 05:26:03 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-01-05 18:27:27 -07:00
|
|
|
else if(how == EXPLO_DIAG5R)
|
|
|
|
{
|
|
|
|
int which;
|
|
|
|
for(uint32_t x = 0; x < x_max; x++)
|
|
|
|
{
|
2018-04-06 00:18:15 -06:00
|
|
|
for(uint32_t y = 0 ; y < y_max; y++)
|
2012-01-05 18:27:27 -07:00
|
|
|
{
|
|
|
|
which = (4*x + 1000-y) % 5;
|
2012-01-19 20:44:17 -07:00
|
|
|
stamp_pattern(x,y_max - 1 - y, z_level, diag5r[which],
|
2012-01-21 17:31:15 -07:00
|
|
|
how, what, x_max, y_max);
|
2012-01-05 18:27:27 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-08-17 05:26:03 -06:00
|
|
|
else if(how == EXPLO_LADDER)
|
|
|
|
{
|
|
|
|
int which;
|
|
|
|
for(uint32_t x = 0; x < x_max; x++)
|
|
|
|
{
|
|
|
|
which = x % 3;
|
2018-04-06 00:18:15 -06:00
|
|
|
for(uint32_t y = 0 ; y < y_max; y++)
|
2011-08-17 05:26:03 -06:00
|
|
|
{
|
2012-01-19 20:44:17 -07:00
|
|
|
stamp_pattern(x, y, z_level, ladder[which],
|
2011-11-15 13:58:38 -07:00
|
|
|
how, what, x_max, y_max);
|
2011-08-17 05:26:03 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-01-05 18:27:27 -07:00
|
|
|
else if(how == EXPLO_LADDERR)
|
|
|
|
{
|
|
|
|
int which;
|
2018-04-06 00:18:15 -06:00
|
|
|
for(uint32_t y = 0 ; y < y_max; y++)
|
2012-01-05 18:27:27 -07:00
|
|
|
{
|
|
|
|
which = y % 3;
|
|
|
|
for(uint32_t x = 0; x < x_max; x++)
|
|
|
|
{
|
2012-01-19 20:44:17 -07:00
|
|
|
stamp_pattern(x, y, z_level, ladderr[which],
|
2012-01-21 17:31:15 -07:00
|
|
|
how, what, x_max, y_max);
|
2012-01-05 18:27:27 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-08-17 06:27:24 -06:00
|
|
|
else if(how == EXPLO_CROSS)
|
|
|
|
{
|
|
|
|
// middle + recentering for the image
|
|
|
|
int xmid = x_max * 8 - 8;
|
|
|
|
int ymid = y_max * 8 - 8;
|
2012-01-19 20:44:17 -07:00
|
|
|
MapExtras::MapCache mx;
|
2011-08-17 06:27:24 -06:00
|
|
|
for(int x = 0; x < 16; x++)
|
|
|
|
for(int y = 0; y < 16; y++)
|
|
|
|
{
|
|
|
|
DFCoord pos(xmid+x,ymid+y,z_level);
|
2012-02-13 15:56:33 -07:00
|
|
|
df::tiletype tt = mx.tiletypeAt(pos);
|
|
|
|
if(tt == tiletype::Void)
|
2011-08-17 06:27:24 -06:00
|
|
|
continue;
|
2012-01-19 13:11:52 -07:00
|
|
|
df::tile_designation des = mx.designationAt(pos);
|
2012-02-13 15:56:33 -07:00
|
|
|
if(tileMaterial(tt) == tiletype_material::CONSTRUCTION && !des.bits.hidden)
|
2011-08-17 06:29:30 -06:00
|
|
|
continue;
|
|
|
|
if(!isWallTerrain(tt) && !des.bits.hidden)
|
|
|
|
continue;
|
2011-08-17 06:27:24 -06:00
|
|
|
if(cross[y][x])
|
|
|
|
{
|
2012-01-21 17:31:15 -07:00
|
|
|
des.bits.dig = tile_dig_designation::Default;
|
2018-01-21 17:27:16 -07:00
|
|
|
mx.setDesignationAt(pos,des,priority);
|
2011-08-17 06:27:24 -06:00
|
|
|
}
|
|
|
|
}
|
2012-08-27 12:42:00 -06:00
|
|
|
mx.WriteAll();
|
2011-08-17 06:27:24 -06:00
|
|
|
}
|
2011-08-17 05:26:03 -06:00
|
|
|
else for(uint32_t x = 0; x < x_max; x++)
|
2011-11-15 13:58:38 -07:00
|
|
|
{
|
2018-04-06 00:18:15 -06:00
|
|
|
for(uint32_t y = 0 ; y < y_max; y++)
|
2011-11-15 13:58:38 -07:00
|
|
|
{
|
2012-01-19 20:44:17 -07:00
|
|
|
stamp_pattern(x, y, z_level, all_tiles,
|
2012-01-21 17:31:15 -07:00
|
|
|
how, what, x_max, y_max);
|
2011-11-15 13:58:38 -07:00
|
|
|
}
|
|
|
|
}
|
2011-08-17 05:26:03 -06:00
|
|
|
return CR_OK;
|
|
|
|
}
|
2011-12-31 02:25:46 -07:00
|
|
|
|
2012-03-31 07:41:55 -06:00
|
|
|
command_result digvx (color_ostream &out, vector <string> & parameters)
|
2011-08-17 05:26:03 -06:00
|
|
|
{
|
2011-12-31 02:25:46 -07:00
|
|
|
// HOTKEY COMMAND: CORE ALREADY SUSPENDED
|
2011-08-17 05:26:03 -06:00
|
|
|
vector <string> lol;
|
|
|
|
lol.push_back("x");
|
2018-01-28 00:16:57 -07:00
|
|
|
lol.push_back(forward_priority(out, parameters));
|
2012-03-31 07:41:55 -06:00
|
|
|
return digv(out,lol);
|
2011-08-17 05:26:03 -06:00
|
|
|
}
|
2011-07-10 13:07:14 -06:00
|
|
|
|
2012-03-31 07:41:55 -06:00
|
|
|
command_result digv (color_ostream &out, vector <string> & parameters)
|
2011-07-10 13:07:14 -06:00
|
|
|
{
|
2011-12-31 02:25:46 -07:00
|
|
|
// HOTKEY COMMAND: CORE ALREADY SUSPENDED
|
2011-07-11 14:23:13 -06:00
|
|
|
uint32_t x_max,y_max,z_max;
|
|
|
|
bool updown = false;
|
2018-01-21 17:27:16 -07:00
|
|
|
int32_t priority = parse_priority(out, parameters);
|
|
|
|
|
2012-01-31 09:55:38 -07:00
|
|
|
for(size_t i = 0; i < parameters.size();i++)
|
2011-08-14 00:42:21 -06:00
|
|
|
{
|
|
|
|
if(parameters.size() && parameters[0]=="x")
|
|
|
|
updown = true;
|
2011-12-31 02:25:46 -07:00
|
|
|
else
|
|
|
|
return CR_WRONG_USAGE;
|
2011-08-14 00:42:21 -06:00
|
|
|
}
|
2011-07-11 14:23:13 -06:00
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
auto &con = out;
|
2011-07-13 20:05:27 -06:00
|
|
|
|
2012-01-19 20:44:17 -07:00
|
|
|
if (!Maps::IsValid())
|
2011-07-11 14:23:13 -06:00
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("Map is not available!\n");
|
2011-07-11 14:23:13 -06:00
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t cx, cy, cz;
|
2012-01-19 20:44:17 -07:00
|
|
|
Maps::getSize(x_max,y_max,z_max);
|
2011-07-11 14:23:13 -06:00
|
|
|
uint32_t tx_max = x_max * 16;
|
|
|
|
uint32_t ty_max = y_max * 16;
|
2012-03-03 06:38:24 -07:00
|
|
|
Gui::getCursorCoords(cx,cy,cz);
|
2011-07-11 14:23:13 -06:00
|
|
|
while(cx == -30000)
|
|
|
|
{
|
2011-07-15 07:55:01 -06:00
|
|
|
con.printerr("Cursor is not active. Point the cursor at a vein.\n");
|
2011-07-11 14:23:13 -06:00
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
|
2018-04-06 00:18:15 -06:00
|
|
|
if(xy.x == 0 || xy.x == int32_t(tx_max) - 1 || xy.y == 0 || xy.y == int32_t(ty_max) - 1)
|
2011-07-11 14:23:13 -06:00
|
|
|
{
|
2011-07-15 07:55:01 -06:00
|
|
|
con.printerr("I won't dig the borders. That would be cheating!\n");
|
2011-07-11 14:23:13 -06:00
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
2012-01-19 20:44:17 -07:00
|
|
|
MapExtras::MapCache * MCache = new MapExtras::MapCache;
|
2012-01-19 13:11:52 -07:00
|
|
|
df::tile_designation des = MCache->designationAt(xy);
|
2012-02-13 15:56:33 -07:00
|
|
|
df::tiletype tt = MCache->tiletypeAt(xy);
|
2011-07-11 14:23:13 -06:00
|
|
|
int16_t veinmat = MCache->veinMaterialAt(xy);
|
|
|
|
if( veinmat == -1 )
|
|
|
|
{
|
2011-07-15 07:55:01 -06:00
|
|
|
con.printerr("This tile is not a vein.\n");
|
2011-07-11 14:23:13 -06:00
|
|
|
delete MCache;
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
2011-07-13 20:05:27 -06:00
|
|
|
con.print("%d/%d/%d tiletype: %d, veinmat: %d, designation: 0x%x ... DIGGING!\n", cx,cy,cz, tt, veinmat, des.whole);
|
2011-07-11 14:23:13 -06:00
|
|
|
stack <DFHack::DFCoord> flood;
|
|
|
|
flood.push(xy);
|
|
|
|
|
|
|
|
while( !flood.empty() )
|
|
|
|
{
|
|
|
|
DFHack::DFCoord current = flood.top();
|
|
|
|
flood.pop();
|
2012-04-10 08:21:19 -06:00
|
|
|
if (MCache->tagAt(current))
|
|
|
|
continue;
|
2011-07-11 14:23:13 -06:00
|
|
|
int16_t vmat2 = MCache->veinMaterialAt(current);
|
|
|
|
tt = MCache->tiletypeAt(current);
|
|
|
|
if(!DFHack::isWallTerrain(tt))
|
|
|
|
continue;
|
|
|
|
if(vmat2!=veinmat)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// found a good tile, dig+unset material
|
2012-01-19 13:11:52 -07:00
|
|
|
df::tile_designation des = MCache->designationAt(current);
|
|
|
|
df::tile_designation des_minus;
|
|
|
|
df::tile_designation des_plus;
|
2011-07-11 14:23:13 -06:00
|
|
|
des_plus.whole = des_minus.whole = 0;
|
|
|
|
int16_t vmat_minus = -1;
|
|
|
|
int16_t vmat_plus = -1;
|
|
|
|
bool below = 0;
|
|
|
|
bool above = 0;
|
|
|
|
if(updown)
|
|
|
|
{
|
|
|
|
if(MCache->testCoord(current-1))
|
|
|
|
{
|
|
|
|
below = 1;
|
|
|
|
des_minus = MCache->designationAt(current-1);
|
|
|
|
vmat_minus = MCache->veinMaterialAt(current-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(MCache->testCoord(current+1))
|
|
|
|
{
|
|
|
|
above = 1;
|
|
|
|
des_plus = MCache->designationAt(current+1);
|
|
|
|
vmat_plus = MCache->veinMaterialAt(current+1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(MCache->testCoord(current))
|
|
|
|
{
|
2012-04-10 08:21:19 -06:00
|
|
|
MCache->setTagAt(current, 1);
|
|
|
|
|
2018-04-06 00:18:15 -06:00
|
|
|
if(current.x < int32_t(tx_max) - 2)
|
2011-07-11 14:23:13 -06:00
|
|
|
{
|
|
|
|
flood.push(DFHack::DFCoord(current.x + 1, current.y, current.z));
|
2018-04-06 00:18:15 -06:00
|
|
|
if(current.y < int32_t(ty_max) - 2)
|
2011-07-11 14:23:13 -06:00
|
|
|
{
|
|
|
|
flood.push(DFHack::DFCoord(current.x + 1, current.y + 1,current.z));
|
|
|
|
flood.push(DFHack::DFCoord(current.x, current.y + 1,current.z));
|
|
|
|
}
|
|
|
|
if(current.y > 1)
|
|
|
|
{
|
|
|
|
flood.push(DFHack::DFCoord(current.x + 1, current.y - 1,current.z));
|
|
|
|
flood.push(DFHack::DFCoord(current.x, current.y - 1,current.z));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(current.x > 1)
|
|
|
|
{
|
|
|
|
flood.push(DFHack::DFCoord(current.x - 1, current.y,current.z));
|
2018-04-06 00:18:15 -06:00
|
|
|
if(current.y < int32_t(ty_max) - 2)
|
2011-07-11 14:23:13 -06:00
|
|
|
{
|
|
|
|
flood.push(DFHack::DFCoord(current.x - 1, current.y + 1,current.z));
|
|
|
|
flood.push(DFHack::DFCoord(current.x, current.y + 1,current.z));
|
|
|
|
}
|
|
|
|
if(current.y > 1)
|
|
|
|
{
|
|
|
|
flood.push(DFHack::DFCoord(current.x - 1, current.y - 1,current.z));
|
|
|
|
flood.push(DFHack::DFCoord(current.x, current.y - 1,current.z));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(updown)
|
|
|
|
{
|
|
|
|
if(current.z > 0 && below && vmat_minus == vmat2)
|
|
|
|
{
|
|
|
|
flood.push(current-1);
|
|
|
|
|
2012-01-21 17:31:15 -07:00
|
|
|
if(des_minus.bits.dig == tile_dig_designation::DownStair)
|
|
|
|
des_minus.bits.dig = tile_dig_designation::UpDownStair;
|
2011-07-11 14:23:13 -06:00
|
|
|
else
|
2012-01-21 17:31:15 -07:00
|
|
|
des_minus.bits.dig = tile_dig_designation::UpStair;
|
2018-01-21 17:27:16 -07:00
|
|
|
MCache->setDesignationAt(current-1,des_minus,priority);
|
2011-07-11 14:23:13 -06:00
|
|
|
|
2012-01-21 17:31:15 -07:00
|
|
|
des.bits.dig = tile_dig_designation::DownStair;
|
2011-07-11 14:23:13 -06:00
|
|
|
}
|
2018-04-06 00:18:15 -06:00
|
|
|
if(current.z < int32_t(z_max) - 1 && above && vmat_plus == vmat2)
|
2011-07-11 14:23:13 -06:00
|
|
|
{
|
|
|
|
flood.push(current+ 1);
|
|
|
|
|
2012-01-21 17:31:15 -07:00
|
|
|
if(des_plus.bits.dig == tile_dig_designation::UpStair)
|
|
|
|
des_plus.bits.dig = tile_dig_designation::UpDownStair;
|
2011-07-11 14:23:13 -06:00
|
|
|
else
|
2012-01-21 17:31:15 -07:00
|
|
|
des_plus.bits.dig = tile_dig_designation::DownStair;
|
2018-01-21 17:27:16 -07:00
|
|
|
MCache->setDesignationAt(current+1,des_plus,priority);
|
2011-07-11 14:23:13 -06:00
|
|
|
|
2012-01-21 17:31:15 -07:00
|
|
|
if(des.bits.dig == tile_dig_designation::DownStair)
|
|
|
|
des.bits.dig = tile_dig_designation::UpDownStair;
|
2011-07-11 14:23:13 -06:00
|
|
|
else
|
2012-01-21 17:31:15 -07:00
|
|
|
des.bits.dig = tile_dig_designation::UpStair;
|
2011-07-11 14:23:13 -06:00
|
|
|
}
|
|
|
|
}
|
2012-01-21 17:31:15 -07:00
|
|
|
if(des.bits.dig == tile_dig_designation::No)
|
|
|
|
des.bits.dig = tile_dig_designation::Default;
|
2018-01-21 17:27:16 -07:00
|
|
|
MCache->setDesignationAt(current,des,priority);
|
2011-07-11 14:23:13 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
MCache->WriteAll();
|
2012-08-27 12:42:00 -06:00
|
|
|
delete MCache;
|
2011-07-10 13:07:14 -06:00
|
|
|
return CR_OK;
|
|
|
|
}
|
2011-07-11 14:23:13 -06:00
|
|
|
|
2012-03-31 07:41:55 -06:00
|
|
|
command_result diglx (color_ostream &out, vector <string> & parameters)
|
|
|
|
{
|
|
|
|
// HOTKEY COMMAND: CORE ALREADY SUSPENDED
|
|
|
|
vector <string> lol;
|
|
|
|
lol.push_back("x");
|
2018-01-28 00:16:57 -07:00
|
|
|
lol.push_back(forward_priority(out, parameters));
|
2012-03-31 07:41:55 -06:00
|
|
|
return digl(out,lol);
|
|
|
|
}
|
|
|
|
|
2015-02-14 20:53:06 -07:00
|
|
|
// TODO:
|
2012-03-31 07:41:55 -06:00
|
|
|
// digl and digv share the longish floodfill code and only use different conditions
|
|
|
|
// to check if a tile should be marked for digging or not.
|
|
|
|
// to make the plugin a bit smaller and cleaner a main execute method would be nice
|
|
|
|
// (doing the floodfill stuff and do the checks dependin on whether called in
|
|
|
|
// "vein" or "layer" mode)
|
|
|
|
command_result digl (color_ostream &out, vector <string> & parameters)
|
|
|
|
{
|
|
|
|
// HOTKEY COMMAND: CORE ALREADY SUSPENDED
|
|
|
|
uint32_t x_max,y_max,z_max;
|
|
|
|
bool updown = false;
|
|
|
|
bool undo = false;
|
2018-01-21 17:27:16 -07:00
|
|
|
int32_t priority = parse_priority(out, parameters);
|
|
|
|
|
2012-03-31 07:41:55 -06:00
|
|
|
for(size_t i = 0; i < parameters.size();i++)
|
|
|
|
{
|
|
|
|
if(parameters[i]=="x")
|
|
|
|
{
|
|
|
|
out << "This might take a while for huge layers..." << std::endl;
|
|
|
|
updown = true;
|
|
|
|
}
|
|
|
|
else if(parameters[i]=="undo")
|
|
|
|
{
|
|
|
|
out << "Removing dig designation." << std::endl;
|
|
|
|
undo = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return CR_WRONG_USAGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto &con = out;
|
|
|
|
|
|
|
|
if (!Maps::IsValid())
|
|
|
|
{
|
|
|
|
out.printerr("Map is not available!\n");
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t cx, cy, cz;
|
|
|
|
Maps::getSize(x_max,y_max,z_max);
|
|
|
|
uint32_t tx_max = x_max * 16;
|
|
|
|
uint32_t ty_max = y_max * 16;
|
|
|
|
Gui::getCursorCoords(cx,cy,cz);
|
|
|
|
while(cx == -30000)
|
|
|
|
{
|
|
|
|
con.printerr("Cursor is not active. Point the cursor at a vein.\n");
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
|
2018-04-06 00:18:15 -06:00
|
|
|
if(xy.x == 0 || xy.x == int32_t(tx_max) - 1 || xy.y == 0 || xy.y == int32_t(ty_max) - 1)
|
2012-03-31 07:41:55 -06:00
|
|
|
{
|
|
|
|
con.printerr("I won't dig the borders. That would be cheating!\n");
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
MapExtras::MapCache * MCache = new MapExtras::MapCache;
|
|
|
|
df::tile_designation des = MCache->designationAt(xy);
|
|
|
|
df::tiletype tt = MCache->tiletypeAt(xy);
|
|
|
|
int16_t veinmat = MCache->veinMaterialAt(xy);
|
2012-04-19 09:17:07 -06:00
|
|
|
int16_t basemat = MCache->layerMaterialAt(xy);
|
2012-03-31 07:41:55 -06:00
|
|
|
if( veinmat != -1 )
|
|
|
|
{
|
2022-03-27 17:54:01 -06:00
|
|
|
con.printerr("This is a vein. Use digv instead!\n");
|
2012-03-31 07:41:55 -06:00
|
|
|
delete MCache;
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
con.print("%d/%d/%d tiletype: %d, basemat: %d, designation: 0x%x ... DIGGING!\n", cx,cy,cz, tt, basemat, des.whole);
|
|
|
|
stack <DFHack::DFCoord> flood;
|
|
|
|
flood.push(xy);
|
|
|
|
|
|
|
|
while( !flood.empty() )
|
|
|
|
{
|
|
|
|
DFHack::DFCoord current = flood.top();
|
|
|
|
flood.pop();
|
2012-04-10 08:21:19 -06:00
|
|
|
if (MCache->tagAt(current))
|
|
|
|
continue;
|
2012-03-31 07:41:55 -06:00
|
|
|
int16_t vmat2 = MCache->veinMaterialAt(current);
|
2012-04-19 09:17:07 -06:00
|
|
|
int16_t bmat2 = MCache->layerMaterialAt(current);
|
2012-03-31 07:41:55 -06:00
|
|
|
tt = MCache->tiletypeAt(current);
|
|
|
|
|
|
|
|
if(!DFHack::isWallTerrain(tt))
|
|
|
|
continue;
|
|
|
|
if(vmat2!=-1)
|
|
|
|
continue;
|
|
|
|
if(bmat2!=basemat)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// don't dig out LAVA_STONE or MAGMA (semi-molten rock) accidentally
|
|
|
|
if( tileMaterial(tt)!=tiletype_material::STONE
|
|
|
|
&& tileMaterial(tt)!=tiletype_material::SOIL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// found a good tile, dig+unset material
|
|
|
|
df::tile_designation des = MCache->designationAt(current);
|
|
|
|
df::tile_designation des_minus;
|
|
|
|
df::tile_designation des_plus;
|
|
|
|
des_plus.whole = des_minus.whole = 0;
|
|
|
|
int16_t vmat_minus = -1;
|
|
|
|
int16_t vmat_plus = -1;
|
|
|
|
int16_t bmat_minus = -1;
|
|
|
|
int16_t bmat_plus = -1;
|
|
|
|
df::tiletype tt_minus;
|
|
|
|
df::tiletype tt_plus;
|
|
|
|
|
|
|
|
if(MCache->testCoord(current))
|
|
|
|
{
|
2012-04-10 08:21:19 -06:00
|
|
|
MCache->setTagAt(current, 1);
|
2018-04-06 00:18:15 -06:00
|
|
|
if(current.x < int32_t(tx_max) - 2)
|
2012-03-31 07:41:55 -06:00
|
|
|
{
|
|
|
|
flood.push(DFHack::DFCoord(current.x + 1, current.y, current.z));
|
2018-04-06 00:18:15 -06:00
|
|
|
if(current.y < int32_t(ty_max) - 2)
|
2012-03-31 07:41:55 -06:00
|
|
|
{
|
|
|
|
flood.push(DFHack::DFCoord(current.x + 1, current.y + 1, current.z));
|
|
|
|
flood.push(DFHack::DFCoord(current.x, current.y + 1, current.z));
|
|
|
|
}
|
|
|
|
if(current.y > 1)
|
|
|
|
{
|
|
|
|
flood.push(DFHack::DFCoord(current.x + 1, current.y - 1, current.z));
|
|
|
|
flood.push(DFHack::DFCoord(current.x, current.y - 1, current.z));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(current.x > 1)
|
|
|
|
{
|
|
|
|
flood.push(DFHack::DFCoord(current.x - 1, current.y, current.z));
|
2018-04-06 00:18:15 -06:00
|
|
|
if(current.y < int32_t(ty_max) - 2)
|
2012-03-31 07:41:55 -06:00
|
|
|
{
|
|
|
|
flood.push(DFHack::DFCoord(current.x - 1, current.y + 1, current.z));
|
|
|
|
flood.push(DFHack::DFCoord(current.x, current.y + 1, current.z));
|
|
|
|
}
|
|
|
|
if(current.y > 1)
|
|
|
|
{
|
|
|
|
flood.push(DFHack::DFCoord(current.x - 1, current.y - 1, current.z));
|
|
|
|
flood.push(DFHack::DFCoord(current.x, current.y - 1, current.z));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(updown)
|
|
|
|
{
|
|
|
|
bool below = 0;
|
|
|
|
bool above = 0;
|
|
|
|
if(MCache->testCoord(current-1))
|
|
|
|
{
|
|
|
|
//below = 1;
|
|
|
|
des_minus = MCache->designationAt(current-1);
|
|
|
|
vmat_minus = MCache->veinMaterialAt(current-1);
|
2012-04-19 09:17:07 -06:00
|
|
|
bmat_minus = MCache->layerMaterialAt(current-1);
|
2012-03-31 07:41:55 -06:00
|
|
|
tt_minus = MCache->tiletypeAt(current-1);
|
|
|
|
if ( tileMaterial(tt_minus)==tiletype_material::STONE
|
|
|
|
|| tileMaterial(tt_minus)==tiletype_material::SOIL)
|
|
|
|
below = 1;
|
|
|
|
}
|
|
|
|
if(MCache->testCoord(current+1))
|
|
|
|
{
|
|
|
|
//above = 1;
|
|
|
|
des_plus = MCache->designationAt(current+1);
|
|
|
|
vmat_plus = MCache->veinMaterialAt(current+1);
|
2012-04-19 09:17:07 -06:00
|
|
|
bmat_plus = MCache->layerMaterialAt(current+1);
|
2012-03-31 07:41:55 -06:00
|
|
|
tt_plus = MCache->tiletypeAt(current+1);
|
|
|
|
if ( tileMaterial(tt_plus)==tiletype_material::STONE
|
|
|
|
|| tileMaterial(tt_plus)==tiletype_material::SOIL)
|
|
|
|
above = 1;
|
|
|
|
}
|
|
|
|
if(current.z > 0 && below && vmat_minus == -1 && bmat_minus == basemat)
|
|
|
|
{
|
|
|
|
flood.push(current-1);
|
|
|
|
|
|
|
|
if(des_minus.bits.dig == tile_dig_designation::DownStair)
|
|
|
|
des_minus.bits.dig = tile_dig_designation::UpDownStair;
|
|
|
|
else
|
|
|
|
des_minus.bits.dig = tile_dig_designation::UpStair;
|
2012-04-02 08:07:23 -06:00
|
|
|
// undo mode: clear designation
|
|
|
|
if(undo)
|
|
|
|
des_minus.bits.dig = tile_dig_designation::No;
|
2018-01-21 17:27:16 -07:00
|
|
|
MCache->setDesignationAt(current-1,des_minus,priority);
|
2012-03-31 07:41:55 -06:00
|
|
|
|
|
|
|
des.bits.dig = tile_dig_designation::DownStair;
|
|
|
|
}
|
2018-04-06 00:18:15 -06:00
|
|
|
if(current.z < int32_t(z_max) - 1 && above && vmat_plus == -1 && bmat_plus == basemat)
|
2012-03-31 07:41:55 -06:00
|
|
|
{
|
|
|
|
flood.push(current+ 1);
|
|
|
|
|
|
|
|
if(des_plus.bits.dig == tile_dig_designation::UpStair)
|
|
|
|
des_plus.bits.dig = tile_dig_designation::UpDownStair;
|
|
|
|
else
|
|
|
|
des_plus.bits.dig = tile_dig_designation::DownStair;
|
2012-04-02 08:07:23 -06:00
|
|
|
// undo mode: clear designation
|
|
|
|
if(undo)
|
|
|
|
des_plus.bits.dig = tile_dig_designation::No;
|
2018-01-21 17:27:16 -07:00
|
|
|
MCache->setDesignationAt(current+1,des_plus,priority);
|
2012-03-31 07:41:55 -06:00
|
|
|
|
|
|
|
if(des.bits.dig == tile_dig_designation::DownStair)
|
|
|
|
des.bits.dig = tile_dig_designation::UpDownStair;
|
|
|
|
else
|
|
|
|
des.bits.dig = tile_dig_designation::UpStair;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(des.bits.dig == tile_dig_designation::No)
|
|
|
|
des.bits.dig = tile_dig_designation::Default;
|
|
|
|
// undo mode: clear designation
|
|
|
|
if(undo)
|
|
|
|
des.bits.dig = tile_dig_designation::No;
|
2018-01-21 17:27:16 -07:00
|
|
|
MCache->setDesignationAt(current,des,priority);
|
2012-03-31 07:41:55 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
MCache->WriteAll();
|
2012-08-27 12:42:00 -06:00
|
|
|
delete MCache;
|
2012-03-31 07:41:55 -06:00
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-19 20:45:47 -06:00
|
|
|
command_result digtype (color_ostream &out, vector <string> & parameters)
|
|
|
|
{
|
|
|
|
//mostly copy-pasted from digv
|
2018-01-21 17:27:16 -07:00
|
|
|
int32_t priority = parse_priority(out, parameters);
|
2012-08-19 20:45:47 -06:00
|
|
|
CoreSuspender suspend;
|
2022-10-05 15:01:09 -06:00
|
|
|
|
|
|
|
if (!Maps::IsValid())
|
2012-08-19 20:45:47 -06:00
|
|
|
{
|
2022-10-05 15:01:09 -06:00
|
|
|
out.printerr("Map is not available!\n");
|
2012-08-19 20:45:47 -06:00
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
2015-02-14 20:53:06 -07:00
|
|
|
|
2022-10-05 15:01:09 -06:00
|
|
|
uint32_t xMax,yMax,zMax;
|
|
|
|
Maps::getSize(xMax,yMax,zMax);
|
|
|
|
|
|
|
|
int32_t targetDigType = -1;
|
|
|
|
for (string parameter : parameters) {
|
2012-08-19 20:45:47 -06:00
|
|
|
if ( parameter == "clear" )
|
|
|
|
targetDigType = tile_dig_designation::No;
|
|
|
|
else if ( parameter == "dig" )
|
|
|
|
targetDigType = tile_dig_designation::Default;
|
|
|
|
else if ( parameter == "updown" )
|
|
|
|
targetDigType = tile_dig_designation::UpDownStair;
|
|
|
|
else if ( parameter == "channel" )
|
|
|
|
targetDigType = tile_dig_designation::Channel;
|
|
|
|
else if ( parameter == "ramp" )
|
|
|
|
targetDigType = tile_dig_designation::Ramp;
|
|
|
|
else if ( parameter == "down" )
|
|
|
|
targetDigType = tile_dig_designation::DownStair;
|
|
|
|
else if ( parameter == "up" )
|
|
|
|
targetDigType = tile_dig_designation::UpStair;
|
2022-10-05 15:01:09 -06:00
|
|
|
else if ( parameter == "-z" )
|
|
|
|
zMax = *window_z + 1;
|
2012-08-19 20:45:47 -06:00
|
|
|
else
|
|
|
|
{
|
2022-10-05 15:01:09 -06:00
|
|
|
out.printerr("Invalid parameter: '%s'.\n", parameter.c_str());
|
2012-08-19 20:45:47 -06:00
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
2015-02-14 20:53:06 -07:00
|
|
|
|
2012-08-19 20:45:47 -06:00
|
|
|
int32_t cx, cy, cz;
|
|
|
|
uint32_t tileXMax = xMax * 16;
|
|
|
|
uint32_t tileYMax = yMax * 16;
|
|
|
|
Gui::getCursorCoords(cx,cy,cz);
|
|
|
|
if (cx == -30000)
|
|
|
|
{
|
|
|
|
out.printerr("Cursor is not active. Point the cursor at a vein.\n");
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
|
|
|
|
MapExtras::MapCache * mCache = new MapExtras::MapCache;
|
|
|
|
df::tile_designation baseDes = mCache->designationAt(xy);
|
|
|
|
df::tiletype tt = mCache->tiletypeAt(xy);
|
|
|
|
int16_t veinmat = mCache->veinMaterialAt(xy);
|
|
|
|
if( veinmat == -1 )
|
|
|
|
{
|
|
|
|
out.printerr("This tile is not a vein.\n");
|
|
|
|
delete mCache;
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
out.print("(%d,%d,%d) tiletype: %d, veinmat: %d, designation: 0x%x ... DIGGING!\n", cx,cy,cz, tt, veinmat, baseDes.whole);
|
2015-02-14 20:53:06 -07:00
|
|
|
|
2012-08-19 20:45:47 -06:00
|
|
|
if ( targetDigType != -1 )
|
|
|
|
{
|
|
|
|
baseDes.bits.dig = (tile_dig_designation::tile_dig_designation)targetDigType;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( baseDes.bits.dig == tile_dig_designation::No )
|
|
|
|
{
|
|
|
|
baseDes.bits.dig = tile_dig_designation::Default;
|
|
|
|
}
|
|
|
|
}
|
2015-02-14 20:53:06 -07:00
|
|
|
|
2012-08-19 20:45:47 -06:00
|
|
|
for( uint32_t z = 0; z < zMax; z++ )
|
|
|
|
{
|
|
|
|
for( uint32_t x = 1; x < tileXMax-1; x++ )
|
|
|
|
{
|
|
|
|
for( uint32_t y = 1; y < tileYMax-1; y++ )
|
|
|
|
{
|
|
|
|
DFHack::DFCoord current(x,y,z);
|
|
|
|
int16_t vmat2 = mCache->veinMaterialAt(current);
|
|
|
|
if ( vmat2 != veinmat )
|
|
|
|
continue;
|
|
|
|
tt = mCache->tiletypeAt(current);
|
|
|
|
if (!DFHack::isWallTerrain(tt))
|
|
|
|
continue;
|
2018-03-20 00:44:10 -06:00
|
|
|
if (tileMaterial(tt) != df::enums::tiletype_material::MINERAL)
|
|
|
|
continue;
|
2015-02-14 20:53:06 -07:00
|
|
|
|
2012-08-19 20:45:47 -06:00
|
|
|
//designate it for digging
|
|
|
|
if ( !mCache->testCoord(current) )
|
|
|
|
{
|
|
|
|
out.printerr("testCoord failed at (%d,%d,%d)\n", x, y, z);
|
|
|
|
delete mCache;
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
2015-02-14 20:53:06 -07:00
|
|
|
|
2012-08-19 20:45:47 -06:00
|
|
|
df::tile_designation designation = mCache->designationAt(current);
|
|
|
|
designation.bits.dig = baseDes.bits.dig;
|
2018-01-21 17:27:16 -07:00
|
|
|
mCache->setDesignationAt(current, designation,priority);
|
2012-08-19 20:45:47 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-02-14 20:53:06 -07:00
|
|
|
|
2012-08-19 20:45:47 -06:00
|
|
|
mCache->WriteAll();
|
|
|
|
delete mCache;
|
|
|
|
return CR_OK;
|
|
|
|
}
|