mail[Wesnoth-commits] r33370 - /trunk/src/formula_ai.cpp


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

Header


Content

Posted by dragonking on March 06, 2009 - 23:07:
Author: dragonking
Date: Fri Mar  6 23:07:20 2009
New Revision: 33370

URL: http://svn.gna.org/viewcvs/wesnoth?rev=33370&view=rev
Log:
Made unit loop formulas work even when no unit formula is specified

Modified:
    trunk/src/formula_ai.cpp

Modified: trunk/src/formula_ai.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/formula_ai.cpp?rev=33370&r1=33369&r2=33370&view=diff
==============================================================================
--- trunk/src/formula_ai.cpp (original)
+++ trunk/src/formula_ai.cpp Fri Mar  6 23:07:20 2009
@@ -1463,8 +1463,9 @@
 
        for(unit_map::unit_iterator i = units_.begin() ; i != units_.end() ; 
++i)
        {
-               if ( (i->second.side() == get_info().team_num) && 
i->second.has_formula() )
+               if ( (i->second.side() == get_info().team_num)  )
                {
+                    if ( i->second.has_formula() ) {
                        try {
                                game_logic::const_formula_ptr formula(new 
game_logic::formula(i->second.get_formula(), &function_table));
                                game_logic::map_formula_callable 
callable(this);
@@ -1477,24 +1478,24 @@
                                        e.line = 0;
                                handle_exception( e, "Unit formula error for 
unit: '" + i->second.type_id() + "' standing at (" + 
boost::lexical_cast<std::string>(i->first.x+1) + "," + 
boost::lexical_cast<std::string>(i->first.y+1) + ")");
                        }
-
-                       if( i.valid() ) {
-                               if( i->second.has_loop_formula() )
-                               {
-                                       try {
-                                               game_logic::const_formula_ptr 
loop_formula(new game_logic::formula(i->second.get_loop_formula(), 
&function_table));
-                                               
game_logic::map_formula_callable callable(this);
-                                               callable.add_ref();
-                                               callable.add("me", 
variant(new unit_callable(*i)));
-                                               while ( 
make_move(loop_formula, callable) ) {}
-                                       }
-                                       catch(formula_error& e) {
-                                               if(e.filename == "formula")
-                                                       e.line = 0;
-                                               handle_exception( e, "Unit 
loop formula error for unit: '" + i->second.type_id() + "' standing at (" + 
boost::lexical_cast<std::string>(i->first.x+1) + "," + 
boost::lexical_cast<std::string>(i->first.y+1) + ")");
-                                       }
-                               }
-                       }
+                    }
+                    if( i.valid() ) {
+                        if( i->second.has_loop_formula() )
+                        {
+                                try {
+                                        game_logic::const_formula_ptr 
loop_formula(new game_logic::formula(i->second.get_loop_formula(), 
&function_table));
+                                        game_logic::map_formula_callable 
callable(this);
+                                        callable.add_ref();
+                                        callable.add("me", variant(new 
unit_callable(*i)));
+                                        while ( make_move(loop_formula, 
callable) ) {}
+                                }
+                                catch(formula_error& e) {
+                                        if(e.filename == "formula")
+                                                e.line = 0;
+                                        handle_exception( e, "Unit loop 
formula error for unit: '" + i->second.type_id() + "' standing at (" + 
boost::lexical_cast<std::string>(i->first.x+1) + "," + 
boost::lexical_cast<std::string>(i->first.y+1) + ")");
+                                }
+                        }
+                    }
                }
        }
 




Related Messages


Powered by MHonArc, Updated Sat Mar 07 00:00:32 2009