summaryrefslogtreecommitdiff
path: root/plugins/getplants.cpp
diff options
context:
space:
mode:
authorQuietust2012-02-22 15:31:34 -0600
committerQuietust2012-02-22 15:31:34 -0600
commit491c3aa0c9965cedefed4d8a024404fe35196d8f (patch)
tree50bf8c237ee964243c184486724539c4f4ad7d26 /plugins/getplants.cpp
parente9b45a5b6d71f579d1dd0e0188f747cd14adc51f (diff)
downloaddfhack-491c3aa0c9965cedefed4d8a024404fe35196d8f.tar.gz
dfhack-491c3aa0c9965cedefed4d8a024404fe35196d8f.tar.bz2
dfhack-491c3aa0c9965cedefed4d8a024404fe35196d8f.tar.xz
Add "-a" option to getplants, selects every type of plant
Diffstat (limited to 'plugins/getplants.cpp')
-rw-r--r--plugins/getplants.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/plugins/getplants.cpp b/plugins/getplants.cpp
index 5361a7ea..0c58f7a6 100644
--- a/plugins/getplants.cpp
+++ b/plugins/getplants.cpp
@@ -28,7 +28,7 @@ command_result df_getplants (Core * c, vector <string> & parameters)
string plantMatStr = "";
set<int> plantIDs;
set<string> plantNames;
- bool deselect = false, exclude = false, treesonly = false, shrubsonly = false;
+ bool deselect = false, exclude = false, treesonly = false, shrubsonly = false, all = false;
int count = 0;
for (size_t i = 0; i < parameters.size(); i++)
@@ -43,6 +43,8 @@ command_result df_getplants (Core * c, vector <string> & parameters)
deselect = true;
else if(parameters[i] == "-x")
exclude = true;
+ else if(parameters[i] == "-a")
+ all = true;
else
plantNames.insert(parameters[i]);
}
@@ -51,13 +53,25 @@ command_result df_getplants (Core * c, vector <string> & parameters)
c->con.printerr("Cannot specify both -t and -s at the same time!\n");
return CR_WRONG_USAGE;
}
+ if (all && exclude)
+ {
+ c->con.printerr("Cannot specify both -a and -x at the same time!\n");
+ return CR_WRONG_USAGE;
+ }
+ if (all && plantNames.size())
+ {
+ c->con.printerr("Cannot specify -a along with plant IDs!\n");
+ return CR_WRONG_USAGE;
+ }
CoreSuspender suspend(c);
for (size_t i = 0; i < world->raws.plants.all.size(); i++)
{
df::plant_raw *plant = world->raws.plants.all[i];
- if (plantNames.find(plant->id) != plantNames.end())
+ if (all)
+ plantIDs.insert(i);
+ else if (plantNames.find(plant->id) != plantNames.end())
{
plantNames.erase(plant->id);
plantIDs.insert(i);
@@ -148,6 +162,7 @@ DFhackCExport command_result plugin_init ( Core * c, vector <PluginCommand> &com
" -s - Select shrubs only (exclude trees)\n"
" -c - Clear designations instead of setting them\n"
" -x - Apply selected action to all plants except those specified\n"
+ " -a - Select every type of plant (obeys -t/-s)\n"
"Specifying both -t and -s will have no effect.\n"
"If no plant IDs are specified, all valid plant IDs will be listed.\n"
));