summaryrefslogtreecommitdiff
path: root/plugins/cleaners.cpp
diff options
context:
space:
mode:
authorTimothy Collett2012-09-10 11:54:56 -0400
committerTimothy Collett2012-09-10 11:54:56 -0400
commit96abc903abb93b7bf7418f2da3455ee6da5ad942 (patch)
treea5326ef1dbd492086b319c888854e707c59d2a56 /plugins/cleaners.cpp
parent274d6038adce5797b58cee78a330eb5d639bf59e (diff)
parent21904fd607d0f2037782e28ff7284300663931ab (diff)
downloaddfhack-96abc903abb93b7bf7418f2da3455ee6da5ad942.tar.gz
dfhack-96abc903abb93b7bf7418f2da3455ee6da5ad942.tar.bz2
dfhack-96abc903abb93b7bf7418f2da3455ee6da5ad942.tar.xz
Merge branch 'master' of http://github.com/peterix/dfhack
Diffstat (limited to 'plugins/cleaners.cpp')
-rw-r--r--plugins/cleaners.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/plugins/cleaners.cpp b/plugins/cleaners.cpp
index fb436a6d..c0301de7 100644
--- a/plugins/cleaners.cpp
+++ b/plugins/cleaners.cpp
@@ -114,6 +114,28 @@ command_result cleanunits (color_ostream &out)
return CR_OK;
}
+command_result cleanplants (color_ostream &out)
+{
+ // Invoked from clean(), already suspended
+ int cleaned_plants = 0, cleaned_total = 0;
+ for (size_t i = 0; i < world->plants.all.size(); i++)
+ {
+ df::plant *plant = world->plants.all[i];
+
+ if (plant->contaminants.size())
+ {
+ for (size_t j = 0; j < plant->contaminants.size(); j++)
+ delete plant->contaminants[j];
+ cleaned_plants++;
+ cleaned_total += plant->contaminants.size();
+ plant->contaminants.clear();
+ }
+ }
+ if (cleaned_total)
+ out.print("Removed %d contaminants from %d plants.\n", cleaned_total, cleaned_plants);
+ return CR_OK;
+}
+
command_result spotclean (color_ostream &out, vector <string> & parameters)
{
// HOTKEY COMMAND: CORE ALREADY SUSPENDED
@@ -153,6 +175,7 @@ command_result clean (color_ostream &out, vector <string> & parameters)
bool mud = false;
bool units = false;
bool items = false;
+ bool plants = false;
for(size_t i = 0; i < parameters.size();i++)
{
if(parameters[i] == "map")
@@ -161,11 +184,14 @@ command_result clean (color_ostream &out, vector <string> & parameters)
units = true;
else if(parameters[i] == "items")
items = true;
+ else if(parameters[i] == "plants")
+ plants = true;
else if(parameters[i] == "all")
{
map = true;
items = true;
units = true;
+ plants = true;
}
else if(parameters[i] == "snow")
snow = true;
@@ -174,7 +200,7 @@ command_result clean (color_ostream &out, vector <string> & parameters)
else
return CR_WRONG_USAGE;
}
- if(!map && !units && !items)
+ if(!map && !units && !items && !plants)
return CR_WRONG_USAGE;
CoreSuspender suspend;
@@ -185,6 +211,8 @@ command_result clean (color_ostream &out, vector <string> & parameters)
cleanunits(out);
if(items)
cleanitems(out);
+ if(plants)
+ cleanplants(out);
return CR_OK;
}
@@ -198,6 +226,7 @@ DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <Plug
" map - clean the map tiles\n"
" items - clean all items\n"
" units - clean all creatures\n"
+ " plants - clean all plants\n"
" all - clean everything.\n"
"More options for 'map':\n"
" snow - also remove snow\n"