Added "workflow clear all" command to remove all constraints.

develop
Clayton Hughes 2012-03-12 00:05:22 -07:00
parent 445b580ad1
commit 7dff12ead7
1 changed files with 22 additions and 0 deletions

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