mail[Wesnoth-commits] r33248 - in /trunk: changelog src/formula_ai.cpp


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

Header


Content

Posted by shadowm2006 on March 01, 2009 - 18:00:
Author: shadowmaster
Date: Sun Mar  1 18:00:45 2009
New Revision: 33248

URL: http://svn.gna.org/viewcvs/wesnoth?rev=33248&view=rev
Log:
Partial fix for bug #13092 : avoid a case of invalid iterator usage in
FormulaAI.

Please do not mark this bug as fixed until a formula AI expert reviews
this patch.

Modified:
    trunk/changelog
    trunk/src/formula_ai.cpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=33248&r1=33247&r2=33248&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Sun Mar  1 18:00:45 2009
@@ -32,6 +32,8 @@
    * Fixed bug #13090: Make movement_costs < 1 behave like movement_costs = 1
  * Miscellaneous and bug fixes:
    * Align all network buffers on 4 bytes
+   * Partial fix for bug #13092: avoid a case of invalid iterator usage
+     in FormulaAI
 
 Version 1.5.11:
  * Campaigns:

Modified: trunk/src/formula_ai.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/formula_ai.cpp?rev=33248&r1=33247&r2=33248&view=diff
==============================================================================
--- trunk/src/formula_ai.cpp (original)
+++ trunk/src/formula_ai.cpp Sun Mar  1 18:00:45 2009
@@ -1414,20 +1414,25 @@
                                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->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) ) {}
+                       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) + ")");
+                                       }
                                }
-                               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) + ")");
-                               }
+                       }
+                       else {
+                               ERR_AI << "FIXME: unit iterator invalidated 
after make_move()!\n";
                        }
                }
        }




Related Messages


Powered by MHonArc, Updated Sun Mar 01 18:40:06 2009