summaryrefslogtreecommitdiff
path: root/plugins/workflow.cpp
diff options
context:
space:
mode:
authorClayton Hughes2012-03-12 00:05:22 -0700
committerClayton Hughes2012-03-12 00:05:22 -0700
commit7dff12ead7651aec8189bc213d1222a5663a682c (patch)
treec5b2d17c9c5c494d780cb6cb7568b2a714c8a144 /plugins/workflow.cpp
parent445b580ad148767f7b623e156f0d9b8b1284b4d9 (diff)
downloaddfhack-7dff12ead7651aec8189bc213d1222a5663a682c.tar.gz
dfhack-7dff12ead7651aec8189bc213d1222a5663a682c.tar.bz2
dfhack-7dff12ead7651aec8189bc213d1222a5663a682c.tar.xz
Added "workflow clear all" command to remove all constraints.
Diffstat (limited to 'plugins/workflow.cpp')
-rw-r--r--plugins/workflow.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/plugins/workflow.cpp b/plugins/workflow.cpp
index a8ace1b0..9040ffc1 100644
--- a/plugins/workflow.cpp
+++ b/plugins/workflow.cpp
@@ -701,6 +701,19 @@ static ItemConstraint *get_constraint(Core *c, const std::string &str, Persisten
return nct;
}
+static void delete_all_constraints(Core *c)
+{
+ for(std::vector<ItemConstraint*>::iterator iter = constraints.begin();
+ iter != constraints.end();
+ ++iter)
+ {
+ c->getWorld()->DeletePersistentData((*iter)->config);
+ delete (*iter);
+ }
+
+ constraints.clear();
+}
+
static void delete_constraint(Core *c, ItemConstraint *cv)
{
int idx = linear_index(constraints, cv);
@@ -1557,6 +1570,15 @@ static command_result workflow_cmd(Core *c, vector <string> & parameters)
c->con.printerr("Constraint not found: %s\n", parameters[1].c_str());
return CR_FAILURE;
}
+ else if (cmd == "clear")
+ {
+ if(parameters.size() == 1 && parameters[0] == "all")
+ {
+ delete_all_constraints(c);
+ return CR_OK;
+ }
+ return CR_WRONG_USAGE;
+ }
else
return CR_WRONG_USAGE;
}