summaryrefslogtreecommitdiff
path: root/plugins/autodump.cpp
diff options
context:
space:
mode:
authorAlexander Gavrilov2012-01-28 17:40:09 +0400
committerAlexander Gavrilov2012-01-28 17:40:09 +0400
commit683c989d0f60e0f7672cb764b1fc88685a29a2aa (patch)
treeb22f5b2bb37f5e0fad41044ec6d5f139be78059b /plugins/autodump.cpp
parentfa4fb4b407b701d707ac3e3a4a0e6804cca2c526 (diff)
downloaddfhack-683c989d0f60e0f7672cb764b1fc88685a29a2aa.tar.gz
dfhack-683c989d0f60e0f7672cb764b1fc88685a29a2aa.tar.bz2
dfhack-683c989d0f60e0f7672cb764b1fc88685a29a2aa.tar.xz
Add options to autodump that filter on the forbidden and hidden flags.
This allows processing only a specific subset of items by first setting an unlikely combination of flags, like dump+hide+forbid.
Diffstat (limited to 'plugins/autodump.cpp')
-rw-r--r--plugins/autodump.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/plugins/autodump.cpp b/plugins/autodump.cpp
index 7b9c9d2c..7299da67 100644
--- a/plugins/autodump.cpp
+++ b/plugins/autodump.cpp
@@ -54,6 +54,9 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand>
"Options:\n"
" destroy - instead of dumping, destroy the items instantly.\n"
" destroy-here - only affect the tile under cursor.\n"
+ " visible - only process items that are not hidden.\n"
+ " hidden - only process hidden items.\n"
+ " forbidden - only process forbidden items (default: only unforbidden).\n"
));
commands.push_back(PluginCommand(
"autodump-destroy-here", "Destroy items marked for dumping under cursor.",
@@ -82,6 +85,9 @@ static command_result autodump_main(Core * c, vector <string> & parameters)
// Command line options
bool destroy = false;
bool here = false;
+ bool need_visible = false;
+ bool need_hidden = false;
+ bool need_forbidden = false;
if(parameters.size() > 0)
{
string & p = parameters[0];
@@ -89,10 +95,22 @@ static command_result autodump_main(Core * c, vector <string> & parameters)
destroy = true;
else if (p == "destroy-here")
destroy = here = true;
+ else if (p == "visible")
+ need_visible = true;
+ else if (p == "hidden")
+ need_hidden = true;
+ else if (p == "forbidden")
+ need_forbidden = true;
else
return CR_WRONG_USAGE;
}
+ if (need_visible && need_hidden)
+ {
+ c->con.printerr("An item can't be both hidden and visible.\n");
+ return CR_WRONG_USAGE;
+ }
+
DFHack::VersionInfo *mem = c->vinfo;
DFHack::Gui * Gui = c->getGui();
if (!Maps::IsValid())
@@ -158,7 +176,6 @@ static command_result autodump_main(Core * c, vector <string> & parameters)
if ( !itm->flags.bits.dump
|| !itm->flags.bits.on_ground
|| itm->flags.bits.construction
- || itm->flags.bits.hidden
|| itm->flags.bits.in_building
|| itm->flags.bits.in_chest
|| itm->flags.bits.in_inventory
@@ -166,6 +183,15 @@ static command_result autodump_main(Core * c, vector <string> & parameters)
)
continue;
+ if (need_visible && itm->flags.bits.hidden)
+ continue;
+ if (need_hidden && !itm->flags.bits.hidden)
+ continue;
+ if (need_forbidden && !itm->flags.bits.forbid)
+ continue;
+ if (!need_forbidden && itm->flags.bits.forbid)
+ continue;
+
if(!destroy) // move to cursor
{
// Change flags to indicate the dump was completed, as if by super-dwarfs