Author: crab
Date: Sat Apr 25 17:47:20 2009
New Revision: 35195

URL: http://svn.gna.org/viewcvs/wesnoth?rev=35195&view=rev
Log:
Fixes bug #13425 - catches formula errors at ai level, with better logging.

Modified:
    trunk/src/ai/formula_ai.cpp

Modified: trunk/src/ai/formula_ai.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai/formula_ai.cpp?rev=35195&r1=35194&r2=35195&view=diff
==============================================================================
--- trunk/src/ai/formula_ai.cpp (original)
+++ trunk/src/ai/formula_ai.cpp Sat Apr 25 17:47:20 2009
@@ -1754,26 +1754,40 @@
             }
        }
 
-       if( candidate_action_manager_.has_candidate_actions() ) {
-               move_maps_valid_ = false;
-               while( 
candidate_action_manager_.evaluate_candidate_actions(this, units_) )
-               {
-                       game_logic::map_formula_callable callable(this);
-                       callable.add_ref();
-
-                       candidate_action_manager_.update_callable_map( callable 
);
-
-                       const_formula_ptr 
move_formula(candidate_action_manager_.get_best_action_formula());
-
-                       make_action(move_formula, callable);
-
+       try {
+               if( candidate_action_manager_.has_candidate_actions() ) {
                        move_maps_valid_ = false;
-               }
+                       while( 
candidate_action_manager_.evaluate_candidate_actions(this, units_) )
+                       {
+                               game_logic::map_formula_callable callable(this);
+                               callable.add_ref();
+
+                               candidate_action_manager_.update_callable_map( 
callable );
+
+                               const_formula_ptr 
move_formula(candidate_action_manager_.get_best_action_formula());
+
+                               make_action(move_formula, callable);
+
+                               move_maps_valid_ = false;
+                       }
+               }
+       }
+       catch(formula_error& e) {
+               if(e.filename == "formula")
+                       e.line = 0;
+                       handle_exception( e, "Formula error in RCA loop");
        }
 
        game_logic::map_formula_callable callable(this);
        callable.add_ref();
-        while(make_action(move_formula_,callable)) { }
+       try {
+               while(make_action(move_formula_,callable)) { }
+       }
+       catch(formula_error& e) {
+               if(e.filename == "formula")
+                       e.line = 0;
+                       handle_exception( e, "Formula error");
+       }
 
 }
 


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to