Stop hidden weapons (attack_weight=0) from skewing the best weapon selection

This commit is contained in:
Alexander van Gessel 2010-05-30 05:30:34 +01:00
parent a9cbaeedc7
commit 2bfebcaf61
2 changed files with 3 additions and 1 deletions

View File

@ -149,6 +149,7 @@ Version 1.9.0-svn:
* Cleaned up the gui2 code at various places
* Don't crash if a [story] [part] [if] misses [then] or [else] (bug #16028)
* Fix a crash on OS X caused by passing invalid utf8 to pango (bug #16020)
* Hidden weapons (attack_weight = 0) no longer skew the best weapon selection
Version 1.8.0:
* AI:

View File

@ -641,7 +641,8 @@ int mouse_handler::fill_weapon_choices(std::vector<battle_context>& bc_vector, u
battle_context bc(units_, attacker->get_location(), defender->get_location(), i);
bc_vector.push_back(bc);
if (bc.better_attack(bc_vector[best], 0.5)) {
best = i;
// as some weapons can be hidden, i is not a valid index into the resulting vector
best = bc_vector.size() - 1;
}
}
}