Fix bug #6804 (infinite loop in AI retreat phase).

We kept trying to desperate attack, even without attacks remaining,
giving infinite recursion.
This commit is contained in:
Rusty Russell 2006-09-03 05:42:14 +00:00
parent 9518e55585
commit 376d5923d6

View File

@ -1339,8 +1339,11 @@ bool ai::retreat_units(std::map<gamemap::location,paths>& possible_moves, const
// If we can't move, we should be more aggressive in lashing out. // If we can't move, we should be more aggressive in lashing out.
if (best_pos == i->first) { if (best_pos == i->first) {
if (i->second.attacks_left()) {
return desperate_attack(i->first); return desperate_attack(i->first);
} }
return false;
}
if(best_pos.valid()) { if(best_pos.valid()) {
LOG_AI << "retreating '" << i->second.id() << "' " << i->first LOG_AI << "retreating '" << i->second.id() << "' " << i->first