|
|
|
@ -1,16 +1,23 @@
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <cstdio>
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
#include <stack>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
|
|
#include "Core.h"
|
|
|
|
|
#include "Console.h"
|
|
|
|
|
#include "Export.h"
|
|
|
|
|
#include "PluginManager.h"
|
|
|
|
|
#include "modules/Maps.h"
|
|
|
|
|
#include "uicommon.h"
|
|
|
|
|
|
|
|
|
|
#include "modules/Gui.h"
|
|
|
|
|
#include "modules/MapCache.h"
|
|
|
|
|
#include "modules/Maps.h"
|
|
|
|
|
#include "modules/Materials.h"
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <cstdio>
|
|
|
|
|
#include <stack>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
|
|
#include "df/ui_sidebar_menus.h"
|
|
|
|
|
|
|
|
|
|
using std::vector;
|
|
|
|
|
using std::string;
|
|
|
|
|
using std::stack;
|
|
|
|
@ -27,6 +34,7 @@ command_result digcircle (color_ostream &out, vector <string> & parameters);
|
|
|
|
|
command_result digtype (color_ostream &out, vector <string> & parameters);
|
|
|
|
|
|
|
|
|
|
DFHACK_PLUGIN("dig");
|
|
|
|
|
REQUIRE_GLOBAL(ui_sidebar_menus);
|
|
|
|
|
REQUIRE_GLOBAL(world);
|
|
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
|
|
|
|
@ -97,6 +105,7 @@ enum circle_what
|
|
|
|
|
bool dig (MapExtras::MapCache & MCache,
|
|
|
|
|
circle_what what,
|
|
|
|
|
df::tile_dig_designation type,
|
|
|
|
|
int32_t priority,
|
|
|
|
|
int32_t x, int32_t y, int32_t z,
|
|
|
|
|
int x_max, int y_max
|
|
|
|
|
)
|
|
|
|
@ -175,20 +184,21 @@ bool dig (MapExtras::MapCache & MCache,
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
std::cerr << "allowing tt" << (int)tt << "\n";
|
|
|
|
|
MCache.setDesignationAt(at,des);
|
|
|
|
|
MCache.setDesignationAt(at,des,priority);
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool lineX (MapExtras::MapCache & MCache,
|
|
|
|
|
circle_what what,
|
|
|
|
|
df::tile_dig_designation type,
|
|
|
|
|
int32_t priority,
|
|
|
|
|
int32_t y1, int32_t y2, int32_t x, int32_t z,
|
|
|
|
|
int x_max, int y_max
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
for(int32_t y = y1; y <= y2; y++)
|
|
|
|
|
{
|
|
|
|
|
dig(MCache, what, type,x,y,z, x_max, y_max);
|
|
|
|
|
dig(MCache, what, type, priority, x,y,z, x_max, y_max);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
@ -196,17 +206,51 @@ bool lineX (MapExtras::MapCache & MCache,
|
|
|
|
|
bool lineY (MapExtras::MapCache & MCache,
|
|
|
|
|
circle_what what,
|
|
|
|
|
df::tile_dig_designation type,
|
|
|
|
|
int32_t priority,
|
|
|
|
|
int32_t x1, int32_t x2, int32_t y, int32_t z,
|
|
|
|
|
int x_max, int y_max
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
for(int32_t x = x1; x <= x2; x++)
|
|
|
|
|
{
|
|
|
|
|
dig(MCache, what, type,x,y,z, x_max, y_max);
|
|
|
|
|
dig(MCache, what, type, priority, x,y,z, x_max, y_max);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int32_t parse_priority(color_ostream &out, vector<string> ¶meters)
|
|
|
|
|
{
|
|
|
|
|
int32_t default_priority = ui_sidebar_menus->designation.priority;
|
|
|
|
|
|
|
|
|
|
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()));
|
|
|
|
|
parameters.erase(it);
|
|
|
|
|
parameters.erase(it + 1);
|
|
|
|
|
return priority;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
out.printerr("invalid priority specified; reverting to %i\n", default_priority);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return default_priority;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
command_result digcircle (color_ostream &out, vector <string> & parameters)
|
|
|
|
|
{
|
|
|
|
|
static bool filled = false;
|
|
|
|
@ -215,6 +259,8 @@ command_result digcircle (color_ostream &out, vector <string> & parameters)
|
|
|
|
|
static int diameter = 0;
|
|
|
|
|
auto saved_d = diameter;
|
|
|
|
|
bool force_help = false;
|
|
|
|
|
int32_t priority = parse_priority(out, parameters);
|
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < parameters.size();i++)
|
|
|
|
|
{
|
|
|
|
|
if(parameters[i] == "help" || parameters[i] == "?")
|
|
|
|
@ -326,12 +372,12 @@ command_result digcircle (color_ostream &out, vector <string> & parameters)
|
|
|
|
|
// paint center
|
|
|
|
|
if(filled)
|
|
|
|
|
{
|
|
|
|
|
lineY(MCache,what,type, cx - r, cx + r, cy, cz,x_max,y_max);
|
|
|
|
|
lineY(MCache, what, type, priority, cx - r, cx + r, cy, cz, x_max, y_max);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dig(MCache, what, type,cx - r, cy, cz,x_max,y_max);
|
|
|
|
|
dig(MCache, what, type,cx + r, cy, cz,x_max,y_max);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
adjust = false;
|
|
|
|
|
iter = 2;
|
|
|
|
@ -363,24 +409,24 @@ command_result digcircle (color_ostream &out, vector <string> & parameters)
|
|
|
|
|
// paint
|
|
|
|
|
if(filled || iter == diameter - 1)
|
|
|
|
|
{
|
|
|
|
|
lineY(MCache,what,type, left, right, top , cz,x_max,y_max);
|
|
|
|
|
lineY(MCache,what,type, left, right, bottom , cz,x_max,y_max);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dig(MCache, what, type,left, top, cz,x_max,y_max);
|
|
|
|
|
dig(MCache, what, type,left, bottom, cz,x_max,y_max);
|
|
|
|
|
dig(MCache, what, type,right, top, cz,x_max,y_max);
|
|
|
|
|
dig(MCache, what, type,right, bottom, cz,x_max,y_max);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
if(!filled && diff > 1)
|
|
|
|
|
{
|
|
|
|
|
int lright = cx + lastwhole;
|
|
|
|
|
int lleft = cx - lastwhole + adjust;
|
|
|
|
|
lineY(MCache,what,type, lleft + 1, left - 1, top + 1 , cz,x_max,y_max);
|
|
|
|
|
lineY(MCache,what,type, right + 1, lright - 1, top + 1 , cz,x_max,y_max);
|
|
|
|
|
lineY(MCache,what,type, lleft + 1, left - 1, bottom - 1 , cz,x_max,y_max);
|
|
|
|
|
lineY(MCache,what,type, right + 1, lright - 1, bottom - 1 , cz,x_max,y_max);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
lastwhole = whole;
|
|
|
|
|
}
|
|
|
|
@ -808,6 +854,8 @@ command_result digexp (color_ostream &out, vector <string> & parameters)
|
|
|
|
|
bool force_help = false;
|
|
|
|
|
static explo_how how = EXPLO_NOTHING;
|
|
|
|
|
static explo_what what = EXPLO_HIDDEN;
|
|
|
|
|
int32_t priority = parse_priority(out, parameters);
|
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < parameters.size();i++)
|
|
|
|
|
{
|
|
|
|
|
if(parameters[i] == "help" || parameters[i] == "?")
|
|
|
|
@ -963,7 +1011,7 @@ command_result digexp (color_ostream &out, vector <string> & parameters)
|
|
|
|
|
if(cross[y][x])
|
|
|
|
|
{
|
|
|
|
|
des.bits.dig = tile_dig_designation::Default;
|
|
|
|
|
mx.setDesignationAt(pos,des);
|
|
|
|
|
mx.setDesignationAt(pos,des,priority);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mx.WriteAll();
|
|
|
|
@ -984,6 +1032,7 @@ command_result digvx (color_ostream &out, vector <string> & parameters)
|
|
|
|
|
// HOTKEY COMMAND: CORE ALREADY SUSPENDED
|
|
|
|
|
vector <string> lol;
|
|
|
|
|
lol.push_back("x");
|
|
|
|
|
lol.push_back(string("-p") + int_to_string(parse_priority(out, parameters)));
|
|
|
|
|
return digv(out,lol);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -992,6 +1041,8 @@ command_result digv (color_ostream &out, vector <string> & parameters)
|
|
|
|
|
// HOTKEY COMMAND: CORE ALREADY SUSPENDED
|
|
|
|
|
uint32_t x_max,y_max,z_max;
|
|
|
|
|
bool updown = false;
|
|
|
|
|
int32_t priority = parse_priority(out, parameters);
|
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < parameters.size();i++)
|
|
|
|
|
{
|
|
|
|
|
if(parameters.size() && parameters[0]=="x")
|
|
|
|
@ -1118,7 +1169,7 @@ command_result digv (color_ostream &out, vector <string> & parameters)
|
|
|
|
|
des_minus.bits.dig = tile_dig_designation::UpDownStair;
|
|
|
|
|
else
|
|
|
|
|
des_minus.bits.dig = tile_dig_designation::UpStair;
|
|
|
|
|
MCache->setDesignationAt(current-1,des_minus);
|
|
|
|
|
MCache->setDesignationAt(current-1,des_minus,priority);
|
|
|
|
|
|
|
|
|
|
des.bits.dig = tile_dig_designation::DownStair;
|
|
|
|
|
}
|
|
|
|
@ -1130,7 +1181,7 @@ command_result digv (color_ostream &out, vector <string> & parameters)
|
|
|
|
|
des_plus.bits.dig = tile_dig_designation::UpDownStair;
|
|
|
|
|
else
|
|
|
|
|
des_plus.bits.dig = tile_dig_designation::DownStair;
|
|
|
|
|
MCache->setDesignationAt(current+1,des_plus);
|
|
|
|
|
MCache->setDesignationAt(current+1,des_plus,priority);
|
|
|
|
|
|
|
|
|
|
if(des.bits.dig == tile_dig_designation::DownStair)
|
|
|
|
|
des.bits.dig = tile_dig_designation::UpDownStair;
|
|
|
|
@ -1140,7 +1191,7 @@ command_result digv (color_ostream &out, vector <string> & parameters)
|
|
|
|
|
}
|
|
|
|
|
if(des.bits.dig == tile_dig_designation::No)
|
|
|
|
|
des.bits.dig = tile_dig_designation::Default;
|
|
|
|
|
MCache->setDesignationAt(current,des);
|
|
|
|
|
MCache->setDesignationAt(current,des,priority);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MCache->WriteAll();
|
|
|
|
@ -1153,6 +1204,7 @@ command_result diglx (color_ostream &out, vector <string> & parameters)
|
|
|
|
|
// HOTKEY COMMAND: CORE ALREADY SUSPENDED
|
|
|
|
|
vector <string> lol;
|
|
|
|
|
lol.push_back("x");
|
|
|
|
|
lol.push_back(string("-p") + int_to_string(parse_priority(out, parameters)));
|
|
|
|
|
return digl(out,lol);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1168,6 +1220,8 @@ command_result digl (color_ostream &out, vector <string> & parameters)
|
|
|
|
|
uint32_t x_max,y_max,z_max;
|
|
|
|
|
bool updown = false;
|
|
|
|
|
bool undo = false;
|
|
|
|
|
int32_t priority = parse_priority(out, parameters);
|
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < parameters.size();i++)
|
|
|
|
|
{
|
|
|
|
|
if(parameters[i]=="x")
|
|
|
|
@ -1326,7 +1380,7 @@ command_result digl (color_ostream &out, vector <string> & parameters)
|
|
|
|
|
// undo mode: clear designation
|
|
|
|
|
if(undo)
|
|
|
|
|
des_minus.bits.dig = tile_dig_designation::No;
|
|
|
|
|
MCache->setDesignationAt(current-1,des_minus);
|
|
|
|
|
MCache->setDesignationAt(current-1,des_minus,priority);
|
|
|
|
|
|
|
|
|
|
des.bits.dig = tile_dig_designation::DownStair;
|
|
|
|
|
}
|
|
|
|
@ -1341,7 +1395,7 @@ command_result digl (color_ostream &out, vector <string> & parameters)
|
|
|
|
|
// undo mode: clear designation
|
|
|
|
|
if(undo)
|
|
|
|
|
des_plus.bits.dig = tile_dig_designation::No;
|
|
|
|
|
MCache->setDesignationAt(current+1,des_plus);
|
|
|
|
|
MCache->setDesignationAt(current+1,des_plus,priority);
|
|
|
|
|
|
|
|
|
|
if(des.bits.dig == tile_dig_designation::DownStair)
|
|
|
|
|
des.bits.dig = tile_dig_designation::UpDownStair;
|
|
|
|
@ -1354,7 +1408,7 @@ command_result digl (color_ostream &out, vector <string> & parameters)
|
|
|
|
|
// undo mode: clear designation
|
|
|
|
|
if(undo)
|
|
|
|
|
des.bits.dig = tile_dig_designation::No;
|
|
|
|
|
MCache->setDesignationAt(current,des);
|
|
|
|
|
MCache->setDesignationAt(current,des,priority);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MCache->WriteAll();
|
|
|
|
@ -1371,6 +1425,7 @@ command_result digauto (color_ostream &out, vector <string> & parameters)
|
|
|
|
|
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 )
|
|
|
|
|
{
|
|
|
|
@ -1474,7 +1529,7 @@ command_result digtype (color_ostream &out, vector <string> & parameters)
|
|
|
|
|
|
|
|
|
|
df::tile_designation designation = mCache->designationAt(current);
|
|
|
|
|
designation.bits.dig = baseDes.bits.dig;
|
|
|
|
|
mCache->setDesignationAt(current, designation);
|
|
|
|
|
mCache->setDesignationAt(current, designation,priority);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|