fixed incorrect assertion statement

This commit is contained in:
David White 2008-03-17 22:14:49 +00:00
parent d0018fdec7
commit a18b053c48
2 changed files with 18 additions and 6 deletions

View File

@ -332,16 +332,28 @@ private:
class filter_function : public function_expression {
public:
explicit filter_function(const args_list& args)
: function_expression("filter", args, 2, 2)
: function_expression("filter", args, 2, 3)
{}
private:
variant execute(const formula_callable& variables) const {
std::vector<variant> vars;
const variant items = args()[0]->evaluate(variables);
for(int n = 0; n != items.num_elements(); ++n) {
const variant val = args()[1]->evaluate(formula_callable_with_backup(*items[n].as_callable(), variables));
if(val.as_bool()) {
vars.push_back(items[n]);
if(args().size() == 2) {
for(int n = 0; n != items.num_elements(); ++n) {
const variant val = args()[1]->evaluate(formula_callable_with_backup(*items[n].as_callable(), variables));
if(val.as_bool()) {
vars.push_back(items[n]);
}
}
} else {
map_formula_callable self_callable;
const std::string self = args()[1]->evaluate(variables).as_string();
for(int n = 0; n != items.num_elements(); ++n) {
self_callable.add(self, items[n]);
const variant val = args()[2]->evaluate(formula_callable_with_backup(self_callable, formula_callable_with_backup(*items[n].as_callable(), variables)));
if(val.as_bool()) {
vars.push_back(items[n]);
}
}
}

View File

@ -449,7 +449,7 @@ void game::send_change_controller(const size_t side_num,
// Update the level so observers who join get the new name.
const simple_wml::node::child_list& side_list = level_.root().children("side");
const int index = side_num - 1;
assert(side_num < side_list.size());
assert(index < side_list.size());
side_list[index]->set_attr_dup("current_player", newplayer->second.name().c_str());
}