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.
This commit is contained in:
Ignacio R. Morelle 2009-03-01 17:00:45 +00:00
parent f22e353be8
commit c861aaf670
2 changed files with 20 additions and 13 deletions

View file

@ -32,6 +32,8 @@ Version 1.5.11+svn:
* 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:

View file

@ -1414,21 +1414,26 @@ void formula_ai::play_turn()
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) ) {}
}
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) + ")");
}
}
}
else {
ERR_AI << "FIXME: unit iterator invalidated after make_move()!\n";
}
}
}