diff options
| author | Quietust | 2012-08-18 19:21:40 -0500 |
|---|---|---|
| committer | Quietust | 2012-08-18 19:21:40 -0500 |
| commit | 8ed219d4e0cbea19c8a9489294a975b81946bba2 (patch) | |
| tree | 95dad9eea822acf531edb4ca49fd6009ebfc9eb4 /plugins/cleaners.cpp | |
| parent | c6694e386fa3a01bae34991a503b22fb4055e757 (diff) | |
| download | dfhack-8ed219d4e0cbea19c8a9489294a975b81946bba2.tar.gz dfhack-8ed219d4e0cbea19c8a9489294a975b81946bba2.tar.bz2 dfhack-8ed219d4e0cbea19c8a9489294a975b81946bba2.tar.xz | |
Add "clean plants", currently just removes water from rain (and lets you set them on fire)
Diffstat (limited to 'plugins/cleaners.cpp')
| -rw-r--r-- | plugins/cleaners.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/plugins/cleaners.cpp b/plugins/cleaners.cpp index 30befab2..de204f61 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" |
