mail[Wesnoth-commits] r24768 - in /trunk/src: formula_function.cpp server/game.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by dave on March 17, 2008 - 23:16:
Author: dave
Date: Mon Mar 17 23:14:49 2008
New Revision: 24768

URL: http://svn.gna.org/viewcvs/wesnoth?rev=24768&view=rev
Log:
fixed incorrect assertion statement

Modified:
    trunk/src/formula_function.cpp
    trunk/src/server/game.cpp

Modified: trunk/src/formula_function.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/formula_function.cpp?rev=24768&r1=24767&r2=24768&view=diff
==============================================================================
--- trunk/src/formula_function.cpp (original)
+++ trunk/src/formula_function.cpp Mon Mar 17 23:14:49 2008
@@ -332,16 +332,28 @@
 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]);
+                               }
                        }
                }
 

Modified: trunk/src/server/game.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/game.cpp?rev=24768&r1=24767&r2=24768&view=diff
==============================================================================
--- trunk/src/server/game.cpp (original)
+++ trunk/src/server/game.cpp Mon Mar 17 23:14:49 2008
@@ -449,7 +449,7 @@
        // 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());
 }
 




Related Messages


Powered by MHonArc, Updated Tue Mar 18 00:02:00 2008