diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1e3ec5166..602550b74 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,7 +25,7 @@ set(DF_VERSION_MINOR "31")
set(DF_VERSION_PATCH "25")
set(DF_VERSION "${DF_VERSION_MAJOR}.${DF_VERSION_MINOR}.${DF_VERSION_PATCH}")
-set(DFHACK_RELEASE "5")
+set(DFHACK_RELEASE "6")
## where to install things (after the build is done, classic 'make install' or package structure)
# the dfhack libraries will be installed here:
diff --git a/README.rst b/README.rst
index c2b623fbb..19fc67472 100644
--- a/README.rst
+++ b/README.rst
@@ -277,6 +277,26 @@ Examples:
* 'expdig' = apply last used pattern and filter.
* 'expdig ladder designated' = Take current designations and replace them with the ladder pattern.
+digcircle
+=========
+A command for easy designation of filled and hollow circles.
+
+Options:
+--------
+:hollow: Set the circle to hollow (default)
+:filled: Set the circle to filled
+:set: Set designation (default)
+:unset: Unset current designation
+:#: Radius in tiles (default = 0)
+
+After you have set the options, the command called with no options
+repeats with the last selected parameters.
+
+Examples:
+---------
+* 'digcircle filled 3' = Dig a filled circle with radius = 3.
+* 'digcircle' = Do it again.
+
weather
=======
Prints the current weather map by default.
diff --git a/Readme.html b/Readme.html
index 2448e3f7f..4d7605155 100644
--- a/Readme.html
+++ b/Readme.html
@@ -318,7 +318,7 @@ ul.auto-toc {
-
+
DFHack is a Dwarf Fortress memory access library and a set of basic
tools that use it. Tools come in the form of plugins or (not yet)
external tools. It is an attempt to unite the various ways tools
@@ -326,63 +326,68 @@ access DF memory and allow for easier development of new tools.
-
+
DFHack works on Windows XP, Vista, 7 or any modern Linux distribution.
OSX is not supported due to lack of developers with a Mac.
Currently, only the 31.25 version is supported. If you need DFHack
@@ -407,7 +412,7 @@ for older versions, look for older releases.
It is possible to use the Windows DFHack under wine/OSX.
-
+
Installing DFhack involves copying files into your DF folder.
Copy the files from a release archive so that:
@@ -433,7 +438,7 @@ Copy the files from a release archive so that:
If it refuses to load, check the stderr.log file created in your DF folder.
-
+
DFHack basically extends what DF can do with something similar to a quake console. On Windows, this is a separate command line window. On linux, the terminal used to launch the dfhack script is taken over (so, make sure you start from a terminal).
Basic interaction with dfhack involves entering commands into the console. For some basic instroduction, use the 'help' command. To list all possible commands, use the 'ls' command.
Many commands have their own help or detailed description. You can use 'command help' or 'command ?' to show that.
@@ -443,21 +448,21 @@ Some commands can't be used from hotkeys - this includes interactive commands li
Most of the commands come from plugins. Those reside in 'DF/plugins/'.
-
+
First, don't panic :) Second, dfhack keeps a few log files in DF's folder - stderr.log and stdout.log. You can look at those and possibly find out what's happening.
If you found a bug, you can either report it in the bay12 DFHack thread, the issues tracker on github, contact me (peterix@gmail.com) or visit the #dfhack IRC channel on freenode.
-
+
Almost all the commands have a 'help'/'?' option that will give you further help without having to look at this document.
-
+
Automated item dumping tool. All loose items on the floor marked
for dumping are insta-dumped to the position of the in-game cursor.
Cursor must be placed on a floor tile. Instadumped items may not
show up in the cursor description list until you save/reload.
-
+
@@ -469,16 +474,16 @@ show up in the cursor description list until you save/reload.
-
+
Cleans all the splatter that get scattered all over the map.
By default, it leaves mud and snow alone.
-
+
Confiscates items owned by dwarfs.
By default, owned food on the floor and rotten items are confistacted and dumped.
-
+
@@ -498,10 +503,10 @@ By default, owned food on the floor and rotten items are confistacted and dumped
-
+
Allows listing all the vermin colonies on the map and optionally turning them into honey bee colonies.
-
+
@@ -513,16 +518,16 @@ By default, owned food on the floor and rotten items are confistacted and dumped
-
+
Removes all ramps designated for removal from the map. This is useful for replicating the old channel digging designation.
It also removes any and all 'down ramps' that can remain after a cave-in (you don't have to designate anything for that to happen).
-
+
This is the DFusion lua plugin system by warmist/darius, running as a DFHack plugin.
See the bay12 thread for details: http://www.bay12forums.com/smf/index.php?topic=69682.15
-
+
:simple_embark:allows changing the number of dwarves available on embark.
Note
@@ -535,19 +540,19 @@ It also removes any and all 'down ramps' that can remain after a cave-in (you do
-
+
A tool for checking how many tiles contain flowing liquids. If you suspect that your magma sea leaks into HFS, you can use this tool to be sure without revealing the map.
-
+
Makes all saplings present on the map grow into trees (almost) instantly.
-
+
A tool for getting rid of trees and shrubs. By default, it only kills a tree/shrub under the cursor.
The plants are turned into ashes instantly.
-
+
@@ -563,11 +568,11 @@ The plants are turned into ashes instantly.
-
+
Very similar to extirpate, but additionally sets the plants on fire. The fires can and will spread ;)
-
+
Allows adding magma, water and obsidian to the game. It replaces the normal dfhack command line and can't be used from a hotkey.
For more information, refer to the command's internal help.
@@ -577,7 +582,7 @@ temperatures (creating heat traps). You've been warned.
-
+
This command lets you see and change the game mode directly. Not all combinations are good for every situation and most of them will produce undesirable results.
There are a few good ones though.
@@ -589,22 +594,22 @@ You just lost a fortress and gained an adventurer.
I take no responsibility of anything that happens as a result of using this tool :P
-
+
Forces DF to pause. This is useful when your FPS drops below 1 and you lose control of the game.
-
+
Instantly kills DF without saving.
-
+
Can be used to determine tile properties like temperature.
-
+
Lists all available minerals on the map and how much of them there is. By default, only processes the already discovered part of the map.
-
+
@@ -616,23 +621,23 @@ You just lost a fortress and gained an adventurer.
-
+
This reveals the map. By default, HFS will remain hidden so that the demons don't spawn. You can use 'reveal hell' to reveal everything. With hell revealed, you won't be able to unpause until you hide the map again.
-
+
Reverts the effects of 'reveal'.
-
+
Switches between 'reveal' and 'unreveal'.
-
+
This command will hide the whole map and then reveal all the tiles that have a path to the in-game cursor.
-
+
An isometric visualizer that runs in a second window. This requires working graphics acceleration and at least a dual core CPU (otherwise it will slow down DF).
Unfortunately currently fails to run on Windows XP and most Linux distributions.
All the data resides in the 'stonesense' directory.
@@ -642,24 +647,24 @@ You just lost a fortress and gained an adventurer.
http://df.magmawiki.com/index.php/Utility:Stonesense/Content_repository
-
+
Fills all the adamantine veins again. Veins that were empty will be filled in too, but might still trigger a demon invasion (this is a known bug).
-
+
Designates a whole vein for digging. Requires an active in-game cursor placed over a vein tile. With the 'x' option, it will traverse z-levels (putting stairs between the same-material tiles).
-
+
A permanent alias for 'vdig x'.
-
+
This command can be used for exploratory mining.
See: http://df.magmawiki.com/index.php/DF2010:Exploratory_mining
There are two variables that can be set: pattern and filter.
-
+
@@ -676,7 +681,7 @@ You just lost a fortress and gained an adventurer.
-
+
@@ -692,7 +697,7 @@ You just lost a fortress and gained an adventurer.
After you have a pattern set, you can use 'expdig' to apply it again.
-
+
- 'expdig diag5 hidden' = designate the diagonal 5 patter over all hidden tiles.
- 'expdig' = apply last used pattern and filter.
@@ -700,12 +705,44 @@ You just lost a fortress and gained an adventurer.
+
+
+
A command for easy designation of filled and hollow circles.
+
+
+
+
+
+
+hollow: | Set the circle to hollow (default) |
+
+filled: | Set the circle to filled |
+
+set: | Set designation (default) |
+
+unset: | Unset current designation |
+
+#: | Radius in tiles (default = 0) |
+
+
+
+
After you have set the options, the command called with no options
+repeats with the last selected parameters.
+
+
+
+
+- 'digcircle filled 3' = Dig a filled circle with radius = 3.
+- 'digcircle' = Do it again.
+
+
+
-
+
Prints the current weather map by default.
Also lets you change the current weather to 'clear sky', 'rainy' or 'snowing'.
-
-
+
+
diff --git a/library/include/dfhack/extra/MapExtras.h b/library/include/dfhack/extra/MapExtras.h
index d0ea3597c..9f03d1917 100644
--- a/library/include/dfhack/extra/MapExtras.h
+++ b/library/include/dfhack/extra/MapExtras.h
@@ -162,6 +162,11 @@ class Block
dirty_designations = true;
//printf("setting block %d/%d/%d , %d %d\n",x,y,z, p.x, p.y);
raw.designation[p.x][p.y] = des;
+ if(des.bits.dig)
+ {
+ dirty_blockflags = true;
+ raw.blockflags.bits.designated = true;
+ }
return true;
}
diff --git a/plugins/vdig.cpp b/plugins/vdig.cpp
index bdffb5629..af3c459eb 100644
--- a/plugins/vdig.cpp
+++ b/plugins/vdig.cpp
@@ -19,6 +19,8 @@ DFhackCExport command_result vdig (Core * c, vector & parameters);
DFhackCExport command_result vdigx (Core * c, vector & parameters);
DFhackCExport command_result autodig (Core * c, vector & parameters);
DFhackCExport command_result expdig (Core * c, vector & parameters);
+DFhackCExport command_result digcircle (Core *c, vector & parameters);
+
DFhackCExport const char * plugin_name ( void )
{
@@ -31,6 +33,7 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector
commands.push_back(PluginCommand("vdig","Dig a whole vein.",vdig));
commands.push_back(PluginCommand("vdigx","Dig a whole vein, follow vein through z-levels with stairs.",vdigx));
commands.push_back(PluginCommand("expdig","Select or designate an exploratory pattern. Use 'expdig ?' for help.",expdig));
+ commands.push_back(PluginCommand("digcircle","Dig desingate a circle (filled or hollow) with given radius.",digcircle));
//commands.push_back(PluginCommand("autodig","Mark a tile for continuous digging.",autodig));
return CR_OK;
}
@@ -39,6 +42,221 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
{
return CR_OK;
}
+
+template
+bool from_string(T& t,
+ const std::string& s,
+ std::ios_base& (*f)(std::ios_base&))
+{
+ std::istringstream iss(s);
+ return !(iss >> f >> t).fail();
+}
+
+enum circle_what
+{
+ circle_set,
+ circle_unset,
+};
+
+DFhackCExport command_result digcircle (Core * c, vector & parameters)
+{
+ static bool filled = false;
+ static circle_what what = circle_set;
+ static int r = 0;
+ auto saved_r = r;
+ bool force_help = false;
+ for(int i = 0; i < parameters.size();i++)
+ {
+ 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;
+ }
+ else if (!from_string(r,parameters[i], std::dec))
+ {
+ r = saved_r;
+ }
+ }
+ if(r < 0)
+ r = -r;
+ if(force_help || r == 0)
+ {
+ c->con.print( "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"
+ " set = set designation\n"
+ " unset = unset current designation\n"
+ " # = radius in tiles (default = 0)\n"
+ "\n"
+ "After you have set the options, the command called with no options\n"
+ "repeats with the last selected parameters:\n"
+ "'digcircle filled 3' = Dig a filled circle with radius = 3.\n"
+ "'digcircle' = Do it again.\n"
+ );
+ return CR_OK;
+ }
+ int32_t cx, cy, cz;
+ c->Suspend();
+ Gui * gui = c->getGui();
+ Maps * maps = c->getMaps();
+ if(!maps->Start())
+ {
+ c->Resume();
+ c->con.printerr("Can't init the map...\n");
+ return CR_FAILURE;
+ }
+
+ uint32_t x_max, y_max, z_max;
+ maps->getSize(x_max,y_max,z_max);
+
+ MapExtras::MapCache MCache (maps);
+ if(!gui->getCursorCoords(cx,cy,cz) || cx == -30000)
+ {
+ c->Resume();
+ c->con.printerr("Can't get the cursor coords...\n");
+ return CR_FAILURE;
+ }
+ auto dig = [&](int32_t x, int32_t y, int32_t z) -> bool
+ {
+ DFCoord at (x,y,z);
+ auto b = MCache.BlockAt(at/16);
+ if(!b || !b->valid)
+ return false;
+ if(x == 0 || x == x_max - 1)
+ return false;
+ if(y == 0 || y == y_max - 1)
+ return false;
+ uint16_t tt = MCache.tiletypeAt(at);
+ t_designation des = MCache.designationAt(at);
+ // could be potentially used to locate hidden constructions?
+ if(tileMaterial(tt) == CONSTRUCTED && !des.bits.hidden)
+ return false;
+ if(!isWallTerrain(tt) && !des.bits.hidden)
+ return false;
+ switch(what)
+ {
+ case circle_set:
+ if(des.bits.dig == designation_no)
+ {
+ des.bits.dig = designation_default;
+ }
+ break;
+ case circle_unset:
+ if (des.bits.dig == designation_default)
+ {
+ des.bits.dig = designation_no;
+ }
+ break;
+ }
+ MCache.setDesignationAt(at,des);
+ return true;
+ };
+ auto lineX = [&](int32_t y1, int32_t y2, int32_t x, int32_t z) -> bool
+ {
+ for(int32_t y = y1; y <= y2; y++)
+ {
+ dig(x,y,z);
+ }
+ return true;
+ };
+ auto lineY = [&](int32_t x1, int32_t x2, int32_t y, int32_t z) -> bool
+ {
+ for(int32_t x = x1; x <= x2; x++)
+ {
+ dig(x,y,z);
+ }
+ return true;
+ };
+ int f = 1 - r;
+ int ddF_x = 1;
+ int ddF_y = -2 * r;
+ int x = 0;
+ int y = r;
+ if(!filled)
+ {
+ dig(cx, cy + r, cz);
+ dig(cx, cy - r, cz);
+ dig(cx + r, cy, cz);
+ dig(cx - r, cy, cz);
+ }
+ else
+ {
+ lineX(cy-r, cy+r, cx, cz);
+ lineY(cx-r, cx+r, cy, cz);
+ }
+
+ while(x < y)
+ {
+ // ddF_x == 2 * x + 1;
+ // ddF_y == -2 * y;
+ // f == x*x + y*y - radius*radius + 2*x - y + 1;
+ if(f >= 0)
+ {
+ y--;
+ ddF_y += 2;
+ f += ddF_y;
+ }
+ x++;
+ ddF_x += 2;
+ f += ddF_x;
+ if(!filled)
+ {
+ dig(cx + x, cy + y, cz);
+ dig(cx - x, cy + y, cz);
+ dig(cx + x, cy - y, cz);
+ dig(cx - x, cy - y, cz);
+ dig(cx + y, cy + x, cz);
+ dig(cx - y, cy + x, cz);
+ dig(cx + y, cy - x, cz);
+ dig(cx - y, cy - x, cz);
+ }
+ else
+ {
+ lineY(cx-x, cx+x, cy+y, cz);
+ lineY(cx-x, cx+x, cy-y, cz);
+ lineY(cx-y, cx+y, cy+x, cz);
+ lineY(cx-y, cx+y, cy-x, cz);
+ }
+ }
+ /*
+ int x = -r, y = 0, err = 2-2*r; // 2. quadrant
+ do
+ {
+ dig(cx-x, cy+y, cz); // 1. quadrant
+ dig(cx-y, cy-x, cz); // 2. quadrant
+ dig(cx+x, cy-y, cz); // 3. quadrant
+ dig(cx+y, cy+x, cz); // 4. quadrant
+ r = err;
+ if (r > x)
+ {
+ err += ++x*2+1; // e_xy+e_x > 0
+ }
+ if (r <= y)
+ {
+ err += ++y*2+1; // e_xy+e_y < 0
+ }
+ } while (x < 0);*/
+ MCache.WriteAll();
+ c->Resume();
+ return CR_OK;
+}
typedef char digmask[16][16];
static digmask diag5[5] =