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.
develop
Alexander Gavrilov 2012-01-28 17:40:09 +04:00
parent fa4fb4b407
commit 683c989d0f
1 changed files with 27 additions and 1 deletions

@ -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